summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2015-11-10 16:06:03 -0500
committerRandolph Tan <randolph@10gen.com>2015-11-17 17:50:47 -0500
commit9f055d483c3238a785c0f508f4011dc49a770504 (patch)
tree3652e4616bb0d467802ebbb52ec2ed0e89cdf7c9 /jstests
parent921659243d9b3691cbf6d82ebd8722cf9e912b1f (diff)
downloadmongo-9f055d483c3238a785c0f508f4011dc49a770504.tar.gz
SERVER-21233 Sharding config servers should not be pinging the distributed lock
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/replset_config/ssv_config_check.js28
-rw-r--r--jstests/sharding/reset_shard_version.js51
-rw-r--r--jstests/sharding/sync_cluster_config/ssv_init.js53
-rw-r--r--jstests/sharding/update_immutable_fields.js1
-rw-r--r--jstests/sharding/version1.js76
-rw-r--r--jstests/sharding/version2.js1
6 files changed, 123 insertions, 87 deletions
diff --git a/jstests/sharding/replset_config/ssv_config_check.js b/jstests/sharding/replset_config/ssv_config_check.js
index d9becd1aa8e..d1a1598b63f 100644
--- a/jstests/sharding/replset_config/ssv_config_check.js
+++ b/jstests/sharding/replset_config/ssv_config_check.js
@@ -40,5 +40,33 @@ assert.commandFailed(adminDB.runCommand({
shardHost: shardDoc.host
}));
+var configAdmin = st.c0.getDB('admin');
+// Initialize internal config string.
+assert.commandWorked(configAdmin.runCommand({
+ setShardVersion: '',
+ init: true,
+ authoritative: true,
+ configdb: configStr,
+ shard: 'config'
+}));
+
+// Passing configdb that does not match initialized value is not ok.
+assert.commandFailed(configAdmin.runCommand({
+ setShardVersion: '',
+ init: true,
+ authoritative: true,
+ configdb: 'bad-rs/local:12,local:34',
+ shard: 'config'
+}));
+
+// Passing configdb that matches initialized value is ok.
+assert.commandWorked(configAdmin.runCommand({
+ setShardVersion: '',
+ init: true,
+ authoritative: true,
+ configdb: alternateConfigStr,
+ shard: 'config'
+}));
+
st.stop();
})();
diff --git a/jstests/sharding/reset_shard_version.js b/jstests/sharding/reset_shard_version.js
deleted file mode 100644
index bb83cb50522..00000000000
--- a/jstests/sharding/reset_shard_version.js
+++ /dev/null
@@ -1,51 +0,0 @@
-// Tests whether a reset sharding version triggers errors
-
-jsTestLog( "Starting sharded cluster..." )
-
-var st = new ShardingTest( { shards : 1, mongos : 2 } )
-
-var mongosA = st.s0
-var mongosB = st.s1
-
-var collA = mongosA.getCollection( jsTestName() + ".coll" )
-collA.drop()
-var collB = mongosB.getCollection( "" + collA )
-
-st.shardColl( collA, { _id : 1 }, false )
-
-jsTestLog( "Inserting data..." )
-
-// Insert some data
-for ( var i = 0; i < 100; i++ ) {
- collA.insert( { _id : i } )
-}
-
-jsTestLog( "Setting connection versions on both mongoses..." )
-
-assert.eq( collA.find().itcount(), 100 )
-assert.eq( collB.find().itcount(), 100 )
-
-jsTestLog( "Resetting connection version on shard..." )
-
-var admin = st.shard0.getDB( "admin" )
-
-printjson( admin.runCommand( {
- setShardVersion : "" + collA, version : new Timestamp( 0, 0 ), configdb : st._configDB,
- authoritative : true } ) )
-
-jsTestLog( "Querying with version reset..." )
-
-// This will cause a version check
-assert.eq(0, collA.findOne({_id:0})['_id'])
-
-jsTestLog( "Resetting connection version on shard again..." )
-
-printjson( admin.runCommand( {
- setShardVersion : "" + collA, version : new Timestamp( 0, 0 ), configdb : st._configDB,
- authoritative : true } ) )
-
-jsTestLog( "Doing count command with version reset..." )
-
-assert.eq(100, collA.count()) // Test for SERVER-4196
-
-st.stop() \ No newline at end of file
diff --git a/jstests/sharding/sync_cluster_config/ssv_init.js b/jstests/sharding/sync_cluster_config/ssv_init.js
new file mode 100644
index 00000000000..d3c83fd5d2d
--- /dev/null
+++ b/jstests/sharding/sync_cluster_config/ssv_init.js
@@ -0,0 +1,53 @@
+(function() {
+"use strict";
+
+var st = new ShardingTest({ shards: 1, other: { sync: true }});
+
+var testDB = st.s.getDB('test');
+testDB.adminCommand({ enableSharding: 'test' });
+testDB.adminCommand({ shardCollection: 'test.user', key: { x: 1 }});
+
+// Initialize version on shard.
+testDB.user.insert({ x: 1 });
+
+var directConn = new Mongo(st.d0.host);
+var adminDB = directConn.getDB('admin');
+
+var configStr = adminDB.runCommand({ getShardVersion: 'test.user' }).configServer;
+var configStrArr = configStr.split(',');
+assert.eq(3, configStrArr.length);
+
+var badConfigStr = configStrArr[1] + ',' + configStrArr[2] + ',' + configStrArr[0];
+
+var configAdmin = st.c0.getDB('admin');
+
+// Initialize internal config string.
+assert.commandWorked(configAdmin.runCommand({
+ setShardVersion: '',
+ init: true,
+ authoritative: true,
+ configdb: configStr,
+ shard: 'config'
+}));
+
+// Passing configdb that does not match initialized value is not ok.
+assert.commandFailed(configAdmin.runCommand({
+ setShardVersion: '',
+ init: true,
+ authoritative: true,
+ configdb: badConfigStr,
+ shard: 'config'
+}));
+
+// Passing configdb that matches initialized value is ok.
+assert.commandWorked(configAdmin.runCommand({
+ setShardVersion: '',
+ init: true,
+ authoritative: true,
+ configdb: configStr,
+ shard: 'config'
+}));
+
+st.stop();
+
+})();
diff --git a/jstests/sharding/update_immutable_fields.js b/jstests/sharding/update_immutable_fields.js
index 0ba27bd2706..e90ecb7e037 100644
--- a/jstests/sharding/update_immutable_fields.js
+++ b/jstests/sharding/update_immutable_fields.js
@@ -26,6 +26,7 @@ var getDirectShardedConn = function( st, collName ) {
authoritative : true,
configdb : configConnStr,
version : maxChunk.lastmod,
+ shard: 'shard0000',
versionEpoch : maxChunk.lastmodEpoch };
printjson( ssvInitCmd );
diff --git a/jstests/sharding/version1.js b/jstests/sharding/version1.js
index d6f786e8ff3..c79d645b0fc 100644
--- a/jstests/sharding/version1.js
+++ b/jstests/sharding/version1.js
@@ -10,30 +10,34 @@ s.printShardingStatus();
a = s._connections[0].getDB( "admin" );
-assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).ok == 0 );
-
-assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : "a" } ).ok == 0 );
-
-assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , authoritative : true } ).ok == 0 );
-
-assert( a.runCommand({ setShardVersion: "alleyinsider.foo",
- configdb: s._configDB,
- version: new Timestamp(2, 0) }).ok == 0,
- "should have failed b/c no auth" );
-
-assert( a.runCommand({ setShardVersion: "alleyinsider.foo",
- configdb: s._configDB,
- version: new Timestamp(2, 0),
- authoritative: true }),
- "should have failed because first setShardVersion needs shard info" );
-
-assert( a.runCommand({ setShardVersion: "alleyinsider.foo",
- configdb: s._configDB,
- version: new Timestamp(2, 0),
- authoritative: true,
- shard: "shard0000",
- shardHost: s.s.host }),
- "should have failed because version is config is 1|0" );
+assert.commandFailed(a.runCommand({ setShardVersion: "alleyinsider.foo", configdb: s._configDB }));
+
+assert.commandFailed(a.runCommand({ setShardVersion: "alleyinsider.foo",
+ configdb: s._configDB,
+ version: "a" }));
+
+assert.commandFailed(a.runCommand({ setShardVersion: "alleyinsider.foo",
+ configdb: s._configDB,
+ authoritative: true }));
+
+assert.commandFailed(a.runCommand({ setShardVersion: "alleyinsider.foo",
+ configdb: s._configDB,
+ version: new Timestamp(2, 0)}),
+ "should have failed b/c no auth" );
+
+assert.commandFailed(a.runCommand({ setShardVersion: "alleyinsider.foo",
+ configdb: s._configDB,
+ version: new Timestamp(2, 0),
+ authoritative: true }),
+ "should have failed because first setShardVersion needs shard info");
+
+assert.commandFailed(a.runCommand({ setShardVersion: "alleyinsider.foo",
+ configdb: s._configDB,
+ version: new Timestamp(2, 0),
+ authoritative: true,
+ shard: "shard0000",
+ shardHost: s.s.host }),
+ "should have failed because version is config is 1|0");
var epoch = s.getDB('config').chunks.findOne().lastmodEpoch;
assert.commandWorked( a.runCommand({ setShardVersion: "alleyinsider.foo",
@@ -45,20 +49,20 @@ assert.commandWorked( a.runCommand({ setShardVersion: "alleyinsider.foo",
shardHost: s.s.host }),
"should have worked" );
-assert( a.runCommand({ setShardVersion: "alleyinsider.foo",
- configdb: "a",
- version: new Timestamp(0, 2),
- versionEpoch: epoch }).ok == 0, "A" );
+assert.commandFailed(a.runCommand({ setShardVersion: "alleyinsider.foo",
+ configdb: "a",
+ version: new Timestamp(0, 2),
+ versionEpoch: epoch }));
-assert( a.runCommand({ setShardVersion: "alleyinsider.foo",
- configdb: s._configDB,
- version: new Timestamp(0, 2),
- versionEpoch: epoch }).ok == 0, "B" );
+assert.commandFailed(a.runCommand({ setShardVersion: "alleyinsider.foo",
+ configdb: s._configDB,
+ version: new Timestamp(0, 2),
+ versionEpoch: epoch }));
-assert( a.runCommand({ setShardVersion: "alleyinsider.foo",
- configdb: s._configDB,
- version: new Timestamp(0, 1),
- versionEpoch: epoch }).ok == 0, "C" );
+assert.commandFailed(a.runCommand({ setShardVersion: "alleyinsider.foo",
+ configdb: s._configDB,
+ version: new Timestamp(0, 1),
+ versionEpoch: epoch }));
// the only way that setSharVersion passes is if the shard agrees with the version
// the shard takes its version from config directly
diff --git a/jstests/sharding/version2.js b/jstests/sharding/version2.js
index 06a0a27c9b4..441b190de73 100644
--- a/jstests/sharding/version2.js
+++ b/jstests/sharding/version2.js
@@ -46,6 +46,7 @@ assert.commandWorked( a2.runCommand({ setShardVersion: "alleyinsider.bar",
configdb: s._configDB,
version: new Timestamp(1, 0),
versionEpoch: barEpoch,
+ shard: 'shard0000',
authoritative: true }),
"setShardVersion bar temp" );