summaryrefslogtreecommitdiff
path: root/jstests/repl
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2010-03-08 18:17:32 -0800
committerAaron <aaron@10gen.com>2010-03-08 18:17:32 -0800
commitc85601f4e2581eef528b2e187b5c85cb1e0072e2 (patch)
treefe8e297c94b9022d45769af858fc0dad59ded210 /jstests/repl
parent6c7dc2b0f8831fac6621f125889d873241588b02 (diff)
downloadmongo-c85601f4e2581eef528b2e187b5c85cb1e0072e2.tar.gz
SERVER-705 forgot to add test
Diffstat (limited to 'jstests/repl')
-rw-r--r--jstests/repl/master1.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/jstests/repl/master1.js b/jstests/repl/master1.js
new file mode 100644
index 00000000000..9f021fc6a2a
--- /dev/null
+++ b/jstests/repl/master1.js
@@ -0,0 +1,49 @@
+// Test handling of clock skew and optimes across mongod instances
+
+var baseName = "jstests_repl_master1test";
+
+oplog = function() {
+ return m.getDB( "local" ).oplog.$main;
+}
+
+lastop = function() {
+ return oplog().find().sort( {$natural:-1} ).next();
+}
+
+am = function() {
+ return m.getDB( baseName ).a;
+}
+
+rt = new ReplTest( baseName );
+
+m = rt.start( true );
+
+am().save( {} );
+assert.eq( "i", lastop().op );
+
+op = lastop();
+printjson( op );
+op.ts.t = op.ts.t + 600000 // 10 minutes
+m.getDB( "local" ).runCommand( {godinsert:"oplog.$main", obj:op} );
+
+rt.stop( true );
+m = rt.start( true, null, true );
+
+assert.eq( op.ts.t, lastop().ts.t );
+am().save( {} );
+assert.eq( op.ts.t, lastop().ts.t );
+assert.eq( op.ts.i + 1, lastop().ts.i );
+
+op = lastop();
+printjson( op );
+op.ts.i = Math.pow(2,31);
+printjson( op );
+m.getDB( "local" ).runCommand( {godinsert:"oplog.$main", obj:op} );
+
+rt.stop( true );
+m = rt.start( true, null, true );
+assert.eq( op.ts.i, lastop().ts.i );
+am().save( {} );
+sleep( 3000 ); // make sure dies on its own before stop() called
+
+assert.eq( 47 /*EXIT_CLOCK_SKEW*/, rt.stop( true ) ); \ No newline at end of file