diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-09-05 11:23:54 -0400 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-09-13 14:44:09 -0400 |
commit | fe125855b6b3e8feb9d7d666338a7f2d29d301ad (patch) | |
tree | c682c408675b895bd343dd7187de8be18e875f66 /jstests/noPassthrough | |
parent | 61d1cfbf2c8521126506c12bcd2d187a7926fbe0 (diff) | |
download | mongo-fe125855b6b3e8feb9d7d666338a7f2d29d301ad.tar.gz |
SERVER-29142 Support $changeStream on unsharded collections.
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); }()); |