summaryrefslogtreecommitdiff
path: root/jstests/change_streams
diff options
context:
space:
mode:
authorJustin Seyster <justin.seyster@mongodb.com>2019-06-13 12:47:52 -0400
committerJustin Seyster <justin.seyster@mongodb.com>2019-06-14 18:31:40 -0400
commitb3c26131f6ab3f919beca658341e737de5d45683 (patch)
tree60d6fed905f04a5fd2e40d5e4050490760d28c67 /jstests/change_streams
parenta368e90685fdaa5d855ecd54769f5ca0c09d4378 (diff)
downloadmongo-b3c26131f6ab3f919beca658341e737de5d45683.tar.gz
SERVER-41183 Add test suites for change streams with transactions
Diffstat (limited to 'jstests/change_streams')
-rw-r--r--jstests/change_streams/include_cluster_time.js5
-rw-r--r--jstests/change_streams/report_latest_observed_oplog_timestamp.js4
-rw-r--r--jstests/change_streams/required_as_first_stage.js5
-rw-r--r--jstests/change_streams/resume_from_high_water_mark_token.js16
-rw-r--r--jstests/change_streams/shell_helper.js5
5 files changed, 29 insertions, 6 deletions
diff --git a/jstests/change_streams/include_cluster_time.js b/jstests/change_streams/include_cluster_time.js
index 405bf2d5b16..d035a92f517 100644
--- a/jstests/change_streams/include_cluster_time.js
+++ b/jstests/change_streams/include_cluster_time.js
@@ -1,4 +1,9 @@
// Tests that each change in the stream will include the cluster time at which it happened.
+//
+// This test expects each change stream result to have an operationTime based on the clusterTime in
+// the oplog entry. When operations get bundled into a transaction, their operationTime is instead
+// based on the commit oplog entry, which would cause this test to fail.
+// @tags: [change_stream_does_not_expect_txns]
(function() {
"use strict";
diff --git a/jstests/change_streams/report_latest_observed_oplog_timestamp.js b/jstests/change_streams/report_latest_observed_oplog_timestamp.js
index 45abd52ada9..56754613b47 100644
--- a/jstests/change_streams/report_latest_observed_oplog_timestamp.js
+++ b/jstests/change_streams/report_latest_observed_oplog_timestamp.js
@@ -1,6 +1,10 @@
// Tests that an aggregate with a $changeStream stage will report the latest optime read in
// the oplog by its cursor. This is information is needed in order to correctly merge the results
// from the various shards on mongos.
+//
+// This test expects operations timestamps from a change stream to strictly increase with each
+// operation, which does not happen when the operations get grouped into a transaction.
+// @tags: [change_stream_does_not_expect_txns]
(function() {
"use strict";
diff --git a/jstests/change_streams/required_as_first_stage.js b/jstests/change_streams/required_as_first_stage.js
index 9eb15db9e9d..bdc0b43ba0c 100644
--- a/jstests/change_streams/required_as_first_stage.js
+++ b/jstests/change_streams/required_as_first_stage.js
@@ -1,4 +1,9 @@
// Tests that the $changeStream stage can only be present as the first stage in the pipeline.
+//
+// The passthrough logic that bundles operations into transactions needs to be able identify change
+// stream aggregations so as to avoid running them in a transaction, but that code would fail to
+// recognize the intentionally malformed aggergations that we test here.
+// @tags: [change_stream_does_not_expect_txns]
(function() {
"use strict";
diff --git a/jstests/change_streams/resume_from_high_water_mark_token.js b/jstests/change_streams/resume_from_high_water_mark_token.js
index bc63fdb33d9..973fc32d9c9 100644
--- a/jstests/change_streams/resume_from_high_water_mark_token.js
+++ b/jstests/change_streams/resume_from_high_water_mark_token.js
@@ -160,18 +160,22 @@
const otherCollection = assertCreateCollection(db, otherCollName);
const adminDB = db.getSiblingDB("admin");
- // Open a stream on the test collection. Write one document to the test collection and one to
- // the unrelated collection, in order to push the postBatchResumeToken (PBRT) past the last
- // related event.
+ // Open a stream on the test collection, and write a document to it.
csCursor = testCollection.watch();
assert.commandWorked(testCollection.insert({_id: docId++}));
- assert.commandWorked(otherCollection.insert({}));
- // Consume all events. The PBRT of the batch should be greater than the last event, which
- // guarantees that it is a synthetic high-water-mark token.
+ // Write an event to the unrelated collection in order to advance the PBRT, and then consume all
+ // events. When we see a PBRT that is greater than the timestamp of the last event (stored in
+ // 'relatedEvent'), we know it must be a synthetic high-water-mark token.
+ //
+ // Note that the first insert into the unrelated collection may not be enough to advance the
+ // PBRT; some passthroughs will group the unrelated write into a transaction with the related
+ // write, giving them the same timestamp. We put the unrelated insert into the assert.soon loop,
+ // so that it will eventually get its own transaction with a new timestamp.
let relatedEvent = null;
let hwmToken = null;
assert.soon(() => {
+ assert.commandWorked(otherCollection.insert({}));
if (csCursor.hasNext()) {
relatedEvent = csCursor.next();
}
diff --git a/jstests/change_streams/shell_helper.js b/jstests/change_streams/shell_helper.js
index f63eba06df7..a044ba76e50 100644
--- a/jstests/change_streams/shell_helper.js
+++ b/jstests/change_streams/shell_helper.js
@@ -1,6 +1,11 @@
// Test change streams related shell helpers and options passed to them. Note that, while we only
// call the DBCollection.watch helper in this file, it will be redirected to the DB.watch or
// Mongo.watch equivalents in the whole_db and whole_cluster passthroughs.
+//
+// This test expects each change stream result to have an operationTime based on the clusterTime in
+// the oplog entry. When operations get bundled into a transaction, their operationTime is instead
+// based on the commit oplog entry, which would cause this test to fail.
+// @tags: [change_stream_does_not_expect_txns]
(function() {
"use strict";