summaryrefslogtreecommitdiff
path: root/jstests/sharding/version2.js
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2010-01-31 08:32:52 +0100
committerAntonin Kral <a.kral@bobek.cz>2010-01-31 08:32:52 +0100
commit4eefaf421bfeddf040d96a3dafb12e09673423d7 (patch)
treecb2e5ccc7f98158894f977ff131949da36673591 /jstests/sharding/version2.js
downloadmongodb-4eefaf421bfeddf040d96a3dafb12e09673423d7.tar.gz
Imported Upstream version 1.3.1
Diffstat (limited to 'jstests/sharding/version2.js')
-rw-r--r--jstests/sharding/version2.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/jstests/sharding/version2.js b/jstests/sharding/version2.js
new file mode 100644
index 0000000..9683c92
--- /dev/null
+++ b/jstests/sharding/version2.js
@@ -0,0 +1,36 @@
+// version2.js
+
+s = new ShardingTest( "version2" , 1 , 2 )
+
+a = s._connections[0].getDB( "admin" );
+
+// setup from one client
+
+assert( a.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).mine.i == 0 );
+assert( a.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).global.i == 0 );
+
+assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 2 , authoritative : true } ).ok == 1 );
+
+assert( a.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).mine.i == 2 );
+assert( a.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).global.i == 2 );
+
+// from another client
+
+a2 = connect( s._connections[0].name + "/admin" );
+
+assert.eq( a2.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).global.i , 2 , "a2 global 1" );
+assert.eq( a2.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).mine.i , 0 , "a2 mine 1" );
+
+function simpleFindOne(){
+ return a2.getMongo().getDB( "alleyinsider" ).foo.findOne();
+}
+
+assert.commandWorked( a2.runCommand( { "setShardVersion" : "alleyinsider.bar" , configdb : s._configDB , version : 2 , authoritative : true } ) , "setShardVersion bar temp");
+assert.throws( simpleFindOne , [] , "should complain about not in sharded mode 1" );
+assert( a2.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 2 } ).ok == 1 , "setShardVersion a2-1");
+simpleFindOne(); // now should run ok
+assert( a2.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 3 } ).ok == 1 , "setShardVersion a2-2");
+simpleFindOne(); // newer version is ok
+
+
+s.stop();