summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2019-03-01 10:00:58 -0500
committerJames Wahlin <james@mongodb.com>2019-03-01 16:00:46 -0500
commitdbb0bbe1b7c0a735f56a470d78a3c22ef1e94ad8 (patch)
tree035b0914aa0c8c7d09f2ddd8ca9c8baa9e510b41
parentcc2361a62962a3abd17ac20136d25ee2df279b70 (diff)
downloadmongo-dbb0bbe1b7c0a735f56a470d78a3c22ef1e94ad8.tar.gz
SERVER-39900 change_streams_resume_at_same_clustertime.js should not assume same that multi-update across shards are performed at the same clusterTime
(cherry picked from commit 5456ba4c303e6febdc89384d7851688c85d016a9)
-rw-r--r--jstests/noPassthrough/change_streams_resume_at_same_clustertime.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/jstests/noPassthrough/change_streams_resume_at_same_clustertime.js b/jstests/noPassthrough/change_streams_resume_at_same_clustertime.js
index 627fdf4eb7a..e6eb5862aea 100644
--- a/jstests/noPassthrough/change_streams_resume_at_same_clustertime.js
+++ b/jstests/noPassthrough/change_streams_resume_at_same_clustertime.js
@@ -27,19 +27,24 @@
// Open a change stream cursor to listen for subsequent events.
let csCursor = mongosColl.watch([], {cursor: {batchSize: 1}});
- // Update both documents in the collection, such that the events will have the same clusterTime.
- // We update twice to ensure that the PBRT for both shards moves past the first two updates.
+ // Update both documents in the collection, such that the events are likely to have the same
+ // clusterTime. We update twice to ensure that the PBRT for both shards moves past the first two
+ // updates.
assert.commandWorked(mongosColl.update({}, {$set: {updated: 1}}, {multi: true}));
assert.commandWorked(mongosColl.update({}, {$set: {updatedAgain: 1}}, {multi: true}));
- // Retrieve the first two events, confirm that they are in order with the same clusterTime.
+ // Retrieve the first two events and confirm that they are in order with non-descending
+ // clusterTime. Unfortunately we cannot guarantee that clusterTime will be identical, since it
+ // is based on each shard's local value and there are operations beyond noop write that can
+ // 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]) {
assert.soon(() => csCursor.hasNext());
updateEvent = csCursor.next();
assert.eq(updateEvent.documentKey._id, id);
clusterTime = (clusterTime || updateEvent.clusterTime);
- assert.eq(updateEvent.clusterTime, clusterTime);
+ assert.gte(updateEvent.clusterTime, clusterTime);
assert.eq(updateEvent.updateDescription.updatedFields.updated, 1);
}
@@ -56,9 +61,9 @@
updateEvent = csCursor.next();
assert.eq(updateEvent.documentKey._id, id);
clusterTime = (clusterTime || updateEvent.clusterTime);
- assert.eq(updateEvent.clusterTime, clusterTime);
+ assert.gte(updateEvent.clusterTime, clusterTime);
assert.eq(updateEvent.updateDescription.updatedFields.updatedAgain, 1);
}
st.stop();
-})(); \ No newline at end of file
+})();