summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/unsupported_change_stream_deployments.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/unsupported_change_stream_deployments.js')
-rw-r--r--jstests/noPassthrough/unsupported_change_stream_deployments.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/jstests/noPassthrough/unsupported_change_stream_deployments.js b/jstests/noPassthrough/unsupported_change_stream_deployments.js
new file mode 100644
index 00000000000..7473168df74
--- /dev/null
+++ b/jstests/noPassthrough/unsupported_change_stream_deployments.js
@@ -0,0 +1,36 @@
+// Tests that the $changeStream stage returns an error when run against a standalone mongod.
+(function() {
+ "use strict";
+ load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
+
+ function assertChangeStreamNotSupportedOnConnection(conn) {
+ const notReplicaSetErrorCode = 40573;
+ assertErrorCode(
+ conn.getDB("test").non_existent, [{$changeStream: {}}], notReplicaSetErrorCode);
+ assertErrorCode(conn.getDB("test").non_existent,
+ [{$changeStream: {fullDocument: "updateLookup"}}],
+ notReplicaSetErrorCode);
+ }
+
+ const conn = MongoRunner.runMongod();
+ assert.neq(null, conn, "mongod was unable to start up");
+ assertChangeStreamNotSupportedOnConnection(conn);
+ assert.eq(0, MongoRunner.stopMongod(conn));
+
+ // Test master/slave deployments.
+ const masterSlaveFixture = new ReplTest("change_stream");
+ const master = masterSlaveFixture.start(true);
+ assertChangeStreamNotSupportedOnConnection(master);
+ const slave = masterSlaveFixture.start(false);
+ assertChangeStreamNotSupportedOnConnection(slave);
+
+ // Test a sharded cluster with standalone shards.
+ const clusterWithStandalones = new ShardingTest({shards: 2});
+ // 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.shard0);
+ assertChangeStreamNotSupportedOnConnection(clusterWithStandalones.shard1);
+}());