diff options
Diffstat (limited to 'jstests/noPassthrough')
-rw-r--r-- | jstests/noPassthrough/sharded_change_stream.js | 23 | ||||
-rw-r--r-- | jstests/noPassthrough/unsupported_change_stream_deployments.js | 3 |
2 files changed, 24 insertions, 2 deletions
diff --git a/jstests/noPassthrough/sharded_change_stream.js b/jstests/noPassthrough/sharded_change_stream.js new file mode 100644 index 00000000000..efb2fc3de00 --- /dev/null +++ b/jstests/noPassthrough/sharded_change_stream.js @@ -0,0 +1,23 @@ +// Tests that the $changeStream returns an error when run against a sharded collection. +// TODO SERVER-29141 Add support for sending a $changeStream to a sharded collection. +(function() { + "use strict"; + + load("jstests/aggregation/extras/utils.js"); // For assertErrorCode(). + + const shardingTest = new ShardingTest({nodes: 1, rs: {nodes: 1}, config: 1}); + + const testDB = shardingTest.getDB("test"); + + // Test that $changeStream is disallowed on a sharded collection. + assert(shardingTest.adminCommand({enableSharding: "test"})); + assert(shardingTest.adminCommand({shardCollection: "test.sharded", key: {_id: 1}})); + const shardedCollection = testDB.getCollection("sharded"); + + assertErrorCode(shardedCollection, [{$changeStream: {}}], 40622); + + // Test that it is still disallowed even if it's not specified as the first stage. + assertErrorCode(shardedCollection, [{$project: {_id: 0}}, {$changeStream: {}}], 40622); + + shardingTest.stop(); +}()); diff --git a/jstests/noPassthrough/unsupported_change_stream_deployments.js b/jstests/noPassthrough/unsupported_change_stream_deployments.js index 7473168df74..23292a2f2f9 100644 --- a/jstests/noPassthrough/unsupported_change_stream_deployments.js +++ b/jstests/noPassthrough/unsupported_change_stream_deployments.js @@ -29,8 +29,7 @@ // Make sure the database exists before running any commands. const mongosDB = clusterWithStandalones.getDB("test"); assert.writeOK(mongosDB.unrelated.insert({})); - // TODO SERVER-29142 This error code will change to match the others. - assertErrorCode(mongosDB.non_existent, [{$changeStream: {}}], 40567); + assertChangeStreamNotSupportedOnConnection(clusterWithStandalones.s); assertChangeStreamNotSupportedOnConnection(clusterWithStandalones.shard0); assertChangeStreamNotSupportedOnConnection(clusterWithStandalones.shard1); }()); |