summaryrefslogtreecommitdiff
path: root/jstests/repl
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/repl')
-rw-r--r--jstests/repl/basic1.js204
-rw-r--r--jstests/repl/batch_write_command_wc_repl.js27
-rw-r--r--jstests/repl/block1.js22
-rw-r--r--jstests/repl/block2.js30
-rw-r--r--jstests/repl/master1.js50
-rw-r--r--jstests/repl/mod_move.js42
-rw-r--r--jstests/repl/repair.js14
-rw-r--r--jstests/repl/repl1.js96
-rw-r--r--jstests/repl/repl10.js52
-rw-r--r--jstests/repl/repl12.js46
-rw-r--r--jstests/repl/repl13.js64
-rw-r--r--jstests/repl/repl14.js87
-rw-r--r--jstests/repl/repl15.js67
-rw-r--r--jstests/repl/repl16.js72
-rw-r--r--jstests/repl/repl17.js49
-rw-r--r--jstests/repl/repl2.js59
-rw-r--r--jstests/repl/repl3.js31
-rw-r--r--jstests/repl/repl4.js58
-rw-r--r--jstests/repl/repl5.js38
-rw-r--r--jstests/repl/repl6.js114
-rw-r--r--jstests/repl/repl7.js65
-rw-r--r--jstests/repl/repl8.js65
-rw-r--r--jstests/repl/repl9.js71
-rw-r--r--jstests/repl/repl_sync_only_db_with_special_chars.js24
-rw-r--r--jstests/repl/snapshot1.js64
25 files changed, 782 insertions, 729 deletions
diff --git a/jstests/repl/basic1.js b/jstests/repl/basic1.js
index 7069b898a77..515667c48e4 100644
--- a/jstests/repl/basic1.js
+++ b/jstests/repl/basic1.js
@@ -2,163 +2,179 @@
// test repl basics
// data on master/slave is the same
-var rt = new ReplTest( "basic1" );
+var rt = new ReplTest("basic1");
-m = rt.start( true );
-s = rt.start( false );
+m = rt.start(true);
+s = rt.start(false);
-function block(){
- am.runCommand( { getlasterror : 1 , w : 2 , wtimeout : 3000 } );
+function block() {
+ am.runCommand({getlasterror: 1, w: 2, wtimeout: 3000});
}
-am = m.getDB( "foo" );
-as = s.getDB( "foo" );
+am = m.getDB("foo");
+as = s.getDB("foo");
-function check( note ){
+function check(note) {
var start = new Date();
- var x,y;
- while ( (new Date()).getTime() - start.getTime() < 30000 ){
- x = am.runCommand( "dbhash" );
- y = as.runCommand( "dbhash" );
- if ( x.md5 == y.md5 )
+ var x, y;
+ while ((new Date()).getTime() - start.getTime() < 30000) {
+ x = am.runCommand("dbhash");
+ y = as.runCommand("dbhash");
+ if (x.md5 == y.md5)
return;
- sleep( 200 );
+ sleep(200);
}
- lastOpLogEntry = m.getDB("local").oplog.$main.find({op:{$ne:"n"}}).sort({$natural:-1}).limit(-1).next();
- note = note + tojson(am.a.find().toArray()) + " != " + tojson(as.a.find().toArray())
- + "last oplog:" + tojson(lastOpLogEntry);
- assert.eq( x.md5 , y.md5 , note );
+ lastOpLogEntry =
+ m.getDB("local").oplog.$main.find({op: {$ne: "n"}}).sort({$natural: -1}).limit(-1).next();
+ note = note + tojson(am.a.find().toArray()) + " != " + tojson(as.a.find().toArray()) +
+ "last oplog:" + tojson(lastOpLogEntry);
+ assert.eq(x.md5, y.md5, note);
}
-am.a.save( { x : 1 } );
-check( "A" );
+am.a.save({x: 1});
+check("A");
-am.a.save( { x : 5 } );
+am.a.save({x: 5});
-am.a.update( {} , { $inc : { x : 1 } } );
-check( "B" );
+am.a.update({}, {$inc: {x: 1}});
+check("B");
-am.a.update( {} , { $inc : { x : 1 } } , false , true );
-check( "C" );
+am.a.update({}, {$inc: {x: 1}}, false, true);
+check("C");
// ----- check features -------
// map/reduce
-assert.writeOK(am.mr.insert({ tags: [ "a" ]}));
-assert.writeOK(am.mr.insert({ tags: [ "a", "b" ]}));
-check( "mr setup" );
-
-m = function(){
- for ( var i=0; i<this.tags.length; i++ ){
- print( "\t " + i );
- emit( this.tags[i] , 1 );
+assert.writeOK(am.mr.insert({tags: ["a"]}));
+assert.writeOK(am.mr.insert({tags: ["a", "b"]}));
+check("mr setup");
+
+m = function() {
+ for (var i = 0; i < this.tags.length; i++) {
+ print("\t " + i);
+ emit(this.tags[i], 1);
}
};
-r = function( key , v ){
- return Array.sum( v );
+r = function(key, v) {
+ return Array.sum(v);
};
-correct = { a : 2 , b : 1 };
+correct = {
+ a: 2,
+ b: 1
+};
-function checkMR( t ){
- var res = t.mapReduce( m , r , { out : { inline : 1 } } );
- assert.eq( correct , res.convertToSingleObject() , "checkMR: " + tojson( t ) );
+function checkMR(t) {
+ var res = t.mapReduce(m, r, {out: {inline: 1}});
+ assert.eq(correct, res.convertToSingleObject(), "checkMR: " + tojson(t));
}
-function checkNumCollections( msg , diff ){
- if ( ! diff ) diff = 0;
+function checkNumCollections(msg, diff) {
+ if (!diff)
+ diff = 0;
var m = am.getCollectionNames();
var s = as.getCollectionNames();
- assert.eq( m.length + diff , s.length , msg + " lengths bad \n" + tojson( m ) + "\n" + tojson( s ) );
+ assert.eq(m.length + diff, s.length, msg + " lengths bad \n" + tojson(m) + "\n" + tojson(s));
}
-checkNumCollections( "MR1" );
-checkMR( am.mr );
-checkMR( as.mr );
-checkNumCollections( "MR2" );
+checkNumCollections("MR1");
+checkMR(am.mr);
+checkMR(as.mr);
+checkNumCollections("MR2");
block();
-checkNumCollections( "MR3" );
+checkNumCollections("MR3");
-var res = am.mr.mapReduce( m , r , { out : "xyz" } );
+var res = am.mr.mapReduce(m, r, {out: "xyz"});
block();
-checkNumCollections( "MR4" );
+checkNumCollections("MR4");
var t = am.rpos;
-var writeOption = { writeConcern: { w: 2, wtimeout: 3000 }};
-t.insert({ _id: 1, a: [{ n: "a", c: 1 }, { n: "b", c: 1 }, { n: "c", c: 1 }], b: [ 1, 2, 3 ]},
- writeOption);
-check( "after pos 1 " );
-
-t.update({ "a.n": "b" }, { $inc: { "a.$.c": 1 }}, writeOption);
-check( "after pos 2 " );
+var writeOption = {
+ writeConcern: {w: 2, wtimeout: 3000}
+};
+t.insert({_id: 1, a: [{n: "a", c: 1}, {n: "b", c: 1}, {n: "c", c: 1}], b: [1, 2, 3]}, writeOption);
+check("after pos 1 ");
-t.update({ b: 2 }, { $inc: { "b.$": 1 }}, writeOption);
-check( "after pos 3 " );
+t.update({"a.n": "b"}, {$inc: {"a.$.c": 1}}, writeOption);
+check("after pos 2 ");
-t.update({ b: 3 }, { $set: { "b.$": 17 }}, writeOption);
-check( "after pos 4 " );
+t.update({b: 2}, {$inc: {"b.$": 1}}, writeOption);
+check("after pos 3 ");
+t.update({b: 3}, {$set: {"b.$": 17}}, writeOption);
+check("after pos 4 ");
-printjson( am.rpos.findOne() );
-printjson( as.rpos.findOne() );
+printjson(am.rpos.findOne());
+printjson(as.rpos.findOne());
-//am.getSisterDB( "local" ).getCollection( "oplog.$main" ).find().limit(10).sort( { $natural : -1 } ).forEach( printjson )
+// am.getSisterDB( "local" ).getCollection( "oplog.$main" ).find().limit(10).sort( { $natural : -1 }
+// ).forEach( printjson )
t = am.b;
-var updateOption = { upsert: true, multi: false, writeConcern: { w: 2, wtimeout: 3000 }};
-t.update({ _id: "fun" }, { $inc: { "a.b.c.x": 6743 }}, updateOption);
-check( "b 1" );
+var updateOption = {
+ upsert: true,
+ multi: false,
+ writeConcern: {w: 2, wtimeout: 3000}
+};
+t.update({_id: "fun"}, {$inc: {"a.b.c.x": 6743}}, updateOption);
+check("b 1");
-t.update({ _id: "fun" }, { $inc: { "a.b.c.x": 5 }}, updateOption);
-check( "b 2" );
+t.update({_id: "fun"}, {$inc: {"a.b.c.x": 5}}, updateOption);
+check("b 2");
-t.update({ _id: "fun" }, { $inc: { "a.b.c.x": 100, "a.b.c.y": 911 }}, updateOption);
-assert.eq( { _id : "fun" , a : { b : { c : { x : 6848 , y : 911 } } } } , as.b.findOne() , "b 3" );
-check( "b 4" );
+t.update({_id: "fun"}, {$inc: {"a.b.c.x": 100, "a.b.c.y": 911}}, updateOption);
+assert.eq({_id: "fun", a: {b: {c: {x: 6848, y: 911}}}}, as.b.findOne(), "b 3");
+check("b 4");
// lots of indexes
-am.lotOfIndexes.insert( { x : 1 } );
-for ( i=0; i<200; i++ ){
+am.lotOfIndexes.insert({x: 1});
+for (i = 0; i < 200; i++) {
var idx = {};
- idx["x"+i] = 1;
- am.lotOfIndexes.ensureIndex( idx );
+ idx["x" + i] = 1;
+ am.lotOfIndexes.ensureIndex(idx);
}
-assert.soon( function(){ return am.lotOfIndexes.getIndexes().length == as.lotOfIndexes.getIndexes().length; } , "lots of indexes a" );
+assert.soon(function() {
+ return am.lotOfIndexes.getIndexes().length == as.lotOfIndexes.getIndexes().length;
+}, "lots of indexes a");
-assert.eq( am.lotOfIndexes.getIndexes().length , as.lotOfIndexes.getIndexes().length , "lots of indexes b" );
+assert.eq(am.lotOfIndexes.getIndexes().length,
+ as.lotOfIndexes.getIndexes().length,
+ "lots of indexes b");
// multi-update with $inc
-am.mu1.update( { _id : 1 , $atomic : 1 } , { $inc : { x : 1 } } , true , true );
-x = { _id : 1 , x : 1 };
-assert.eq( x , am.mu1.findOne() , "mu1" );
-assert.soon( function(){ z = as.mu1.findOne(); printjson( z ); return friendlyEqual( x , z ); } , "mu2" );
+am.mu1.update({_id: 1, $atomic: 1}, {$inc: {x: 1}}, true, true);
+x = {
+ _id: 1,
+ x: 1
+};
+assert.eq(x, am.mu1.findOne(), "mu1");
+assert.soon(function() {
+ z = as.mu1.findOne();
+ printjson(z);
+ return friendlyEqual(x, z);
+}, "mu2");
// profiling - this should be last
-am.setProfilingLevel( 2 );
-am.foo.insert({ x: 1 }, writeOption);
+am.setProfilingLevel(2);
+am.foo.insert({x: 1}, writeOption);
am.foo.findOne();
-assert.eq( 2 , am.system.profile.count() , "P1" );
-assert.eq( 0 , as.system.profile.count() , "P2" );
+assert.eq(2, am.system.profile.count(), "P1");
+assert.eq(0, as.system.profile.count(), "P2");
-assert.eq( 1 , as.foo.findOne().x , "P3" );
-assert.eq( 0 , as.system.profile.count() , "P4" );
+assert.eq(1, as.foo.findOne().x, "P3");
+assert.eq(0, as.system.profile.count(), "P4");
-assert( as.getCollectionNames().indexOf( "system.profile" ) < 0 , "P4.5" );
+assert(as.getCollectionNames().indexOf("system.profile") < 0, "P4.5");
as.setProfilingLevel(2);
as.foo.findOne();
-assert.eq( 1 , as.system.profile.count() , "P5" );
-
+assert.eq(1, as.system.profile.count(), "P5");
rt.stop();
-
-
-
-
diff --git a/jstests/repl/batch_write_command_wc_repl.js b/jstests/repl/batch_write_command_wc_repl.js
index 41de494ab0c..3e28b330bf1 100644
--- a/jstests/repl/batch_write_command_wc_repl.js
+++ b/jstests/repl/batch_write_command_wc_repl.js
@@ -12,15 +12,14 @@ jsTest.log("Starting legacy repl tests...");
// Start a master node
// Allows testing legacy repl failures
-var mongod = MongoRunner.runMongod({ master : "", oplogSize : 40, smallfiles : "" });
+var mongod = MongoRunner.runMongod({master: "", oplogSize: 40, smallfiles: ""});
var coll = mongod.getCollection("test.batch_write_command_wc_repl");
//
// Basic insert, default WC
coll.remove({});
-printjson( request = {insert : coll.getName(),
- documents: [{a:1}]});
-printjson( result = coll.runCommand(request) );
+printjson(request = {insert: coll.getName(), documents: [{a: 1}]});
+printjson(result = coll.runCommand(request));
assert(result.ok);
assert.eq(1, result.n);
assert.eq(1, coll.count());
@@ -28,10 +27,8 @@ assert.eq(1, coll.count());
//
// Basic insert, majority WC
coll.remove({});
-printjson( request = {insert : coll.getName(),
- documents: [{a:1}],
- writeConcern: {w: 'majority'}});
-printjson( result = coll.runCommand(request) );
+printjson(request = {insert: coll.getName(), documents: [{a: 1}], writeConcern: {w: 'majority'}});
+printjson(result = coll.runCommand(request));
assert(result.ok);
assert.eq(1, result.n);
assert.eq(1, coll.count());
@@ -39,20 +36,17 @@ assert.eq(1, coll.count());
//
// Basic insert, immediate bad wMode error
coll.remove({});
-printjson( request = {insert : coll.getName(),
- documents: [{a:1}],
- writeConcern: {w: 'invalid'}});
-printjson( result = coll.runCommand(request) );
+printjson(request = {insert: coll.getName(), documents: [{a: 1}], writeConcern: {w: 'invalid'}});
+printjson(result = coll.runCommand(request));
assert(!result.ok);
assert.eq(0, coll.count());
//
// Basic insert, error on WC with wtimeout
coll.remove({});
-printjson( request = {insert : coll.getName(),
- documents: [{a:1}],
- writeConcern: {w:2, wtimeout: 1}});
-printjson( result = coll.runCommand(request) );
+printjson(
+ request = {insert: coll.getName(), documents: [{a: 1}], writeConcern: {w: 2, wtimeout: 1}});
+printjson(result = coll.runCommand(request));
assert(result.ok);
assert.eq(1, result.n);
assert(result.writeConcernError);
@@ -61,4 +55,3 @@ assert.eq(1, coll.count());
jsTest.log("DONE legacy repl tests");
MongoRunner.stopMongod(mongod);
-
diff --git a/jstests/repl/block1.js b/jstests/repl/block1.js
index ef36c3efb34..ab427270340 100644
--- a/jstests/repl/block1.js
+++ b/jstests/repl/block1.js
@@ -1,23 +1,19 @@
-var rt = new ReplTest( "block1" );
+var rt = new ReplTest("block1");
-m = rt.start( true );
-s = rt.start( false );
+m = rt.start(true);
+s = rt.start(false);
-dbm = m.getDB( "foo" );
-dbs = s.getDB( "foo" );
+dbm = m.getDB("foo");
+dbs = s.getDB("foo");
tm = dbm.bar;
ts = dbs.bar;
-for ( var i=0; i<1000; i++ ){
- tm.insert({ _id: i }, { writeConcern: { w: 2 }});
- assert.eq( i + 1 , ts.count() , "A" + i );
- assert.eq( i + 1 , tm.count() , "B" + i );
+for (var i = 0; i < 1000; i++) {
+ tm.insert({_id: i}, {writeConcern: {w: 2}});
+ assert.eq(i + 1, ts.count(), "A" + i);
+ assert.eq(i + 1, tm.count(), "B" + i);
}
rt.stop();
-
-
-
-
diff --git a/jstests/repl/block2.js b/jstests/repl/block2.js
index fc35b2774c4..0eb19771228 100644
--- a/jstests/repl/block2.js
+++ b/jstests/repl/block2.js
@@ -1,31 +1,29 @@
-var rt = new ReplTest( "block1" );
+var rt = new ReplTest("block1");
-m = rt.start( true );
-s = rt.start( false );
+m = rt.start(true);
+s = rt.start(false);
-function setup(){
-
- dbm = m.getDB( "foo" );
- dbs = s.getDB( "foo" );
+function setup() {
+ dbm = m.getDB("foo");
+ dbs = s.getDB("foo");
tm = dbm.bar;
ts = dbs.bar;
}
setup();
-function check( msg ){
- assert.eq( tm.count() , ts.count() , "check: " + msg );
+function check(msg) {
+ assert.eq(tm.count(), ts.count(), "check: " + msg);
}
-check( "A" );
+check("A");
-assert.writeOK(tm.insert({ x: 1 }, { writeConcern: { w: 2 }}));
-assert.writeOK(tm.insert({ x: 2 }, { writeConcern: { w: 2, wtimeout: 3000 }}));
+assert.writeOK(tm.insert({x: 1}, {writeConcern: {w: 2}}));
+assert.writeOK(tm.insert({x: 2}, {writeConcern: {w: 2, wtimeout: 3000}}));
-rt.stop( false );
-assert.writeError(tm.insert({ x: 3 }, { writeConcern: { w: 2, wtimeout: 3000 }}));
-assert.eq( 3 , tm.count() , "D1" );
+rt.stop(false);
+assert.writeError(tm.insert({x: 3}, {writeConcern: {w: 2, wtimeout: 3000}}));
+assert.eq(3, tm.count(), "D1");
rt.stop();
-
diff --git a/jstests/repl/master1.js b/jstests/repl/master1.js
index 1da0f29b9d4..85f116fb242 100644
--- a/jstests/repl/master1.js
+++ b/jstests/repl/master1.js
@@ -9,49 +9,49 @@
var baseName = "jstests_repl_master1test";
oplog = function() {
- return m.getDB( "local" ).oplog.$main;
+ return m.getDB("local").oplog.$main;
};
lastop = function() {
- return oplog().find().sort( {$natural:-1} ).next();
+ return oplog().find().sort({$natural: -1}).next();
};
am = function() {
- return m.getDB( baseName ).a;
+ return m.getDB(baseName).a;
};
-rt = new ReplTest( baseName );
+rt = new ReplTest(baseName);
-m = rt.start( true );
+m = rt.start(true);
-am().save( {} );
-assert.eq( "i", lastop().op );
+am().save({});
+assert.eq("i", lastop().op);
op = lastop();
-printjson( op );
-op.ts.t = op.ts.t + 600000; // 10 minutes
-assert.commandWorked(m.getDB( "local" ).runCommand( {godinsert:"oplog.$main", obj:op} ));
+printjson(op);
+op.ts.t = op.ts.t + 600000; // 10 minutes
+assert.commandWorked(m.getDB("local").runCommand({godinsert: "oplog.$main", obj: op}));
-rt.stop( true );
-m = rt.start( true, null, true );
+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 );
+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)-1;
-printjson( op );
-assert.commandWorked(m.getDB( "local" ).runCommand( {godinsert:"oplog.$main", obj:op} ));
+printjson(op);
+op.ts.i = Math.pow(2, 31) - 1;
+printjson(op);
+assert.commandWorked(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 );
+rt.stop(true);
+m = rt.start(true, null, true);
+assert.eq(op.ts.i, lastop().ts.i);
assert.throws(function() {
- am().save( {} ); // triggers fassert because ofclock skew
+ am().save({}); // triggers fassert because ofclock skew
});
-assert.neq(0, rt.stop( true )); // fasserted
+assert.neq(0, rt.stop(true)); // fasserted
diff --git a/jstests/repl/mod_move.js b/jstests/repl/mod_move.js
index 6b5d7d8a5aa..2ec8996dce3 100644
--- a/jstests/repl/mod_move.js
+++ b/jstests/repl/mod_move.js
@@ -2,23 +2,23 @@
// test repl basics
// data on master/slave is the same
-var rt = new ReplTest( "mod_move" );
+var rt = new ReplTest("mod_move");
-m = rt.start( true , { oplogSize : 50 } );
+m = rt.start(true, {oplogSize: 50});
-am = m.getDB( "foo" );
+am = m.getDB("foo");
-function check( note ){
+function check(note) {
var start = new Date();
- var x,y;
- while ( (new Date()).getTime() - start.getTime() < 5 * 60 * 1000 ){
- x = am.runCommand( "dbhash" );
- y = as.runCommand( "dbhash" );
- if ( x.md5 == y.md5 )
+ var x, y;
+ while ((new Date()).getTime() - start.getTime() < 5 * 60 * 1000) {
+ x = am.runCommand("dbhash");
+ y = as.runCommand("dbhash");
+ if (x.md5 == y.md5)
return;
- sleep( 200 );
+ sleep(200);
}
- assert.eq( x.md5 , y.md5 , note );
+ assert.eq(x.md5, y.md5, note);
}
// insert a lot of 'big' docs
@@ -29,30 +29,30 @@ N = BIG * 2;
var bulk = am.a.initializeUnorderedBulkOp();
for (var i = 0; i < BIG; i++) {
- bulk.insert({ _id: i, s: 1, x: 1 });
+ bulk.insert({_id: i, s: 1, x: 1});
}
for (; i < N; i++) {
- bulk.insert({ _id: i, s: 1 });
+ bulk.insert({_id: i, s: 1});
}
for (i = 0; i < BIG; i++) {
- bulk.find({ _id: i }).remove();
+ bulk.find({_id: i}).remove();
}
assert.writeOK(bulk.execute());
-assert.eq( BIG , am.a.count() );
+assert.eq(BIG, am.a.count());
-if ( am.serverStatus().storageEngine.name == "mmapv1" ) {
- assert.eq( 1 , am.a.stats().paddingFactor , "A2" );
+if (am.serverStatus().storageEngine.name == "mmapv1") {
+ assert.eq(1, am.a.stats().paddingFactor, "A2");
}
// start slave
-s = rt.start( false );
-as = s.getDB( "foo" );
+s = rt.start(false);
+as = s.getDB("foo");
bulk = am.a.initializeUnorderedBulkOp();
for (i = N - 1; i >= BIG; i--) {
- bulk.find({ _id: i }).update({ $set: { x: 1 }});
+ bulk.find({_id: i}).update({$set: {x: 1}});
}
assert.writeOK(bulk.execute());
-check( "B" );
+check("B");
rt.stop();
diff --git a/jstests/repl/repair.js b/jstests/repl/repair.js
index 9bdaef35962..b654244eb2b 100644
--- a/jstests/repl/repair.js
+++ b/jstests/repl/repair.js
@@ -2,13 +2,13 @@
var baseName = "jstests_repl_repair";
-rt = new ReplTest( baseName );
+rt = new ReplTest(baseName);
-m = rt.start( true );
+m = rt.start(true);
-m.getDB( baseName )[ baseName ].save( {} );
-var c = m.getDB( 'local' ).oplog.$main.count();
-assert.automsg( "c > 0" );
+m.getDB(baseName)[baseName].save({});
+var c = m.getDB('local').oplog.$main.count();
+assert.automsg("c > 0");
-assert.commandWorked( m.getDB( "local" ).repairDatabase() );
-assert.automsg( "c <= m.getDB( 'local' ).oplog.$main.count()" );
+assert.commandWorked(m.getDB("local").repairDatabase());
+assert.automsg("c <= m.getDB( 'local' ).oplog.$main.count()");
diff --git a/jstests/repl/repl1.js b/jstests/repl/repl1.js
index 1bdfaa00bdd..ea8f85a6260 100644
--- a/jstests/repl/repl1.js
+++ b/jstests/repl/repl1.js
@@ -8,55 +8,57 @@
var baseName = "jstests_repl1test";
-soonCount = function( count ) {
- assert.soon( function() {
-// print( "check count" );
-// print( "count: " + s.getDB( baseName ).z.find().count() );
- return s.getDB( baseName ).a.find().count() == count;
- } );
+soonCount = function(count) {
+ assert.soon(function() {
+ // print( "check count" );
+ // print( "count: " + s.getDB( baseName ).z.find().count() );
+ return s.getDB(baseName).a.find().count() == count;
+ });
};
-doTest = function( signal ) {
-
- rt = new ReplTest( "repl1tests" );
-
- m = rt.start( true );
- s = rt.start( false );
-
- am = m.getDB( baseName ).a;
-
- for( i = 0; i < 1000; ++i )
- am.save( { _id: new ObjectId(), i: i } );
-
- soonCount( 1000 );
- as = s.getDB( baseName ).a;
- assert.eq( 1, as.find( { i: 0 } ).count() );
- assert.eq( 1, as.find( { i: 999 } ).count() );
-
- rt.stop( false, signal );
-
- for( i = 1000; i < 1010; ++i )
- am.save( { _id: new ObjectId(), i: i } );
-
- s = rt.start( false, null, true );
- soonCount( 1010 );
- as = s.getDB( baseName ).a;
- assert.eq( 1, as.find( { i: 1009 } ).count() );
-
- rt.stop( true, signal );
-
- m = rt.start( true, null, true );
- am = m.getDB( baseName ).a;
-
- for( i = 1010; i < 1020; ++i )
- am.save( { _id: new ObjectId(), i: i } );
-
- assert.soon( function() { return as.find().count() == 1020; } );
- assert.eq( 1, as.find( { i: 1019 } ).count() );
-
- assert.automsg( "m.getDB( 'local' ).getCollection( 'oplog.$main' ).stats().size > 0" );
-
+doTest = function(signal) {
+
+ rt = new ReplTest("repl1tests");
+
+ m = rt.start(true);
+ s = rt.start(false);
+
+ am = m.getDB(baseName).a;
+
+ for (i = 0; i < 1000; ++i)
+ am.save({_id: new ObjectId(), i: i});
+
+ soonCount(1000);
+ as = s.getDB(baseName).a;
+ assert.eq(1, as.find({i: 0}).count());
+ assert.eq(1, as.find({i: 999}).count());
+
+ rt.stop(false, signal);
+
+ for (i = 1000; i < 1010; ++i)
+ am.save({_id: new ObjectId(), i: i});
+
+ s = rt.start(false, null, true);
+ soonCount(1010);
+ as = s.getDB(baseName).a;
+ assert.eq(1, as.find({i: 1009}).count());
+
+ rt.stop(true, signal);
+
+ m = rt.start(true, null, true);
+ am = m.getDB(baseName).a;
+
+ for (i = 1010; i < 1020; ++i)
+ am.save({_id: new ObjectId(), i: i});
+
+ assert.soon(function() {
+ return as.find().count() == 1020;
+ });
+ assert.eq(1, as.find({i: 1019}).count());
+
+ assert.automsg("m.getDB( 'local' ).getCollection( 'oplog.$main' ).stats().size > 0");
+
rt.stop();
};
-doTest( 15 ); // SIGTERM
+doTest(15); // SIGTERM
diff --git a/jstests/repl/repl10.js b/jstests/repl/repl10.js
index 65deb3a2744..dfe3aab9fbf 100644
--- a/jstests/repl/repl10.js
+++ b/jstests/repl/repl10.js
@@ -2,39 +2,39 @@
var baseName = "jstests_repl10test";
-soonCount = function( count ) {
- assert.soon( function() {
- // print( "check count" );
- // print( "count: " + s.getDB( baseName ).z.find().count() );
- return s.getDB( baseName ).a.find().count() == count;
- } );
+soonCount = function(count) {
+ assert.soon(function() {
+ // print( "check count" );
+ // print( "count: " + s.getDB( baseName ).z.find().count() );
+ return s.getDB(baseName).a.find().count() == count;
+ });
};
-doTest = function( signal ) {
-
- rt = new ReplTest( "repl10tests" );
-
- m = rt.start( true );
- s = rt.start( false, { "slavedelay": "10" } );
-
- am = m.getDB( baseName ).a;
-
- am.save( {i:1} );
-
- soonCount( 1 );
-
- am.save( {i:2} );
- assert.eq( 2, am.count() );
- sleep( 3000 );
- assert.eq( 1, s.getDB( baseName ).a.count() );
-
- soonCount( 2 );
+doTest = function(signal) {
+
+ rt = new ReplTest("repl10tests");
+
+ m = rt.start(true);
+ s = rt.start(false, {"slavedelay": "10"});
+
+ am = m.getDB(baseName).a;
+
+ am.save({i: 1});
+
+ soonCount(1);
+
+ am.save({i: 2});
+ assert.eq(2, am.count());
+ sleep(3000);
+ assert.eq(1, s.getDB(baseName).a.count());
+
+ soonCount(2);
rt.stop();
};
print("repl10.js dotest(15)");
-doTest(15); // SIGTERM
+doTest(15); // SIGTERM
print("repl10.js dotest(15)");
doTest(9); // SIGKILL
print("repl10.js SUCCESS");
diff --git a/jstests/repl/repl12.js b/jstests/repl/repl12.js
index 4d41462afde..9771a48178e 100644
--- a/jstests/repl/repl12.js
+++ b/jstests/repl/repl12.js
@@ -1,25 +1,25 @@
// SERVER-1626
// check for initial sync of multiple db's
-function debug( x ) {
- print( "DEBUG:" + tojson( x ) );
+function debug(x) {
+ print("DEBUG:" + tojson(x));
}
-rt = new ReplTest( "repl12tests" );
+rt = new ReplTest("repl12tests");
-m = rt.start( true );
+m = rt.start(true);
usedDBs = [];
a = "a";
-for( i = 0; i < 3; ++i ) {
- usedDBs.push( a );
- m.getDB( a ).c.save( {} );
+for (i = 0; i < 3; ++i) {
+ usedDBs.push(a);
+ m.getDB(a).c.save({});
a += "a";
}
-//print("\n\n\n DB NAMES MASTER:");
-//printjson(m.getDBNames());
+// print("\n\n\n DB NAMES MASTER:");
+// printjson(m.getDBNames());
var z = 10500;
print("sleeping " + z + "ms");
@@ -27,26 +27,24 @@ sleep(z);
s = rt.start(false);
-function countHave(){
+function countHave() {
var have = 0;
- for ( var i=0; i<usedDBs.length; i++ ){
- if ( s.getDB( usedDBs[i] ).c.findOne() )
+ for (var i = 0; i < usedDBs.length; i++) {
+ if (s.getDB(usedDBs[i]).c.findOne())
have++;
}
return have;
}
-assert.soon(
- function() {
- try {
- var c = countHave();
- debug( "count: " + c );
- return c == 3;
- } catch (e) {
- printjson(e);
- return false;
- }
+assert.soon(function() {
+ try {
+ var c = countHave();
+ debug("count: " + c);
+ return c == 3;
+ } catch (e) {
+ printjson(e);
+ return false;
}
-);
+});
-//printjson(s.getDBNames());
+// printjson(s.getDBNames());
diff --git a/jstests/repl/repl13.js b/jstests/repl/repl13.js
index 80d86ffd92d..78fe9adfc81 100644
--- a/jstests/repl/repl13.js
+++ b/jstests/repl/repl13.js
@@ -1,58 +1,66 @@
// Test update modifier uassert during initial sync. SERVER-4781
var debuggingEnabled = false;
-function debug( x ) {
- if ( debuggingEnabled ) {
- printjson( x );
+function debug(x) {
+ if (debuggingEnabled) {
+ printjson(x);
}
}
-rt = new ReplTest( "repl13tests" );
+rt = new ReplTest("repl13tests");
-m = rt.start( true );
-mc = m.getDB( 'd' )[ 'c' ];
+m = rt.start(true);
+mc = m.getDB('d')['c'];
// Insert some documents with a:{} fields.
var bulk = mc.initializeUnorderedBulkOp();
-for(var i = 0; i < 100000; ++i) {
- bulk.insert({ _id: i, a: {}});
+for (var i = 0; i < 100000; ++i) {
+ bulk.insert({_id: i, a: {}});
}
assert.writeOK(bulk.execute());
-s = rt.start( false );
-sc = s.getDB( 'd' )[ 'c' ];
+s = rt.start(false);
+sc = s.getDB('d')['c'];
// Wait for the initial clone to begin.
-assert.soon( function() { debug( sc.count() ); return sc.count() > 0; } );
+assert.soon(function() {
+ debug(sc.count());
+ return sc.count() > 0;
+});
// Update documents that will be cloned last with the intent that an updated version will be cloned.
// This may cause an assertion when an update that was successfully applied to the original version
// of a document is replayed against an updated version of the same document.
bulk = mc.initializeUnorderedBulkOp();
-for( i = 99999; i >= 90000; --i ) {
+for (i = 99999; i >= 90000; --i) {
// If the document is cloned as {a:1}, the {$set:{'a.b':1}} modifier will uassert.
- bulk.find({ _id: i }).update({ $set: { 'a.b': 1 }});
- bulk.find({ _id: i }).update({ $set: { a: 1 }});
+ bulk.find({_id: i}).update({$set: {'a.b': 1}});
+ bulk.find({_id: i}).update({$set: {a: 1}});
}
assert.writeOK(bulk.execute());
// The initial sync completes and subsequent writes succeed, in spite of any assertions that occur
// when the update operations above are replicated.
-mc.save( {} );
-assert.eq( 100001 , mc.count() );
-assert.soon( function() { return sc.count() == 100001; } );
-mc.save( {} );
-assert.eq( 100002 , mc.count() );
-assert.soon( function() { return sc.count() == 100002; } );
+mc.save({});
+assert.eq(100001, mc.count());
+assert.soon(function() {
+ return sc.count() == 100001;
+});
+mc.save({});
+assert.eq(100002, mc.count());
+assert.soon(function() {
+ return sc.count() == 100002;
+});
-debug( sc.findOne( {_id:99999} ) );
-debug( sc.findOne( {_id:90000} ) );
+debug(sc.findOne({_id: 99999}));
+debug(sc.findOne({_id: 90000}));
-assert.eq( 1, sc.findOne( {_id:99999} ).a );
-assert.eq( 1, sc.findOne( {_id:90000} ).a );
+assert.eq(1, sc.findOne({_id: 99999}).a);
+assert.eq(1, sc.findOne({_id: 90000}).a);
-m_hash = m.getDB( "d" ).runCommand( "dbhash" );
-s_hash = s.getDB( "d" ).runCommand( "dbhash" );
-
-assert.eq( m_hash.collections.c , s_hash.collections.c , "sad " + tojson( m_hash ) + " " + tojson( s_hash ) );
+m_hash = m.getDB("d").runCommand("dbhash");
+s_hash = s.getDB("d").runCommand("dbhash");
+assert.eq(m_hash.collections.c,
+ s_hash.collections.c,
+ "sad " + tojson(m_hash) + " " + tojson(s_hash));
diff --git a/jstests/repl/repl14.js b/jstests/repl/repl14.js
index 5359221e607..c9d39686034 100644
--- a/jstests/repl/repl14.js
+++ b/jstests/repl/repl14.js
@@ -1,65 +1,74 @@
// Test replication of an array by $push-ing to a missing field in the presence of a sparse index on
// the field. SERVER-4907
-function testWithCollectionIndexIds( capped, sparse, useIds ) {
- printjson( { capped:capped, sparse:sparse, useIds:useIds } );
-
- rt = new ReplTest( "repl14tests" );
-
- m = rt.start( true ); // master
- if ( capped ) {
- m.getDB( 'd' ).createCollection( 'c', { capped:true, size:5*1024 } );
+function testWithCollectionIndexIds(capped, sparse, useIds) {
+ printjson({capped: capped, sparse: sparse, useIds: useIds});
+
+ rt = new ReplTest("repl14tests");
+
+ m = rt.start(true); // master
+ if (capped) {
+ m.getDB('d').createCollection('c', {capped: true, size: 5 * 1024});
}
- mc = m.getDB( 'd' )[ 'c' ]; // master collection
-
- mc.ensureIndex( {a:1}, {sparse:sparse} );
+ mc = m.getDB('d')['c']; // master collection
+
+ mc.ensureIndex({a: 1}, {sparse: sparse});
toInsert = {};
- if ( capped ) {
+ if (capped) {
// Add a singleton array as padding, so the push later on will not change document size.
- toInsert = {p:[1]};
- }
- if ( useIds ) { // Insert wiith an auto generated _id.
- mc.insert( toInsert );
+ toInsert = {
+ p: [1]
+ };
}
- else { // Otherwise avoid the auto generated _id.
- mc._mongo.insert( mc._fullName, toInsert, 0 );
+ if (useIds) { // Insert wiith an auto generated _id.
+ mc.insert(toInsert);
+ } else { // Otherwise avoid the auto generated _id.
+ mc._mongo.insert(mc._fullName, toInsert, 0);
}
assert.eq(mc.count(), 1);
-
- s = rt.start( false ); // slave
- sc = s.getDB( 'd' )[ 'c' ]; // slave collection
+
+ s = rt.start(false); // slave
+ sc = s.getDB('d')['c']; // slave collection
// Wait for the document to be cloned.
- assert.soon( function() { return sc.count() > 0; },"doc not replicated soon enough", 60*1000 );
-
- modifiers = {$push:{a:1}};
- if ( capped ) {
+ assert.soon(function() {
+ return sc.count() > 0;
+ }, "doc not replicated soon enough", 60 * 1000);
+
+ modifiers = {
+ $push: {a: 1}
+ };
+ if (capped) {
// Delete our singleton array to balance the new singleton array we're going to create.
- modifiers['$unset'] = {p:1};
+ modifiers['$unset'] = {
+ p: 1
+ };
}
- assert.writeOK(mc.update( {}, modifiers ));
-
+ assert.writeOK(mc.update({}, modifiers));
+
// Wait for the update to be replicated.
- assert.soon( function() { return sc.count( {a:1} ) > 0; } );
-
+ assert.soon(function() {
+ return sc.count({a: 1}) > 0;
+ });
+
rt.stop();
}
-function testWithCollectionIndex( capped, sparse ) {
- testWithCollectionIndexIds( capped, sparse, true );
- if ( capped ) {
- testWithCollectionIndexIds( capped, sparse, false );
+function testWithCollectionIndex(capped, sparse) {
+ testWithCollectionIndexIds(capped, sparse, true);
+ if (capped) {
+ testWithCollectionIndexIds(capped, sparse, false);
}
}
-function testWithCollection( capped ) {
- testWithCollectionIndex( capped, true );
- testWithCollectionIndex( capped, false );
+function testWithCollection(capped) {
+ testWithCollectionIndex(capped, true);
+ testWithCollectionIndex(capped, false);
}
function test() {
- testWithCollection( true );
- testWithCollection( false );
+ testWithCollection(true);
+ testWithCollection(false);
}
test();
diff --git a/jstests/repl/repl15.js b/jstests/repl/repl15.js
index 2545ec0b9d5..b5ec0a0ade3 100644
--- a/jstests/repl/repl15.js
+++ b/jstests/repl/repl15.js
@@ -1,39 +1,40 @@
// Test a case were an update can grow a document on master but growth is prevented on slave.
// SERVER-4939
-if ( 0 ) { // SERVER-4939
-
-function doTest( capped ) {
-
- rt = new ReplTest( "repl15tests" );
- master = rt.start( true );
- if ( capped ) {
- master.getDB( 'd' ).createCollection( 'c', { capped:true, size:5*1024 } );
+if (0) { // SERVER-4939
+
+ function doTest(capped) {
+ rt = new ReplTest("repl15tests");
+ master = rt.start(true);
+ if (capped) {
+ master.getDB('d').createCollection('c', {capped: true, size: 5 * 1024});
+ }
+ mc = master.getDB('d')['c'];
+
+ big = new Array(1000).toString();
+ // Insert a document, then make it slightly smaller.
+ mc.insert({a: big});
+ mc.update({}, {$set: {a: 'b'}});
+
+ slave = rt.start(false);
+ sc = slave.getDB('d')['c'];
+
+ // Slave will copy the smaller doc.
+ assert.soon(function() {
+ return sc.count({a: 'b'}) > 0;
+ });
+
+ // Update the primary doc to its original size.
+ mc.update({}, {$set: {a: big}});
+
+ // Wait for secondary to clone the update.
+ assert.soon(function() {
+ return sc.count({a: big}) > 0;
+ });
+
+ rt.stop();
}
- mc = master.getDB( 'd' )[ 'c' ];
-
- big = new Array( 1000 ).toString();
- // Insert a document, then make it slightly smaller.
- mc.insert( {a:big} );
- mc.update( {}, {$set:{a:'b'}} );
-
- slave = rt.start( false );
- sc = slave.getDB( 'd' )[ 'c' ];
-
- // Slave will copy the smaller doc.
- assert.soon( function() { return sc.count( {a:'b'} ) > 0; } );
-
- // Update the primary doc to its original size.
- mc.update( {}, {$set:{a:big}} );
-
- // Wait for secondary to clone the update.
- assert.soon( function() { return sc.count( {a:big} ) > 0; } );
-
- rt.stop();
-
-}
-
-doTest( false );
-doTest( true );
+ doTest(false);
+ doTest(true);
}
diff --git a/jstests/repl/repl16.js b/jstests/repl/repl16.js
index e0b5540ee95..84d0073eff8 100644
--- a/jstests/repl/repl16.js
+++ b/jstests/repl/repl16.js
@@ -1,40 +1,40 @@
// Test deduping of new documents without an _id index
// SERVER-14132
-if ( 0 ) {
-
-function doTest( insert ) {
-
- rt = new ReplTest( "repl16tests" );
- master = rt.start( true );
- master.getDB( 'd' ).createCollection( 'c', { capped:true, size:5*1024, autoIndexId:false } );
- mc = master.getDB( 'd' )[ 'c' ];
-
- insert( {_id:1} );
- insert( {_id:2} );
-
- slave = rt.start( false );
- sc = slave.getDB( 'd' )[ 'c' ];
-
- // Wait for the slave to copy the documents.
- assert.soon( function() { return sc.count() == 2; } );
-
- insert( {_id:1} );
- insert( {_id:2} );
- insert( {_id:3} );
- assert.eq( 5, mc.count() );
-
- // Wait for the slave to apply the operations.
- assert.soon( function() { return sc.count() == 5; } );
-
- rt.stop();
-
-}
-
-function insertWithIds( obj ) {
- mc.insert( obj );
-}
-
-doTest( insertWithIds );
-
+if (0) {
+ function doTest(insert) {
+ rt = new ReplTest("repl16tests");
+ master = rt.start(true);
+ master.getDB('d').createCollection('c', {capped: true, size: 5 * 1024, autoIndexId: false});
+ mc = master.getDB('d')['c'];
+
+ insert({_id: 1});
+ insert({_id: 2});
+
+ slave = rt.start(false);
+ sc = slave.getDB('d')['c'];
+
+ // Wait for the slave to copy the documents.
+ assert.soon(function() {
+ return sc.count() == 2;
+ });
+
+ insert({_id: 1});
+ insert({_id: 2});
+ insert({_id: 3});
+ assert.eq(5, mc.count());
+
+ // Wait for the slave to apply the operations.
+ assert.soon(function() {
+ return sc.count() == 5;
+ });
+
+ rt.stop();
+ }
+
+ function insertWithIds(obj) {
+ mc.insert(obj);
+ }
+
+ doTest(insertWithIds);
}
diff --git a/jstests/repl/repl17.js b/jstests/repl/repl17.js
index 651bebdaa09..cd62e6c7ac6 100644
--- a/jstests/repl/repl17.js
+++ b/jstests/repl/repl17.js
@@ -1,37 +1,40 @@
// Test collection rename during initial sync.
// SERVER-4941
-if ( 0 ) { // SERVER-4941
+if (0) { // SERVER-4941
-rt = new ReplTest( "repl17tests" );
+ rt = new ReplTest("repl17tests");
-master = rt.start( true );
-md = master.getDB( 'd' );
+ master = rt.start(true);
+ md = master.getDB('d');
-for( i = 0; i < 1000; ++i ) {
- md[ ''+i ].save( {} );
-}
+ for (i = 0; i < 1000; ++i) {
+ md['' + i].save({});
+ }
-slave = rt.start( false );
-sd = slave.getDB( 'd' );
+ slave = rt.start(false);
+ sd = slave.getDB('d');
-function checkSlaveCount( collection, expectedCount ) {
- var count = sd[ collection ].count();
- var debug = false;
- if ( debug ) {
- print( collection + ': ' + count );
+ function checkSlaveCount(collection, expectedCount) {
+ var count = sd[collection].count();
+ var debug = false;
+ if (debug) {
+ print(collection + ': ' + count);
+ }
+ return count == expectedCount;
}
- return count == expectedCount;
-}
-
-// Wait for the slave to start cloning
-assert.soon( function() { return checkSlaveCount( '0', 1 ); } );
-assert.commandWorked( md[ '999' ].renameCollection( 'renamed' ) );
+ // Wait for the slave to start cloning
+ assert.soon(function() {
+ return checkSlaveCount('0', 1);
+ });
-// Check for renamed collection on slave.
-assert.soon( function() { return checkSlaveCount( '999', 0 ) && checkSlaveCount( 'renamed', 1 ); } );
+ assert.commandWorked(md['999'].renameCollection('renamed'));
-rt.stop();
+ // Check for renamed collection on slave.
+ assert.soon(function() {
+ return checkSlaveCount('999', 0) && checkSlaveCount('renamed', 1);
+ });
+ rt.stop();
}
diff --git a/jstests/repl/repl2.js b/jstests/repl/repl2.js
index 020caa8bc71..c23c2a994c4 100644
--- a/jstests/repl/repl2.js
+++ b/jstests/repl/repl2.js
@@ -13,57 +13,58 @@
// slave will not have any data and will start an initial sync, rejecting the resync command.
// @tags: [requires_persistence]
-soonCount = function( count ) {
- assert.soon( function() {
-// print( "check count" );
-// print( "count: " + s.getDB( baseName ).z.find().count() );
- return s.getDB("foo").a.find().count() == count;
- } );
+soonCount = function(count) {
+ assert.soon(function() {
+ // print( "check count" );
+ // print( "count: " + s.getDB( baseName ).z.find().count() );
+ return s.getDB("foo").a.find().count() == count;
+ });
};
doTest = function(signal, extraOpts) {
- print("signal: "+signal);
+ print("signal: " + signal);
- var rt = new ReplTest( "repl2tests" );
+ var rt = new ReplTest("repl2tests");
// implicit small oplog makes slave get out of sync
- m = rt.start( true, { oplogSize : "1" } );
+ m = rt.start(true, {oplogSize: "1"});
s = rt.start(false, extraOpts);
am = m.getDB("foo").a;
- am.save( { _id: new ObjectId() } );
- soonCount( 1 );
- assert.eq( 0, s.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok );
- rt.stop( false , signal );
+ am.save({_id: new ObjectId()});
+ soonCount(1);
+ assert.eq(0, s.getDB("admin").runCommand({"resync": 1}).ok);
+ rt.stop(false, signal);
- big = new Array( 2000 ).toString();
- for( i = 0; i < 1000; ++i )
- am.save( { _id: new ObjectId(), i: i, b: big } );
+ big = new Array(2000).toString();
+ for (i = 0; i < 1000; ++i)
+ am.save({_id: new ObjectId(), i: i, b: big});
s = rt.start(false, extraOpts, true);
- print("earliest op in master: "+tojson(m.getDB("local").oplog.$main.find().sort({$natural:1}).limit(1).next()));
- print("latest op on slave: "+tojson(s.getDB("local").sources.findOne()));
+ print("earliest op in master: " +
+ tojson(m.getDB("local").oplog.$main.find().sort({$natural: 1}).limit(1).next()));
+ print("latest op on slave: " + tojson(s.getDB("local").sources.findOne()));
- assert.soon( function() {
- var result = s.getDB( "admin" ).runCommand( { "resync" : 1 } );
- print("resync says: "+tojson(result));
+ assert.soon(function() {
+ var result = s.getDB("admin").runCommand({"resync": 1});
+ print("resync says: " + tojson(result));
return result.ok == 1;
- } );
+ });
- soonCount( 1001 );
- assert.automsg( "m.getDB( 'local' ).getCollection( 'oplog.$main' ).stats().size > 0" );
+ soonCount(1001);
+ assert.automsg("m.getDB( 'local' ).getCollection( 'oplog.$main' ).stats().size > 0");
as = s.getDB("foo").a;
- assert.eq( 1, as.find( { i: 0 } ).count() );
- assert.eq( 1, as.find( { i: 999 } ).count() );
+ assert.eq(1, as.find({i: 0}).count());
+ assert.eq(1, as.find({i: 999}).count());
- assert.eq( 0, s.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok );
+ assert.eq(0, s.getDB("admin").runCommand({"resync": 1}).ok);
rt.stop();
};
-doTest(15, {"vv": null}); // SIGTERM
-doTest(9, {"vv": null, journal: null }); // SIGKILL
+doTest(15, {"vv": null}); // SIGTERM
+doTest(9, {"vv": null, journal: null}); // SIGKILL
diff --git a/jstests/repl/repl3.js b/jstests/repl/repl3.js
index 78e76347115..fb31e9208f0 100644
--- a/jstests/repl/repl3.js
+++ b/jstests/repl/repl3.js
@@ -2,15 +2,16 @@
var baseName = "jstests_repl3test";
-soonCount = function( count ) {
- assert.soon( function() {
-// print( "check count" );
-// print( "count: " + s.getDB( baseName ).z.find().count() + ", expected: " + count );
- return s.getDB( baseName ).a.find().itcount() == count;
- } );
+soonCount = function(count) {
+ assert.soon(function() {
+ // print( "check count" );
+ // print( "count: " + s.getDB( baseName ).z.find().count() + ", expected: " +
+ // count );
+ return s.getDB(baseName).a.find().itcount() == count;
+ });
};
-doTest = function (signal) {
+doTest = function(signal) {
print("repl3.js doTest(" + signal + ")");
@@ -21,15 +22,15 @@ doTest = function (signal) {
am = m.getDB(baseName).a;
- am.save({ _id: new ObjectId() });
+ am.save({_id: new ObjectId()});
soonCount(1);
rt.stop(false, signal);
big = new Array(2000).toString();
for (i = 0; i < 1000; ++i)
- am.save({ _id: new ObjectId(), i: i, b: big });
+ am.save({_id: new ObjectId(), i: i, b: big});
- s = rt.start(false, { autoresync: null }, true);
+ s = rt.start(false, {autoresync: null}, true);
// after SyncException, mongod waits 10 secs.
sleep(15000);
@@ -37,15 +38,15 @@ doTest = function (signal) {
// Need the 2 additional seconds timeout, since commands don't work on an 'allDead' node.
soonCount(1001);
as = s.getDB(baseName).a;
- assert.eq(1, as.find({ i: 0 }).count());
- assert.eq(1, as.find({ i: 999 }).count());
+ assert.eq(1, as.find({i: 0}).count());
+ assert.eq(1, as.find({i: 999}).count());
- assert.commandFailed(s.getDB("admin").runCommand({ "resync": 1 }));
+ assert.commandFailed(s.getDB("admin").runCommand({"resync": 1}));
rt.stop();
};
-doTest( 15 ); // SIGTERM
-doTest( 9 ); // SIGKILL
+doTest(15); // SIGTERM
+doTest(9); // SIGKILL
print("repl3.js OK");
diff --git a/jstests/repl/repl4.js b/jstests/repl/repl4.js
index b540e8545fe..e28986e1573 100644
--- a/jstests/repl/repl4.js
+++ b/jstests/repl/repl4.js
@@ -1,38 +1,38 @@
// Test replication 'only' mode
-soonCount = function( db, coll, count ) {
- assert.soon( function() {
- return s.getDB( db )[ coll ].find().count() == count;
- } );
+soonCount = function(db, coll, count) {
+ assert.soon(function() {
+ return s.getDB(db)[coll].find().count() == count;
+ });
};
doTest = function() {
- rt = new ReplTest( "repl4tests" );
-
- m = rt.start( true );
- s = rt.start( false, { only: "c" } );
-
- cm = m.getDB( "c" ).c;
- bm = m.getDB( "b" ).b;
-
- cm.save( { x:1 } );
- bm.save( { x:2 } );
-
- soonCount( "c", "c", 1 );
- assert.eq( 1, s.getDB( "c" ).c.findOne().x );
- sleep( 10000 );
- printjson( s.getDBNames() );
- assert.eq( -1, s.getDBNames().indexOf( "b" ) );
- assert.eq( 0, s.getDB( "b" ).b.find().count() );
-
- rt.stop( false );
-
- cm.save( { x:3 } );
- bm.save( { x:4 } );
-
- s = rt.start( false, { only: "c" }, true );
- soonCount( "c", "c", 2 );
+ rt = new ReplTest("repl4tests");
+
+ m = rt.start(true);
+ s = rt.start(false, {only: "c"});
+
+ cm = m.getDB("c").c;
+ bm = m.getDB("b").b;
+
+ cm.save({x: 1});
+ bm.save({x: 2});
+
+ soonCount("c", "c", 1);
+ assert.eq(1, s.getDB("c").c.findOne().x);
+ sleep(10000);
+ printjson(s.getDBNames());
+ assert.eq(-1, s.getDBNames().indexOf("b"));
+ assert.eq(0, s.getDB("b").b.find().count());
+
+ rt.stop(false);
+
+ cm.save({x: 3});
+ bm.save({x: 4});
+
+ s = rt.start(false, {only: "c"}, true);
+ soonCount("c", "c", 2);
};
// Disabled because of SERVER-10344
diff --git a/jstests/repl/repl5.js b/jstests/repl/repl5.js
index 91834637947..514d1560376 100644
--- a/jstests/repl/repl5.js
+++ b/jstests/repl/repl5.js
@@ -1,34 +1,34 @@
// Test auto reclone after failed initial clone
-soonCountAtLeast = function( db, coll, count ) {
- assert.soon( function() {
-// print( "count: " + s.getDB( db )[ coll ].find().count() );
- return s.getDB( db )[ coll ].find().itcount() >= count;
- } );
+soonCountAtLeast = function(db, coll, count) {
+ assert.soon(function() {
+ // print( "count: " + s.getDB( db )[ coll ].find().count() );
+ return s.getDB(db)[coll].find().itcount() >= count;
+ });
};
doTest = function(signal, extraOpts) {
- rt = new ReplTest( "repl5tests" );
-
- m = rt.start( true );
-
- ma = m.getDB( "a" ).a;
+ rt = new ReplTest("repl5tests");
+
+ m = rt.start(true);
+
+ ma = m.getDB("a").a;
var bulk = ma.initializeUnorderedBulkOp();
- for( i = 0; i < 10000; ++i )
- bulk.insert({ i: i });
+ for (i = 0; i < 10000; ++i)
+ bulk.insert({i: i});
assert.writeOK(bulk.execute());
-
+
s = rt.start(false, extraOpts);
- soonCountAtLeast( "a", "a", 1 );
- rt.stop( false, signal );
+ soonCountAtLeast("a", "a", 1);
+ rt.stop(false, signal);
s = rt.start(false, extraOpts, true);
- sleep( 1000 );
- soonCountAtLeast( "a", "a", 10000 );
+ sleep(1000);
+ soonCountAtLeast("a", "a", 10000);
rt.stop();
};
-doTest( 15 ); // SIGTERM
-doTest(9, { journal: null }); // SIGKILL
+doTest(15); // SIGTERM
+doTest(9, {journal: null}); // SIGKILL
diff --git a/jstests/repl/repl6.js b/jstests/repl/repl6.js
index a26a7be94e5..c9ccdbdd559 100644
--- a/jstests/repl/repl6.js
+++ b/jstests/repl/repl6.js
@@ -8,75 +8,75 @@
var baseName = "jstests_repl6test";
-soonCount = function( m, count ) {
- assert.soon( function() {
- return m.getDB( baseName ).a.find().count() == count;
- }, "expected count: " + count + " from : " + m );
+soonCount = function(m, count) {
+ assert.soon(function() {
+ return m.getDB(baseName).a.find().count() == count;
+ }, "expected count: " + count + " from : " + m);
};
-doTest = function( signal ) {
-
- ports = allocatePorts( 3 );
-
- ms1 = new ReplTest( "repl6tests-1", [ ports[ 0 ], ports[ 1 ] ] );
- ms2 = new ReplTest( "repl6tests-2", [ ports[ 0 ], ports[ 2 ] ] );
-
- m = ms1.start( true );
- s1 = ms1.start( false );
- s2 = ms2.start( false );
-
- am = m.getDB( baseName ).a;
-
- for( i = 0; i < 1000; ++i )
- am.save( { _id: new ObjectId(), i: i } );
-
- soonCount( s1, 1000 );
- soonCount( s2, 1000 );
-
- check = function( as ) {
- assert.eq( 1, as.find( { i: 0 } ).count() );
- assert.eq( 1, as.find( { i: 999 } ).count() );
+doTest = function(signal) {
+
+ ports = allocatePorts(3);
+
+ ms1 = new ReplTest("repl6tests-1", [ports[0], ports[1]]);
+ ms2 = new ReplTest("repl6tests-2", [ports[0], ports[2]]);
+
+ m = ms1.start(true);
+ s1 = ms1.start(false);
+ s2 = ms2.start(false);
+
+ am = m.getDB(baseName).a;
+
+ for (i = 0; i < 1000; ++i)
+ am.save({_id: new ObjectId(), i: i});
+
+ soonCount(s1, 1000);
+ soonCount(s2, 1000);
+
+ check = function(as) {
+ assert.eq(1, as.find({i: 0}).count());
+ assert.eq(1, as.find({i: 999}).count());
};
-
- as = s1.getDB( baseName ).a;
- check( as );
- as = s2.getDB( baseName ).a;
- check( as );
- ms1.stop( false, signal );
- ms2.stop( false, signal );
-
- for( i = 1000; i < 1010; ++i )
- am.save( { _id: new ObjectId(), i: i } );
+ as = s1.getDB(baseName).a;
+ check(as);
+ as = s2.getDB(baseName).a;
+ check(as);
+
+ ms1.stop(false, signal);
+ ms2.stop(false, signal);
+
+ for (i = 1000; i < 1010; ++i)
+ am.save({_id: new ObjectId(), i: i});
- s1 = ms1.start( false, null, true );
- soonCount( s1, 1010 );
- as = s1.getDB( baseName ).a;
- assert.eq( 1, as.find( { i: 1009 } ).count() );
+ s1 = ms1.start(false, null, true);
+ soonCount(s1, 1010);
+ as = s1.getDB(baseName).a;
+ assert.eq(1, as.find({i: 1009}).count());
- ms1.stop( true, signal );
+ ms1.stop(true, signal);
// Need to pause here on Windows, since killing processes does not synchronously close their
// open file handles.
sleep(5000);
- m = ms1.start( true, null, true );
- am = m.getDB( baseName ).a;
-
- for( i = 1010; i < 1020; ++i )
- am.save( { _id: new ObjectId(), i: i } );
-
- soonCount( s1, 1020 );
- assert.eq( 1, as.find( { i: 1019 } ).count() );
-
- s2 = ms2.start( false, null, true );
- soonCount( s2, 1020 );
- as = s2.getDB( baseName ).a;
- assert.eq( 1, as.find( { i: 1009 } ).count() );
- assert.eq( 1, as.find( { i: 1019 } ).count() );
+ m = ms1.start(true, null, true);
+ am = m.getDB(baseName).a;
+
+ for (i = 1010; i < 1020; ++i)
+ am.save({_id: new ObjectId(), i: i});
+
+ soonCount(s1, 1020);
+ assert.eq(1, as.find({i: 1019}).count());
+
+ s2 = ms2.start(false, null, true);
+ soonCount(s2, 1020);
+ as = s2.getDB(baseName).a;
+ assert.eq(1, as.find({i: 1009}).count());
+ assert.eq(1, as.find({i: 1019}).count());
ms1.stop();
- ms2.stop( false );
+ ms2.stop(false);
};
-doTest( 15 ); // SIGTERM
+doTest(15); // SIGTERM
diff --git a/jstests/repl/repl7.js b/jstests/repl/repl7.js
index 2907acc087c..790aef03420 100644
--- a/jstests/repl/repl7.js
+++ b/jstests/repl/repl7.js
@@ -11,44 +11,45 @@ var getDBNamesNoThrow = function(conn) {
doTest = function(signal, extraOpts) {
- rt = new ReplTest( "repl7tests" );
-
- m = rt.start( true );
+ rt = new ReplTest("repl7tests");
- for( n = "a"; n != "aaaaa"; n += "a" ) {
- m.getDB( n ).a.save( {x:1} );
+ m = rt.start(true);
+
+ for (n = "a"; n != "aaaaa"; n += "a") {
+ m.getDB(n).a.save({x: 1});
}
s = rt.start(false, extraOpts);
-
- assert.soon( function() {
- return -1 != getDBNamesNoThrow(s).indexOf( "aa" );
- }, "aa timeout", 60000, 1000 );
-
- rt.stop( false, signal );
+
+ assert.soon(function() {
+ return -1 != getDBNamesNoThrow(s).indexOf("aa");
+ }, "aa timeout", 60000, 1000);
+
+ rt.stop(false, signal);
s = rt.start(false, extraOpts, signal);
-
- assert.soon( function() {
- for( n = "a"; n != "aaaaa"; n += "a" ) {
- if ( -1 == getDBNamesNoThrow(s).indexOf( n ) )
- return false;
- }
- return true;
- }, "a-aaaa timeout", 60000, 1000 );
-
- assert.soon( function() {
- for( n = "a"; n != "aaaaa"; n += "a" ) {
- if ( 1 != m.getDB( n ).a.find().count() ) {
- return false;
- }
- }
- return true; }, "a-aaaa count timeout" );
-
- sleep( 300 );
-
+
+ assert.soon(function() {
+ for (n = "a"; n != "aaaaa"; n += "a") {
+ if (-1 == getDBNamesNoThrow(s).indexOf(n))
+ return false;
+ }
+ return true;
+ }, "a-aaaa timeout", 60000, 1000);
+
+ assert.soon(function() {
+ for (n = "a"; n != "aaaaa"; n += "a") {
+ if (1 != m.getDB(n).a.find().count()) {
+ return false;
+ }
+ }
+ return true;
+ }, "a-aaaa count timeout");
+
+ sleep(300);
+
rt.stop();
};
-doTest( 15 ); // SIGTERM
-doTest(9, { journal: null }); // SIGKILL
+doTest(15); // SIGTERM
+doTest(9, {journal: null}); // SIGKILL
diff --git a/jstests/repl/repl8.js b/jstests/repl/repl8.js
index 64e65cc0e16..e9ddba94729 100644
--- a/jstests/repl/repl8.js
+++ b/jstests/repl/repl8.js
@@ -2,29 +2,42 @@
baseName = "jstests_repl_repl8";
-rt = new ReplTest( "repl8tests" );
-
-m = rt.start( true );
-
-m.getDB( baseName ).createCollection( "first", {capped:true,size:1000} );
-assert( m.getDB( baseName ).getCollection( "first" ).isCapped() );
-
-s = rt.start( false );
-
-assert.soon( function() { return s.getDB( baseName ).getCollection( "first" ).isCapped(); } );
-
-m.getDB( baseName ).createCollection( "second", {capped:true,size:1000} );
-assert.soon( function() { return s.getDB( baseName ).getCollection( "second" ).isCapped(); } );
-
-m.getDB( baseName ).getCollection( "third" ).save( { a: 1 } );
-assert.soon( function() { return s.getDB( baseName ).getCollection( "third" ).exists(); } );
-assert.commandWorked( m.getDB( "admin" ).runCommand( {renameCollection:"jstests_repl_repl8.third", to:"jstests_repl_repl8.third_rename"} ) );
-assert( m.getDB( baseName ).getCollection( "third_rename" ).exists() );
-assert( !m.getDB( baseName ).getCollection( "third" ).exists() );
-assert.soon( function() { return s.getDB( baseName ).getCollection( "third_rename" ).exists(); } );
-assert.soon( function() { return !s.getDB( baseName ).getCollection( "third" ).exists(); } );
-
-m.getDB( baseName ).getCollection( "fourth" ).save( {a:1} );
-assert.commandWorked( m.getDB( baseName ).getCollection( "fourth" ).convertToCapped( 1000 ) );
-assert( m.getDB( baseName ).getCollection( "fourth" ).isCapped() );
-assert.soon( function() { return s.getDB( baseName ).getCollection( "fourth" ).isCapped(); } );
+rt = new ReplTest("repl8tests");
+
+m = rt.start(true);
+
+m.getDB(baseName).createCollection("first", {capped: true, size: 1000});
+assert(m.getDB(baseName).getCollection("first").isCapped());
+
+s = rt.start(false);
+
+assert.soon(function() {
+ return s.getDB(baseName).getCollection("first").isCapped();
+});
+
+m.getDB(baseName).createCollection("second", {capped: true, size: 1000});
+assert.soon(function() {
+ return s.getDB(baseName).getCollection("second").isCapped();
+});
+
+m.getDB(baseName).getCollection("third").save({a: 1});
+assert.soon(function() {
+ return s.getDB(baseName).getCollection("third").exists();
+});
+assert.commandWorked(m.getDB("admin").runCommand(
+ {renameCollection: "jstests_repl_repl8.third", to: "jstests_repl_repl8.third_rename"}));
+assert(m.getDB(baseName).getCollection("third_rename").exists());
+assert(!m.getDB(baseName).getCollection("third").exists());
+assert.soon(function() {
+ return s.getDB(baseName).getCollection("third_rename").exists();
+});
+assert.soon(function() {
+ return !s.getDB(baseName).getCollection("third").exists();
+});
+
+m.getDB(baseName).getCollection("fourth").save({a: 1});
+assert.commandWorked(m.getDB(baseName).getCollection("fourth").convertToCapped(1000));
+assert(m.getDB(baseName).getCollection("fourth").isCapped());
+assert.soon(function() {
+ return s.getDB(baseName).getCollection("fourth").isCapped();
+});
diff --git a/jstests/repl/repl9.js b/jstests/repl/repl9.js
index 61f52d377e9..4e50a657809 100644
--- a/jstests/repl/repl9.js
+++ b/jstests/repl/repl9.js
@@ -2,47 +2,54 @@
baseName = "jstests_repl_repl9";
-rt = new ReplTest( "repl9tests" );
+rt = new ReplTest("repl9tests");
-m = rt.start( true );
-s = rt.start( false );
+m = rt.start(true);
+s = rt.start(false);
-admin = m.getDB( "admin" );
+admin = m.getDB("admin");
-debug = function( foo ) {}; // print( foo ); }
+debug = function(foo) {}; // print( foo ); }
// rename within db
-m.getDB( baseName ).one.save( { a: 1 } );
-assert.soon( function() { v = s.getDB( baseName ).one.findOne(); return v && 1 == v.a; } );
-
-assert.commandWorked( admin.runCommand( {renameCollection:"jstests_repl_repl9.one", to:"jstests_repl_repl9.two"} ) );
-assert.soon( function() {
- if ( -1 == s.getDB( baseName ).getCollectionNames().indexOf( "two" ) ) {
- debug( "no two coll" );
- debug( tojson( s.getDB( baseName ).getCollectionNames() ) );
- return false;
- }
- if ( !s.getDB( baseName ).two.findOne() ) {
- debug( "no two object" );
- return false;
- }
- return 1 == s.getDB( baseName ).two.findOne().a; });
-assert.eq( -1, s.getDB( baseName ).getCollectionNames().indexOf( "one" ) );
+m.getDB(baseName).one.save({a: 1});
+assert.soon(function() {
+ v = s.getDB(baseName).one.findOne();
+ return v && 1 == v.a;
+});
+
+assert.commandWorked(
+ admin.runCommand({renameCollection: "jstests_repl_repl9.one", to: "jstests_repl_repl9.two"}));
+assert.soon(function() {
+ if (-1 == s.getDB(baseName).getCollectionNames().indexOf("two")) {
+ debug("no two coll");
+ debug(tojson(s.getDB(baseName).getCollectionNames()));
+ return false;
+ }
+ if (!s.getDB(baseName).two.findOne()) {
+ debug("no two object");
+ return false;
+ }
+ return 1 == s.getDB(baseName).two.findOne().a;
+});
+assert.eq(-1, s.getDB(baseName).getCollectionNames().indexOf("one"));
// rename to new db
first = baseName + "_first";
second = baseName + "_second";
-m.getDB( first ).one.save( { a: 1 } );
-assert.soon( function() { return s.getDB( first ).one.findOne() && 1 == s.getDB( first ).one.findOne().a; } );
-
-assert.commandWorked( admin.runCommand( {renameCollection:"jstests_repl_repl9_first.one", to:"jstests_repl_repl9_second.two"} ) );
-assert.soon( function() {
- return -1 != s.getDBNames().indexOf( second ) &&
- -1 != s.getDB( second ).getCollectionNames().indexOf( "two" ) &&
- s.getDB( second ).two.findOne() &&
- 1 == s.getDB( second ).two.findOne().a; } );
-assert.eq( -1, s.getDB( first ).getCollectionNames().indexOf( "one" ) );
-
+m.getDB(first).one.save({a: 1});
+assert.soon(function() {
+ return s.getDB(first).one.findOne() && 1 == s.getDB(first).one.findOne().a;
+});
+
+assert.commandWorked(admin.runCommand(
+ {renameCollection: "jstests_repl_repl9_first.one", to: "jstests_repl_repl9_second.two"}));
+assert.soon(function() {
+ return -1 != s.getDBNames().indexOf(second) &&
+ -1 != s.getDB(second).getCollectionNames().indexOf("two") &&
+ s.getDB(second).two.findOne() && 1 == s.getDB(second).two.findOne().a;
+});
+assert.eq(-1, s.getDB(first).getCollectionNames().indexOf("one"));
diff --git a/jstests/repl/repl_sync_only_db_with_special_chars.js b/jstests/repl/repl_sync_only_db_with_special_chars.js
index 68089e9db9a..1daaf1abe85 100644
--- a/jstests/repl/repl_sync_only_db_with_special_chars.js
+++ b/jstests/repl/repl_sync_only_db_with_special_chars.js
@@ -1,21 +1,21 @@
doTest = function() {
-var rt = new ReplTest( "repl_sync_only_db_with_special_chars" );
-var normalDB = "abc";
-var specialDB = "[a-z]+";
-var master = rt.start( true );
-var slave = rt.start( false, { only: specialDB } );
+ var rt = new ReplTest("repl_sync_only_db_with_special_chars");
+ var normalDB = "abc";
+ var specialDB = "[a-z]+";
+ var master = rt.start(true);
+ var slave = rt.start(false, {only: specialDB});
-master.getDB( normalDB ).data.save( { a: 1 } );
-master.getDB( specialDB ).data.save( { z: 1 } );
+ master.getDB(normalDB).data.save({a: 1});
+ master.getDB(specialDB).data.save({z: 1});
-assert.soon( function() {
- var normalDocs = slave.getDB( normalDB ).data.find().count();
- var specialDocs = slave.getDB( specialDB ).data.find().count();
+ assert.soon(function() {
+ var normalDocs = slave.getDB(normalDB).data.find().count();
+ var specialDocs = slave.getDB(specialDB).data.find().count();
- return normalDocs == 0 && specialDocs == 1;
-}, "Failed to only sync to " + specialDB );
+ return normalDocs == 0 && specialDocs == 1;
+ }, "Failed to only sync to " + specialDB);
};
diff --git a/jstests/repl/snapshot1.js b/jstests/repl/snapshot1.js
index 0d3313dad97..8db8e232e3b 100644
--- a/jstests/repl/snapshot1.js
+++ b/jstests/repl/snapshot1.js
@@ -5,35 +5,41 @@
// work. It also requires the fsync command to enduce replication lag.
// @tags: [requires_persistence, requires_fsync]
-ports = allocatePorts( 3 );
+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" ).fsyncUnlock();
-
-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" ).fsyncUnlock();
-
-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/ ) );
+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").fsyncUnlock();
+
+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").fsyncUnlock();
+
+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/));