diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-09-03 16:48:34 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-09-03 16:48:34 -0400 |
commit | 08489a2b4279b2433603942648b9e437e97f7cfc (patch) | |
tree | b6b4dbb283473b8fbea12007759a0b6a08b248c0 /jstests | |
parent | 66072780c042948026175ce1ba2d699f0fd9a75b (diff) | |
download | mongo-08489a2b4279b2433603942648b9e437e97f7cfc.tar.gz |
unique shard key support SHARDING-31
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/features1.js | 16 | ||||
-rw-r--r-- | jstests/sharding/shard1.js | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/jstests/sharding/features1.js b/jstests/sharding/features1.js index f76d978dc3c..01d1e991a9a 100644 --- a/jstests/sharding/features1.js +++ b/jstests/sharding/features1.js @@ -62,5 +62,21 @@ printjson( db.system.indexes.find( { ns : "test.foo3" } ).toArray() ); assert( ! s.admin.runCommand( { shardcollection : "test.foo3" , key : { num : 1 } } ).ok , "shard with unique index" ); +// ---- unique shard key ---- + +assert( s.admin.runCommand( { shardcollection : "test.foo4" , key : { num : 1 } , unique : true } ).ok , "shard with index and unique" ); +s.adminCommand( { split : "test.foo4" , middle : { num : 10 } } ); +s.adminCommand( { movechunk : "test.foo4" , find : { num : 20 } , to : s.getOther( s.getServer( "test" ) ).name } ); +db.foo4.save( { num : 5 } ); +db.foo4.save( { num : 15 } ); +s.sync(); +assert.eq( 1 , a.foo4.count() , "ua1" ); +assert.eq( 1 , b.foo4.count() , "ub1" ); + +assert.eq( 2 , a.foo4.getIndexes().length , "ua2" ); +assert.eq( 2 , b.foo4.getIndexes().length , "ub2" ); + +assert( a.foo4.getIndexes()[1].unique , "ua3" ); +assert( b.foo4.getIndexes()[1].unique , "ub3" ); s.stop() diff --git a/jstests/sharding/shard1.js b/jstests/sharding/shard1.js index faf0654a0a0..bbe1144bf07 100644 --- a/jstests/sharding/shard1.js +++ b/jstests/sharding/shard1.js @@ -19,7 +19,7 @@ assert.eq( 3 , db.foo.find().length() , "after partitioning count failed" ); s.adminCommand( shardCommand ); dbconfig = s.config.databases.findOne( { name : "test" } ); -assert.eq( dbconfig.sharded["test.foo"] , { num : 1 } , "Sharded content" ); +assert.eq( dbconfig.sharded["test.foo"] , { key : { num : 1 } , unique : false } , "Sharded content" ); assert.eq( 1 , s.config.chunks.count() ); si = s.config.chunks.findOne(); |