summaryrefslogtreecommitdiff
path: root/jstests/sharding
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding')
-rw-r--r--jstests/sharding/auth_copydb.js49
-rw-r--r--jstests/sharding/copydb_from_mongos.js22
-rw-r--r--jstests/sharding/database_and_shard_versioning_all_commands.js28
-rw-r--r--jstests/sharding/libs/last_stable_mongos_commands.js16
-rw-r--r--jstests/sharding/localhostAuthBypass.js3
-rw-r--r--jstests/sharding/printShardingStatus.js1
-rw-r--r--jstests/sharding/safe_secondary_reads_drop_recreate.js10
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js10
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js10
9 files changed, 45 insertions, 104 deletions
diff --git a/jstests/sharding/auth_copydb.js b/jstests/sharding/auth_copydb.js
deleted file mode 100644
index 1c732546b2b..00000000000
--- a/jstests/sharding/auth_copydb.js
+++ /dev/null
@@ -1,49 +0,0 @@
-// Tests the copydb command on mongos with auth
-(function() {
- 'use strict';
- load('jstests/libs/feature_compatibility_version.js');
-
- // TODO: Remove 'shardAsReplicaSet: false' when SERVER-32672 is fixed.
- var st = new ShardingTest(
- {shards: 1, mongos: 1, other: {keyFile: 'jstests/libs/key1', shardAsReplicaSet: false}});
- var mongos = st.s0;
- var destAdminDB = mongos.getDB('admin');
- var destTestDB = mongos.getDB('test');
-
- var sourceMongodConn = MongoRunner.runMongod({});
- var sourceTestDB = sourceMongodConn.getDB('test');
-
- // Ensure sourceMongodConn has featureCompatibilityVersion=lastStableFCV so that the sharded
- // cluster can communicate with it if it has featureCompatibilityVersion=lastStableFCV
- assert.commandWorked(
- sourceMongodConn.adminCommand({setFeatureCompatibilityVersion: lastStableFCV}));
-
- sourceTestDB.foo.insert({a: 1});
-
- destAdminDB.createUser({
- user: 'admin',
- pwd: 'password',
- roles: jsTest.adminUserRoles
- }); // Turns on access control enforcement
-
- jsTestLog("Running copydb that should fail");
- var res = destAdminDB.runCommand(
- {copydb: 1, fromhost: sourceMongodConn.host, fromdb: 'test', todb: 'test'});
- printjson(res);
- assert.commandFailed(res);
-
- destAdminDB.auth('admin', 'password');
- assert.eq(0, destTestDB.foo.count()); // Be extra sure the copydb didn't secretly succeed.
-
- jsTestLog("Running copydb that should succeed");
- res = destAdminDB.runCommand(
- {copydb: 1, fromhost: sourceMongodConn.host, fromdb: 'test', todb: 'test'});
- printjson(res);
- assert.commandWorked(res);
-
- assert.eq(1, destTestDB.foo.count());
- assert.eq(1, destTestDB.foo.findOne().a);
-
- st.stop();
- MongoRunner.stopMongod(sourceMongodConn);
-})();
diff --git a/jstests/sharding/copydb_from_mongos.js b/jstests/sharding/copydb_from_mongos.js
deleted file mode 100644
index 66db42407ca..00000000000
--- a/jstests/sharding/copydb_from_mongos.js
+++ /dev/null
@@ -1,22 +0,0 @@
-(function() {
-
- var st = new ShardingTest({shards: 1});
-
- var testDB = st.s.getDB('test');
- assert.writeOK(testDB.foo.insert({a: 1}));
-
- var res =
- testDB.adminCommand({copydb: 1, fromhost: st.s.host, fromdb: 'test', todb: 'test_copy'});
- assert.commandWorked(res);
-
- var copy = st.s.getDB('test_copy');
- assert.eq(1, copy.foo.count());
- assert.eq(1, copy.foo.findOne().a);
-
- // Test invalid todb database name.
- assert.commandFailed(testDB.adminCommand(
- {copydb: 1, fromhost: st.s.host, fromdb: 'test_copy', todb: 'test/copy'}));
-
- st.stop();
-
-})();
diff --git a/jstests/sharding/database_and_shard_versioning_all_commands.js b/jstests/sharding/database_and_shard_versioning_all_commands.js
index ec7a1c564fe..09b60667d4c 100644
--- a/jstests/sharding/database_and_shard_versioning_all_commands.js
+++ b/jstests/sharding/database_and_shard_versioning_all_commands.js
@@ -6,20 +6,13 @@
'use strict';
load('jstests/libs/profiler.js');
+ load('jstests/sharding/libs/last_stable_mongos_commands.js');
const dbName = "test";
const collName = "foo";
const ns = dbName + "." + collName;
const SHARD_VERSION_UNSHARDED = [Timestamp(0, 0), ObjectId("000000000000000000000000")];
- // These commands exist in the 4.0 mongo shell, so we must define a test case in mixed version
- // suites. However, a check exists in this test that asserts that every command tested exists
- // on mongos. In an all-4.2 environment, these commands won't exist. To increase test coverage,
- // and allow us to run on same- and mixed-version suites, we will allow these commands to have
- // a test defined without always existing on the mongos being used.
- const fcv40OnlyCommands =
- ['abortTransaction', 'commitTransaction', 'eval', 'geoNear', 'group', 'reIndex'];
-
function validateTestCase(testCase) {
assert(testCase.skip || testCase.command,
"must specify exactly one of 'skip' or 'command' for test case " + tojson(testCase));
@@ -115,7 +108,6 @@
assert(mongosConn.getDB(dbName).getCollection(collName).drop());
}
},
- copydb: {skip: "not allowed through mongos"},
count: {
sendsDbVersion: true,
sendsShardVersion: true,
@@ -207,7 +199,6 @@
echo: {skip: "does not forward command to primary shard"},
enableSharding: {skip: "does not forward command to primary shard"},
endSessions: {skip: "goes through the cluster write path"},
- eval: {skip: "must define test coverage for 4.0 backwards compatibility"},
explain: {skip: "TODO SERVER-31226"},
features: {skip: "executes locally on mongos (not sent to any remote node)"},
filemd5: {
@@ -227,7 +218,6 @@
},
flushRouterConfig: {skip: "executes locally on mongos (not sent to any remote node)"},
fsync: {skip: "broadcast to all shards"},
- geoNear: {skip: "must define test coverage for 4.0 backwards compatibility"},
getCmdLineOpts: {skip: "executes locally on mongos (not sent to any remote node)"},
getDiagnosticData: {skip: "executes locally on mongos (not sent to any remote node)"},
getLastError: {skip: "does not forward command to primary shard"},
@@ -241,7 +231,6 @@
grantPrivilegesToRole: {skip: "always targets the config server"},
grantRolesToRole: {skip: "always targets the config server"},
grantRolesToUser: {skip: "always targets the config server"},
- group: {skip: "must define test coverage for 4.0 backwards compatibility"},
hostInfo: {skip: "executes locally on mongos (not sent to any remote node)"},
insert: {
sendsDbVersion: false,
@@ -361,7 +350,6 @@
refreshLogicalSessionCacheNow: {skip: "goes through the cluster write path"},
refreshSessions: {skip: "executes locally on mongos (not sent to any remote node)"},
refreshSessionsInternal: {skip: "executes locally on mongos (not sent to any remote node)"},
- reIndex: {skip: "must define test coverage for 4.0 backwards compatibility"},
removeShard: {skip: "not on a user database"},
removeShardFromZone: {skip: "not on a user database"},
renameCollection: {
@@ -432,6 +420,10 @@
whatsmyuri: {skip: "executes locally on mongos (not sent to any remote node)"},
};
+ commandsRemovedFromMongosIn42.forEach(function(cmd) {
+ testCases[cmd] = {skip: "must define test coverage for 4.0 backwards compatibility"};
+ });
+
class AllCommandsTestRunner {
constructor() {
this.st = new ShardingTest(this.getShardingTestOptions());
@@ -548,7 +540,15 @@
// After iterating through all the existing commands, ensure there were no additional
// test cases that did not correspond to any mongos command.
for (let key of Object.keys(testCases)) {
- if (fcv40OnlyCommands.includes(key)) {
+ // We have defined real test cases for commands added in 4.2 so that the test cases
+ // are exercised in the regular suites, but because these test cases can't run in
+ // the last stable suite, we skip processing them here to avoid failing the below
+ // assertion. We have defined "skip" test cases for commands removed in 4.2 so the
+ // test case is defined in last stable suites (in which these commands still exist
+ // on the mongos), but these test cases won't be run in regular suites, so we skip
+ // processing them below as well.
+ if (commandsAddedToMongosIn42.includes(key) ||
+ commandsRemovedFromMongosIn42.includes(key)) {
continue;
}
assert(testCases[key].validated || testCases[key].conditional,
diff --git a/jstests/sharding/libs/last_stable_mongos_commands.js b/jstests/sharding/libs/last_stable_mongos_commands.js
new file mode 100644
index 00000000000..43a1da0acfa
--- /dev/null
+++ b/jstests/sharding/libs/last_stable_mongos_commands.js
@@ -0,0 +1,16 @@
+// These commands were removed from mongos 4.2, but will still appear in the listCommands output
+// of a 4.0 mongos. A last-stable mongos will be unable to run a command on a latest version shard
+// that no longer supports that command. To increase test coverage and allow us to run on same- and
+// mixed-version suites, we allow these commands to have a test defined without always existing on
+// the servers being used.
+const commandsRemovedFromMongosIn42 = [
+ 'copydb',
+ 'eval',
+ 'geoNear',
+ 'group',
+ 'reIndex',
+];
+// These commands were added in mongos 4.2, so will not appear in the listCommands output of a 4.0
+// mongos. We will allow these commands to have a test defined without always existing on the mongos
+// being used.
+const commandsAddedToMongosIn42 = ['abortTransaction', 'commitTransaction'];
diff --git a/jstests/sharding/localhostAuthBypass.js b/jstests/sharding/localhostAuthBypass.js
index d2035acdba2..996fb949175 100644
--- a/jstests/sharding/localhostAuthBypass.js
+++ b/jstests/sharding/localhostAuthBypass.js
@@ -95,9 +95,6 @@ TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
to: st.shard0.shardName // Arbitrary shard.
});
assert.commandFailedWithCode(res, authorizeErrorCode, "moveChunk");
- assert.commandFailedWithCode(mongo.getDB("test").copyDatabase("admin", "admin2"),
- authorizeErrorCode,
- "copyDatabase");
// Create collection
assert.commandFailedWithCode(
mongo.getDB("test").createCollection("log", {capped: true, size: 5242880, max: 5000}),
diff --git a/jstests/sharding/printShardingStatus.js b/jstests/sharding/printShardingStatus.js
index 15fc549050e..25009589e67 100644
--- a/jstests/sharding/printShardingStatus.js
+++ b/jstests/sharding/printShardingStatus.js
@@ -88,7 +88,6 @@
// Take a copy of the config db, in order to test the harder-to-setup cases below.
// Copy into a standalone to also test running printShardingStatus() against a config dump.
- // TODO: Replace this manual copy with copydb once SERVER-13080 is fixed.
var config = mongos.getDB("config");
var configCopy = standalone.getDB("configCopy");
config.getCollectionInfos().forEach(function(c) {
diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js
index 65eb2e0c03b..e26497dfddd 100644
--- a/jstests/sharding/safe_secondary_reads_drop_recreate.js
+++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js
@@ -20,6 +20,7 @@
"use strict";
load('jstests/libs/profiler.js');
+ load('jstests/sharding/libs/last_stable_mongos_commands.js');
let db = "test";
let coll = "foo";
@@ -105,7 +106,6 @@
connPoolSync: {skip: "does not return user data"},
connectionStatus: {skip: "does not return user data"},
convertToCapped: {skip: "primary only"},
- copydb: {skip: "primary only"},
copydbsaslstart: {skip: "primary only"},
count: {
setUp: function(mongosConn) {
@@ -152,7 +152,6 @@
emptycapped: {skip: "primary only"},
enableSharding: {skip: "primary only"},
endSessions: {skip: "does not return user data"},
- eval: {skip: "must define test coverage for 4.0 backwards compatibility"},
explain: {skip: "TODO SERVER-30068"},
features: {skip: "does not return user data"},
filemd5: {skip: "does not return user data"},
@@ -172,7 +171,6 @@
forceerror: {skip: "does not return user data"},
fsync: {skip: "does not return user data"},
fsyncUnlock: {skip: "does not return user data"},
- geoNear: {skip: "must define test coverage for 4.0 backwards compatibility"},
geoSearch: {skip: "not supported in mongos"},
getCmdLineOpts: {skip: "does not return user data"},
getDiagnosticData: {skip: "does not return user data"},
@@ -188,7 +186,6 @@
grantPrivilegesToRole: {skip: "primary only"},
grantRolesToRole: {skip: "primary only"},
grantRolesToUser: {skip: "primary only"},
- group: {skip: "must define test coverage for 4.0 backwards compatibility"},
handshake: {skip: "does not return user data"},
hostInfo: {skip: "does not return user data"},
insert: {skip: "primary only"},
@@ -244,7 +241,6 @@
planCacheListQueryShapes: {skip: "does not return user data"},
planCacheSetFilter: {skip: "does not return user data"},
profile: {skip: "primary only"},
- reIndex: {skip: "does not return user data"},
reapLogicalSessionCacheNow: {skip: "does not return user data"},
refreshLogicalSessionCacheNow: {skip: "does not return user data"},
refreshSessions: {skip: "does not return user data"},
@@ -307,6 +303,10 @@
whatsmyuri: {skip: "does not return user data"}
};
+ commandsRemovedFromMongosIn42.forEach(function(cmd) {
+ testCases[cmd] = {skip: "must define test coverage for 4.0 backwards compatibility"};
+ });
+
let scenarios = {
dropRecreateAsUnshardedOnSameShard: function(
staleMongos, freshMongos, test, commandProfile) {
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
index 67270de532a..6b682d1609d 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
@@ -25,6 +25,7 @@
"use strict";
load('jstests/libs/profiler.js');
+ load('jstests/sharding/libs/last_stable_mongos_commands.js');
let db = "test";
let coll = "foo";
@@ -118,7 +119,6 @@
connPoolSync: {skip: "does not return user data"},
connectionStatus: {skip: "does not return user data"},
convertToCapped: {skip: "primary only"},
- copydb: {skip: "primary only"},
copydbsaslstart: {skip: "primary only"},
count: {
setUp: function(mongosConn) {
@@ -176,7 +176,6 @@
emptycapped: {skip: "primary only"},
enableSharding: {skip: "primary only"},
endSessions: {skip: "does not return user data"},
- eval: {skip: "must define test coverage for 4.0 backwards compatibility"},
explain: {skip: "TODO SERVER-30068"},
features: {skip: "does not return user data"},
filemd5: {skip: "does not return user data"},
@@ -202,7 +201,6 @@
forceerror: {skip: "does not return user data"},
fsync: {skip: "does not return user data"},
fsyncUnlock: {skip: "does not return user data"},
- geoNear: {skip: "must define test coverage for 4.0 backwards compatibility"},
geoSearch: {skip: "not supported in mongos"},
getCmdLineOpts: {skip: "does not return user data"},
getDiagnosticData: {skip: "does not return user data"},
@@ -218,7 +216,6 @@
grantPrivilegesToRole: {skip: "primary only"},
grantRolesToRole: {skip: "primary only"},
grantRolesToUser: {skip: "primary only"},
- group: {skip: "must define test coverage for 4.0 backwards compatibility"},
handshake: {skip: "does not return user data"},
hostInfo: {skip: "does not return user data"},
insert: {skip: "primary only"},
@@ -279,7 +276,6 @@
planCacheListQueryShapes: {skip: "does not return user data"},
planCacheSetFilter: {skip: "does not return user data"},
profile: {skip: "primary only"},
- reIndex: {skip: "does not return user data"},
reapLogicalSessionCacheNow: {skip: "does not return user data"},
refreshLogicalSessionCacheNow: {skip: "does not return user data"},
refreshSessions: {skip: "does not return user data"},
@@ -342,6 +338,10 @@
whatsmyuri: {skip: "does not return user data"}
};
+ commandsRemovedFromMongosIn42.forEach(function(cmd) {
+ testCases[cmd] = {skip: "must define test coverage for 4.0 backwards compatibility"};
+ });
+
// Set the secondaries to priority 0 and votes 0 to prevent the primaries from stepping down.
let rsOpts = {nodes: [{rsConfig: {votes: 1}}, {rsConfig: {priority: 0, votes: 0}}]};
let st = new ShardingTest({mongos: 2, shards: {rs0: rsOpts, rs1: rsOpts}});
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
index 1f372a38fed..03822856590 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
@@ -20,6 +20,7 @@
"use strict";
load('jstests/libs/profiler.js');
+ load('jstests/sharding/libs/last_stable_mongos_commands.js');
let db = "test";
let coll = "foo";
@@ -106,7 +107,6 @@
connPoolSync: {skip: "does not return user data"},
connectionStatus: {skip: "does not return user data"},
convertToCapped: {skip: "primary only"},
- copydb: {skip: "primary only"},
copydbsaslstart: {skip: "primary only"},
count: {
setUp: function(mongosConn) {
@@ -154,7 +154,6 @@
emptycapped: {skip: "primary only"},
enableSharding: {skip: "primary only"},
endSessions: {skip: "does not return user data"},
- eval: {skip: "must define test coverage for 4.0 backwards compatibility"},
explain: {skip: "TODO SERVER-30068"},
features: {skip: "does not return user data"},
filemd5: {skip: "does not return user data"},
@@ -175,7 +174,6 @@
forceerror: {skip: "does not return user data"},
fsync: {skip: "does not return user data"},
fsyncUnlock: {skip: "does not return user data"},
- geoNear: {skip: "must define test coverage for 4.0 backwards compatibility"},
geoSearch: {skip: "not supported in mongos"},
getCmdLineOpts: {skip: "does not return user data"},
getDiagnosticData: {skip: "does not return user data"},
@@ -191,7 +189,6 @@
grantPrivilegesToRole: {skip: "primary only"},
grantRolesToRole: {skip: "primary only"},
grantRolesToUser: {skip: "primary only"},
- group: {skip: "must define test coverage for 4.0 backwards compatibility"},
handshake: {skip: "does not return user data"},
hostInfo: {skip: "does not return user data"},
insert: {skip: "primary only"},
@@ -253,7 +250,6 @@
refreshLogicalSessionCacheNow: {skip: "does not return user data"},
refreshSessions: {skip: "does not return user data"},
refreshSessionsInternal: {skip: "does not return user data"},
- reIndex: {skip: "does not return user data"},
removeShard: {skip: "primary only"},
removeShardFromZone: {skip: "primary only"},
renameCollection: {skip: "primary only"},
@@ -312,6 +308,10 @@
whatsmyuri: {skip: "does not return user data"}
};
+ commandsRemovedFromMongosIn42.forEach(function(cmd) {
+ testCases[cmd] = {skip: "must define test coverage for 4.0 backwards compatibility"};
+ });
+
// Set the secondaries to priority 0 and votes 0 to prevent the primaries from stepping down.
let rsOpts = {nodes: [{rsConfig: {votes: 1}}, {rsConfig: {priority: 0, votes: 0}}]};
let st = new ShardingTest({mongos: 2, shards: {rs0: rsOpts, rs1: rsOpts}});