2
s = new ShardingTest( "error1" , 2 , 1 , 1 );
3
s.adminCommand( { enablesharding : "test" } );
5
a = s._connections[0].getDB( "test" );
6
b = s._connections[1].getDB( "test" );
8
// ---- simple getLastError ----
10
db = s.getDB( "test" );
11
db.foo.insert( { _id : 1 } );
12
assert.isnull( db.getLastError() , "gle 1" );
13
db.foo.insert( { _id : 1 } );
14
assert( db.getLastError() , "gle21" );
15
assert( db.getLastError() , "gle22" );
17
// --- sharded getlasterror
19
s.adminCommand( { shardcollection : "test.foo2" , key : { num : 1 } } );
21
db.foo2.insert( { _id : 1 , num : 5 } );
22
db.foo2.insert( { _id : 2 , num : 10 } );
23
db.foo2.insert( { _id : 3 , num : 15 } );
24
db.foo2.insert( { _id : 4 , num : 20 } );
26
s.adminCommand( { split : "test.foo2" , middle : { num : 10 } } );
27
s.adminCommand( { movechunk : "test.foo2" , find : { num : 20 } , to : s.getOther( s.getServer( "test" ) ).name } );
29
assert( a.foo2.count() > 0 && a.foo2.count() < 4 , "se1" );
30
assert( b.foo2.count() > 0 && b.foo2.count() < 4 , "se2" );
31
assert.eq( 4 , db.foo2.count() , "se3" );
33
db.foo2.insert( { _id : 5 , num : 25 } );
34
assert( ! db.getLastError() , "se3.5" );
36
assert.eq( 5 , db.foo2.count() , "se4" );
40
db.foo2.insert( { _id : 5 , num : 30 } );
41
assert( db.getLastError() , "se5" );
42
assert( db.getLastError() , "se6" );
44
assert.eq( 5 , db.foo2.count() , "se5" );