summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2019-03-15 09:55:33 -0400
committerJames Wahlin <james@mongodb.com>2019-03-22 13:35:51 -0400
commita024594e29523cd3213f6127e120a00c697d0831 (patch)
treec752a71ad4f56a64d327d47e42e41c1e6b7411ae
parent0eecc58363a2173d9a2bc91e9e7dc8665e12bfac (diff)
downloadmongo-a024594e29523cd3213f6127e120a00c697d0831.tar.gz
SERVER-40154 change_streams_resume_at_same_clustertime.js should not assume change order
(cherry picked from commit b6958f06004e45baf0fb4b2593dd6bd2e4765279)
-rw-r--r--jstests/noPassthrough/change_streams_resume_at_same_clustertime.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/jstests/noPassthrough/change_streams_resume_at_same_clustertime.js b/jstests/noPassthrough/change_streams_resume_at_same_clustertime.js
index e6eb5862aea..73cb523ce49 100644
--- a/jstests/noPassthrough/change_streams_resume_at_same_clustertime.js
+++ b/jstests/noPassthrough/change_streams_resume_at_same_clustertime.js
@@ -10,7 +10,7 @@
const st =
new ShardingTest({shards: 2, rs: {nodes: 1, setParameter: {writePeriodicNoops: false}}});
- const mongosDB = st.s.getDB(jsTestName());
+ const mongosDB = st.s.startSession({causalConsistency: true}).getDatabase(jsTestName());
const mongosColl = mongosDB.test;
// Enable sharding on the test DB and ensure its primary is shard0.
@@ -39,14 +39,14 @@
// bump the oplog timestamp. We expect however that they will be identical for most test runs,
// so there is value in testing.
let clusterTime = null, updateEvent = null;
- for (let id of[-10, 10]) {
+ for (let x = 0; x < 2; ++x) {
assert.soon(() => csCursor.hasNext());
updateEvent = csCursor.next();
- assert.eq(updateEvent.documentKey._id, id);
clusterTime = (clusterTime || updateEvent.clusterTime);
assert.gte(updateEvent.clusterTime, clusterTime);
assert.eq(updateEvent.updateDescription.updatedFields.updated, 1);
}
+ assert.soon(() => csCursor.hasNext());
// Update both documents again, so that we will have something to observe after resuming.
assert.commandWorked(mongosColl.update({}, {$set: {updatedYetAgain: 1}}, {multi: true}));
@@ -56,14 +56,14 @@
// mongoS when resuming, rather than scanning all the way to the most recent point in its oplog.
csCursor = mongosColl.watch([], {resumeAfter: updateEvent._id, cursor: {batchSize: 1}});
clusterTime = updateEvent = null;
- for (let id of[-10, 10]) {
+ for (let x = 0; x < 2; ++x) {
assert.soon(() => csCursor.hasNext());
updateEvent = csCursor.next();
- assert.eq(updateEvent.documentKey._id, id);
clusterTime = (clusterTime || updateEvent.clusterTime);
assert.gte(updateEvent.clusterTime, clusterTime);
assert.eq(updateEvent.updateDescription.updatedFields.updatedAgain, 1);
}
+ assert.soon(() => csCursor.hasNext());
st.stop();
})();