~ubuntu-branches/ubuntu/trusty/mongodb/trusty-proposed

« back to all changes in this revision

Viewing changes to jstests/sharding/splitpick.js

  • Committer: Bazaar Package Importer
  • Author(s): Antonin Kral
  • Date: 2010-01-29 19:48:45 UTC
  • Revision ID: james.westby@ubuntu.com-20100129194845-8wbmkf626fwcavc9
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// splitpick.js
 
2
 
 
3
/**
 
4
* tests picking the middle to split on
 
5
*/
 
6
 
 
7
s = new ShardingTest( "splitpick" , 2 );
 
8
 
 
9
db = s.getDB( "test" );
 
10
 
 
11
s.adminCommand( { enablesharding : "test" } );
 
12
s.adminCommand( { shardcollection : "test.foo" , key : { a : 1 } } );
 
13
 
 
14
c = db.foo;
 
15
 
 
16
for ( var i=1; i<20; i++ ){
 
17
    c.save( { a : i } );
 
18
}
 
19
c.save( { a : 99 } );
 
20
 
 
21
assert.eq( s.admin.runCommand( { splitvalue : "test.foo" , find : { a : 1 } } ).middle.a , 1 , "splitvalue 1" );
 
22
assert.eq( s.admin.runCommand( { splitvalue : "test.foo" , find : { a : 3 } } ).middle.a , 1 , "splitvalue 2" );
 
23
 
 
24
s.adminCommand( { split : "test.foo" , find : { a : 1 } } );
 
25
assert.eq( s.admin.runCommand( { splitvalue : "test.foo" , find : { a : 3 } } ).middle.a , 99 , "splitvalue 3" );
 
26
s.adminCommand( { split : "test.foo" , find : { a : 99 } } );
 
27
 
 
28
assert.eq( s.config.chunks.count() , 3 );
 
29
s.printChunks();
 
30
 
 
31
assert.eq( s.admin.runCommand( { splitvalue : "test.foo" , find : { a : 50 } } ).middle.a , 10 , "splitvalue 4 " );
 
32
 
 
33
s.stop();