summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2019-09-03 13:50:05 -0400
committerSuganthi Mani <suganthi.mani@mongodb.com>2019-09-03 13:50:05 -0400
commitd4ccbcfad2b7b47593054c3319f80b9ca922e066 (patch)
tree49fdb1ed2eeb42f133d21d2c690d5830ce87aae9
parent5a3ae3a4bc864d1a582d0da95d86fe7f3bfccd8d (diff)
downloadmongo-d4ccbcfad2b7b47593054c3319f80b9ca922e066.tar.gz
SERVER-38356 Fix copydb_illegal_collections.js to not create
local.oplog.rs collection.
-rw-r--r--jstests/noPassthrough/copydb_illegal_collections.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/jstests/noPassthrough/copydb_illegal_collections.js b/jstests/noPassthrough/copydb_illegal_collections.js
index 29c41d08ffc..0ed06988b6d 100644
--- a/jstests/noPassthrough/copydb_illegal_collections.js
+++ b/jstests/noPassthrough/copydb_illegal_collections.js
@@ -8,19 +8,19 @@
"use strict";
var rst = new ReplSetTest({nodes: 1});
- rst.startSet();
- rst.initiate();
+ // Start as stand-alone node so that local.oplog.rs collection won't be created. In order to
+ // make 'copydb' cmd to fail with 'ErrorCodes.InvalidNamespace`, it is necessary that local db
+ // should not contain oplog collection.
+ rst.start(0, {noReplSet: true});
- var conn = rst.getPrimary(); // Waits for PRIMARY state.
- conn = rst.restart(0, {noReplSet: true}); // Restart as a standalone node.
- assert.neq(null, conn, "failed to restart");
-
- // Must drop the oplog in order to induce the correct error below.
- conn.getDB("local").oplog.rs.drop();
+ var conn = rst.getPrimary(); // Waits for PRIMARY state.
var db1 = conn.getDB("local");
var db2 = conn.getDB("db2");
+ // Create system.replset collection manually.
+ assert.commandWorked(db1.runCommand({create: 'system.replset'}));
+
var res = db1.adminCommand({copydb: 1, fromdb: db1._name, todb: db2._name});
assert.commandFailedWithCode(res, ErrorCodes.InvalidNamespace);