File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ // Test handling of clock skew and optimes across mongod instances
2+
3+ var baseName = "jstests_repl_master1test" ;
4+
5+ oplog = function ( ) {
6+ return m . getDB ( "local" ) . oplog . $main ;
7+ }
8+
9+ lastop = function ( ) {
10+ return oplog ( ) . find ( ) . sort ( { $natural :- 1 } ) . next ( ) ;
11+ }
12+
13+ am = function ( ) {
14+ return m . getDB ( baseName ) . a ;
15+ }
16+
17+ rt = new ReplTest ( baseName ) ;
18+
19+ m = rt . start ( true ) ;
20+
21+ am ( ) . save ( { } ) ;
22+ assert . eq ( "i" , lastop ( ) . op ) ;
23+
24+ op = lastop ( ) ;
25+ printjson ( op ) ;
26+ op . ts . t = op . ts . t + 600000 // 10 minutes
27+ m . getDB ( "local" ) . runCommand ( { godinsert :"oplog.$main" , obj :op } ) ;
28+
29+ rt . stop ( true ) ;
30+ m = rt . start ( true , null , true ) ;
31+
32+ assert . eq ( op . ts . t , lastop ( ) . ts . t ) ;
33+ am ( ) . save ( { } ) ;
34+ assert . eq ( op . ts . t , lastop ( ) . ts . t ) ;
35+ assert . eq ( op . ts . i + 1 , lastop ( ) . ts . i ) ;
36+
37+ op = lastop ( ) ;
38+ printjson ( op ) ;
39+ op . ts . i = Math . pow ( 2 , 31 ) ;
40+ printjson ( op ) ;
41+ m . getDB ( "local" ) . runCommand ( { godinsert :"oplog.$main" , obj :op } ) ;
42+
43+ rt . stop ( true ) ;
44+ m = rt . start ( true , null , true ) ;
45+ assert . eq ( op . ts . i , lastop ( ) . ts . i ) ;
46+ am ( ) . save ( { } ) ;
47+ sleep ( 3000 ) ; // make sure dies on its own before stop() called
48+
49+ assert . eq ( 47 /*EXIT_CLOCK_SKEW*/ , rt . stop ( true ) ) ;
You can’t perform that action at this time.
0 commit comments