summaryrefslogtreecommitdiff
path: root/jstests/change_streams
diff options
context:
space:
mode:
authorDenis Grebennicov <denis.grebennicov@mongodb.com>2021-07-27 19:20:43 +0200
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-07-27 17:54:15 +0000
commit2d76701ca6266cf01bfc43e96c9a8ad912debb4f (patch)
treed28d3558b7b9dd57cc15a78cfc6c68262d4fa12b /jstests/change_streams
parent0c1e060e7e87a32673e9a6b0311663aa4875544b (diff)
downloadmongo-2d76701ca6266cf01bfc43e96c9a8ad912debb4f.tar.gz
SERVER-58423 Parse and validate change stream open parameter "fullDocument"
Diffstat (limited to 'jstests/change_streams')
-rw-r--r--jstests/change_streams/lookup_pit_post_image.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/change_streams/lookup_pit_post_image.js b/jstests/change_streams/lookup_pit_post_image.js
new file mode 100644
index 00000000000..5bb2bc9ec14
--- /dev/null
+++ b/jstests/change_streams/lookup_pit_post_image.js
@@ -0,0 +1,26 @@
+// Tests the behaviour of $changeStream's 'fullDocument' option when retrieving point-in-time
+// post-images.
+(function() {
+"use strict";
+
+load("jstests/libs/collection_drop_recreate.js"); // For assertDropAndRecreateCollection.
+load("jstests/libs/change_stream_util.js"); // For isChangeStreamPreAndPostImagesEnabled.
+
+const testDB = db.getSiblingDB(jsTestName());
+const coll = assertDropAndRecreateCollection(testDB, "test");
+
+if (!isChangeStreamPreAndPostImagesEnabled(db)) {
+ // If feature flag is off, creating changeStream with new fullDocument arguments should throw.
+ assert.throwsWithCode(() => coll.watch([], {fullDocument: 'whenAvailable'}),
+ ErrorCodes.BadValue);
+ assert.throwsWithCode(() => coll.watch([], {fullDocument: 'required'}), ErrorCodes.BadValue);
+
+ jsTestLog(
+ 'Skipping test because featureFlagChangeStreamsPreAndPostImages feature flag is not enabled');
+ return;
+}
+
+// Open the change streams with new fullDocument parameters.
+assert.doesNotThrow(() => coll.watch([], {fullDocument: 'whenAvailable'}));
+assert.doesNotThrow(() => coll.watch([], {fullDocument: 'required'}));
+}());