File: snapshot1.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (34 lines) | stat: -rw-r--r-- 1,360 bytes parent folder | download | duplicates (5)
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
// Test SERVER-623 - starting slave from a new snapshot

ports = allocatePorts( 3 );

var baseName = "repl_snapshot1";

rt1 = new ReplTest( "repl_snapshot1-1", [ ports[ 0 ], ports[ 1 ] ] );
rt2 = new ReplTest( "repl_snapshot1-2", [ ports[ 0 ], ports[ 2 ] ] );
m = rt1.start( true );

big = new Array( 2000 ).toString();
for( i = 0; i < 1000; ++i )
    m.getDB( baseName )[ baseName ].save( { _id: new ObjectId(), i: i, b: big } );

m.getDB( "admin" ).runCommand( {fsync:1,lock:1} );
copyDbpath( rt1.getPath( true ), rt1.getPath( false ) );
m.getDB( "admin" ).$cmd.sys.unlock.findOne();

s1 = rt1.start( false, null, true );
assert.eq( 1000, s1.getDB( baseName )[ baseName ].count() );
m.getDB( baseName )[ baseName ].save( {i:1000} );
assert.soon( function() { return 1001 == s1.getDB( baseName )[ baseName ].count(); } );

s1.getDB( "admin" ).runCommand( {fsync:1,lock:1} );
copyDbpath( rt1.getPath( false ), rt2.getPath( false ) );
s1.getDB( "admin" ).$cmd.sys.unlock.findOne();

s2 = rt2.start( false, null, true );
assert.eq( 1001, s2.getDB( baseName )[ baseName ].count() );
m.getDB( baseName )[ baseName ].save( {i:1001} );
assert.soon( function() { return 1002 == s2.getDB( baseName )[ baseName ].count(); } );
assert.soon( function() { return 1002 == s1.getDB( baseName )[ baseName ].count(); } );

assert( !rawMongoProgramOutput().match( /resync/ ) );