blob: dd871885c6c9cac6de42721ea8112ccd5817e7e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/**
* Test that mongoS rejects change streams which request 'fullDocumentBeforeChange' pre-images.
*
* @tags: [uses_change_streams, requires_replication]
*/
(function() {
'use strict';
load("jstests/libs/change_stream_util.js"); // For isChangeStreamPreAndPostImagesEnabled.
const st = new ShardingTest({
shards: 1,
mongos: 1,
config: 1,
});
const shard = st.shard0;
const mongos = st.s;
if (isChangeStreamPreAndPostImagesEnabled(mongos.getDB("test"))) {
jsTestLog(
"Skipping test as pre-image lookup is supported in sharded clusters with feature flag " +
"'featureFlagChangeStreamPreAndPostImages' enabled.");
st.stop();
return;
}
// Test that we cannot create a collection with pre-images enabled in a sharded cluster.
assert.commandFailed(shard.getDB("test").runCommand({create: "test", recordPreImages: true}));
// Test that attempting to run $changeStream with {fullDocumentBeforeChange: "whenAvailable"} fails.
assert.commandFailedWithCode(mongos.getDB("test").runCommand({
aggregate: 1,
pipeline: [{$changeStream: {fullDocumentBeforeChange: "whenAvailable"}}],
cursor: {}
}),
51771);
// Test that attempting to run $changeStream with {fullDocumentBeforeChange: "required"} fails.
assert.commandFailedWithCode(mongos.getDB("test").runCommand({
aggregate: 1,
pipeline: [{$changeStream: {fullDocumentBeforeChange: "required"}}],
cursor: {}
}),
51771);
st.stop();
}());
|