summaryrefslogtreecommitdiff
path: root/jstests/repl
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/repl')
-rw-r--r--jstests/repl/repl10.js12
-rw-r--r--jstests/repl/repl12.js47
-rw-r--r--jstests/repl/replacePeer2.js11
-rw-r--r--jstests/repl/snapshot2.js47
4 files changed, 90 insertions, 27 deletions
diff --git a/jstests/repl/repl10.js b/jstests/repl/repl10.js
index 67c5db1..cc7cf12 100644
--- a/jstests/repl/repl10.js
+++ b/jstests/repl/repl10.js
@@ -26,13 +26,15 @@ doTest = function( signal ) {
am.save( {i:2} );
assert.eq( 2, am.count() );
sleep( 3000 );
-
- rt.stop( true, signal );
- sleep( 3000 );
assert.eq( 1, s.getDB( baseName ).a.count() );
+ soonCount( 2 );
+
rt.stop();
}
-doTest( 15 ); // SIGTERM
-doTest( 9 ); // SIGKILL
+print("repl10.js dotest(15)");
+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
new file mode 100644
index 0000000..586aa53
--- /dev/null
+++ b/jstests/repl/repl12.js
@@ -0,0 +1,47 @@
+// SERVER-1626
+// check for initial sync of multiple db's
+
+function debug( x ) {
+ print( "DEBUG:" + tojson( x ) );
+}
+
+rt = new ReplTest( "repl12tests" );
+
+m = rt.start( true );
+
+usedDBs = []
+
+a = "a"
+for( i = 0; i < 3; ++i ) {
+ usedDBs.push( a )
+ m.getDB( a ).c.save( {} );
+ a += "a";
+}
+m.getDB(a).getLastError();
+
+//print("\n\n\n DB NAMES MASTER:");
+//printjson(m.getDBNames());
+
+var z = 10500;
+print("sleeping " + z + "ms");
+sleep(z);
+
+s = rt.start(false);
+
+function countHave(){
+ var have = 0;
+ for ( var i=0; i<usedDBs.length; i++ ){
+ if ( s.getDB( usedDBs[i] ).c.findOne() )
+ have++;
+ }
+ return have;
+}
+
+assert.soon(
+ function() {
+ var c = countHave();
+ debug( "count: " + c );
+ return c == 3; }
+);
+
+//printjson(s.getDBNames());
diff --git a/jstests/repl/replacePeer2.js b/jstests/repl/replacePeer2.js
index c2983dc..33b054a 100644
--- a/jstests/repl/replacePeer2.js
+++ b/jstests/repl/replacePeer2.js
@@ -44,15 +44,8 @@ doTest = function( signal ) {
checkWrite( rp.master(), rp.slave() );
// allow slave to finish initial sync
- assert.soon(
- function() {
- var res = rp.slave().getDB( "admin" ).runCommand( {replacepeer:1} );
- if ( res.ok == 1 )
- return true;
- printjson( res );
- return false;
- }
- );
+ var res = rp.slave().getDB( "admin" ).runCommand( {replacepeer:1} );
+ assert( res.ok , "replacepeer didn't finish: " + tojson( res ) );
// Should not be saved to slave.
writeOne( rp.master() );
diff --git a/jstests/repl/snapshot2.js b/jstests/repl/snapshot2.js
index d65cad7..60b3531 100644
--- a/jstests/repl/snapshot2.js
+++ b/jstests/repl/snapshot2.js
@@ -1,4 +1,6 @@
-// Test SERVER-623 - starting repl peer from a new snapshot of master
+// Test SERVER-623 - starting repl peer from a new snapshot of master
+
+print("snapshot2.js 1 -----------------------------------------------------------");
ports = allocatePorts( 3 );
@@ -7,21 +9,37 @@ var basePath = "/data/db/" + baseName;
a = new MongodRunner( ports[ 0 ], basePath + "-arbiter" );
l = new MongodRunner( ports[ 1 ], basePath + "-left", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ] );
-r = new MongodRunner( ports[ 2 ], basePath + "-right", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ] );
+r = new MongodRunner( ports[ 2 ], basePath + "-right", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ] );
+
+print("snapshot2.js 2 -----------------------------------------------------------");
-rp = new ReplPair( l, r, a );
-rp.start();
-rp.waitForSteadyState();
+rp = new ReplPair(l, r, a);
+rp.start();
+print("snapshot2.js 3 -----------------------------------------------------------");
+rp.waitForSteadyState();
+
+print("snapshot2.js 4 -----------------------------------------------------------");
big = new Array( 2000 ).toString(); // overflow oplog, so test can't pass supriously
-rp.slave().setSlaveOk();
-for( i = 0; i < 500; ++i ) {
- rp.master().getDB( baseName )[ baseName ].save( { _id: new ObjectId(), i: i, b: big } );
- if ( i % 250 == 249 ) {
- assert.soon( function() { return i+1 == rp.slave().getDB( baseName )[ baseName ].count(); } );
+rp.slave().setSlaveOk();
+print("snapshot2.js 5 -----------------------------------------------------------");
+for (i = 0; i < 500; ++i) {
+ rp.master().getDB( baseName )[ baseName ].save( { _id: new ObjectId(), i: i, b: big } );
+ if (i % 250 == 249) {
+ function p() { return i + 1 == rp.slave().getDB(baseName)[baseName].count(); }
+ try {
+ assert.soon(p);
+ } catch (e) {
+ print("\n\n\nsnapshot2.js\ni+1:" + (i + 1));
+ print("slave count:" + rp.slave().getDB(baseName)[baseName].count());
+ sleep(2000);
+ print(p());
+ throw (e);
+ }
sleep( 10 ); // give master a chance to grab a sync point - have such small oplogs the master log might overflow otherwise
}
-}
+}
+print("snapshot2.js 6 -----------------------------------------------------------");
rp.master().getDB( "admin" ).runCommand( {fsync:1,lock:1} );
leftMaster = ( rp.master().host == rp.left().host );
@@ -47,5 +65,8 @@ assert.eq( 500, rp.slave().getDB( baseName )[ baseName ].count() );
rp.master().getDB( baseName )[ baseName ].save( {i:500} );
assert.soon( function() { return 501 == rp.slave().getDB( baseName )[ baseName ].count(); } );
-assert( !rawMongoProgramOutput().match( /resync/ ) );
-assert( !rawMongoProgramOutput().match( /SyncException/ ) ); \ No newline at end of file
+assert( !rawMongoProgramOutput().match( /resync/ ) );
+assert(!rawMongoProgramOutput().match(/SyncException/));
+
+print("snapshot2.js SUCCESS ----------------");
+