diff options
author | Ivan Fefer <ivan.fefer@mongodb.com> | 2022-10-07 07:29:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-07 08:02:46 +0000 |
commit | 27e71f251ee6a2136d10b895c72391f9c5a12d59 (patch) | |
tree | b0f7c3466f6ca7a22e3f7639898df78ce460f269 /jstests/core | |
parent | 0406b63884d9993f0eafd7d6dcd680e0ecdc1a1f (diff) | |
download | mongo-27e71f251ee6a2136d10b895c72391f9c5a12d59.tar.gz |
SERVER-70270: Use fail_point_util.js instead of checkLog to wait for failpoint hit
Diffstat (limited to 'jstests/core')
-rw-r--r-- | jstests/core/txns/speculative_snapshot_includes_all_writes.js | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/jstests/core/txns/speculative_snapshot_includes_all_writes.js b/jstests/core/txns/speculative_snapshot_includes_all_writes.js index e5cdda1ce0c..54979b34033 100644 --- a/jstests/core/txns/speculative_snapshot_includes_all_writes.js +++ b/jstests/core/txns/speculative_snapshot_includes_all_writes.js @@ -12,6 +12,8 @@ (function() { "use strict"; +load("jstests/libs/fail_point_util.js"); + const dbName = "test"; const collName = "speculative_snapshot_includes_all_writes_1"; const collName2 = "speculative_snapshot_includes_all_writes_2"; @@ -44,10 +46,8 @@ let checkReads = (session, collExpected, coll2Expected) => { assert.sameMembers(coll2Expected, coll2.find().toArray()); }; -// Clear ramlog so checkLog can't find log messages from previous times this fail point was -// enabled. -assert.commandWorked(testDB.adminCommand({clearLog: 'global'})); - +const failPoint = configureFailPoint( + db, "hangAfterCollectionInserts", {collectionNS: testColl2.getFullName(), first_id: "b"}); try { // The default WC is majority and this test can't satisfy majority writes. assert.commandWorked(testDB.adminCommand( @@ -58,20 +58,13 @@ try { assert.commandWorked(testColl2.insert([{_id: "a"}], {writeConcern: {w: "majority"}})); jsTest.log("Create the uncommitted write."); - - assert.commandWorked(db.adminCommand({ - configureFailPoint: "hangAfterCollectionInserts", - mode: "alwaysOn", - data: {collectionNS: testColl2.getFullName()} - })); - const joinHungWrite = startParallelShell(() => { assert.commandWorked( db.getSiblingDB("test").speculative_snapshot_includes_all_writes_2.insert( {_id: "b"}, {writeConcern: {w: "majority"}})); }); - checkLog.containsJson(db.getMongo(), 20289); + failPoint.wait(); jsTest.log("Create a write following the uncommitted write."); // Note this write must use local write concern; it cannot be majority committed until @@ -91,11 +84,7 @@ try { checkReads(defaultSession, [{_id: 0}, {_id: 1}], [{_id: "a"}]); jsTestLog("Allow the uncommitted write to finish."); - assert.commandWorked(db.adminCommand({ - configureFailPoint: "hangAfterCollectionInserts", - mode: "off", - })); - + failPoint.off(); joinHungWrite(); jsTestLog("Double-checking that writes not committed at start of snapshot cannot appear."); @@ -121,6 +110,7 @@ try { localSession.endSession(); defaultSession.endSession(); } finally { + failPoint.off(); // Unsetting CWWC is not allowed, so explicitly restore the default write concern to be majority // by setting CWWC to {w: majority}. assert.commandWorked(testDB.adminCommand({ |