1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Test resync after failed initial clone
var baseName = "jstests_repl5test";
soonCountAtLeast = function( db, coll, count ) {
assert.soon( function() {
if ( -1 == s.getDBNames().indexOf( db ) )
return false;
if ( -1 == s.getDB( db ).getCollectionNames().indexOf( coll ) )
return false;
// print( "count: " + s.getDB( db )[ coll ].find().count() );
return s.getDB( db )[ coll ].find().count() >= count;
} );
}
doTest = function( signal ) {
ports = allocatePorts( 2 );
m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface" );
ma = m.getDB( "a" ).a;
for( i = 0; i < 10000; ++i )
ma.save( { i:i } );
s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface" );
soonCountAtLeast( "a", "a", 1 );
stopMongod( ports[ 1 ], signal );
s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface" );
sleep( 1000 );
ma.save( { i:-1 } );
ma.save( { i:-2 } );
soonCountAtLeast( "a", "a", 10002 );
ports.forEach( function( x ) { stopMongod( x ); } );
}
doTest( 15 ); // SIGTERM
doTest( 9 ); // SIGKILL
|