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

« back to all changes in this revision

Viewing changes to jstests/sharding/error1.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
 
 
2
s = new ShardingTest( "error1" , 2 , 1 , 1 );
 
3
s.adminCommand( { enablesharding : "test" } );
 
4
 
 
5
a = s._connections[0].getDB( "test" );
 
6
b = s._connections[1].getDB( "test" );
 
7
 
 
8
// ---- simple getLastError ----
 
9
 
 
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" );
 
16
 
 
17
// --- sharded getlasterror
 
18
 
 
19
s.adminCommand( { shardcollection : "test.foo2" , key : { num : 1 } } );
 
20
 
 
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 } );
 
25
 
 
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 } );
 
28
 
 
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" );
 
32
 
 
33
db.foo2.insert( { _id : 5 , num : 25 } );
 
34
assert( ! db.getLastError() , "se3.5" );
 
35
s.sync();
 
36
assert.eq( 5 , db.foo2.count() , "se4" );
 
37
 
 
38
 
 
39
 
 
40
db.foo2.insert( { _id : 5 , num : 30 } );
 
41
assert( db.getLastError() , "se5" );
 
42
assert( db.getLastError() , "se6" );
 
43
 
 
44
assert.eq( 5 , db.foo2.count() , "se5" );
 
45
 
 
46
// ----
 
47
s.stop();