diff options
author | Scott Hernandez <scotthernandez@gmail.com> | 2016-08-18 09:10:39 -0400 |
---|---|---|
committer | Scott Hernandez <scotthernandez@gmail.com> | 2016-08-18 12:49:57 -0400 |
commit | f5821cbc18c7270a63634bb4080375d165464939 (patch) | |
tree | 3ad1ecf14c8f200cdc30a99010a01ae9f90e6df9 | |
parent | 74682194962bf695d03a8f7e120d998136c0c1f9 (diff) | |
download | mongo-f5821cbc18c7270a63634bb4080375d165464939.tar.gz |
SERVER-23476: re-enable resync tests
-rw-r--r-- | jstests/replsets/initialsync_with_write_load.js | 106 | ||||
-rw-r--r-- | jstests/replsets/read_committed_no_snapshots.js | 8 | ||||
-rw-r--r-- | jstests/replsets/resync.js | 8 | ||||
-rw-r--r-- | jstests/replsets/resync_with_write_load.js | 21 |
4 files changed, 114 insertions, 29 deletions
diff --git a/jstests/replsets/initialsync_with_write_load.js b/jstests/replsets/initialsync_with_write_load.js new file mode 100644 index 00000000000..adb51cd088b --- /dev/null +++ b/jstests/replsets/initialsync_with_write_load.js @@ -0,0 +1,106 @@ +/** + * This test creates replica set and then puts load on the primary with writes during + * the initial sync in order to verify that all phases of the initial sync work correctly. + * + * We cannot test each phase of the initial sync directly but by providing constant writes we can + * assume that each individual phase will have data to work with, and therefore be tested. + */ +var testName = "initialsync_with_write_load"; +var replTest = new ReplSetTest({name: testName, nodes: 3, oplogSize: 100}); +var nodes = replTest.nodeList(); + +var conns = replTest.startSet(); +var config = { + "_id": testName, + "members": [ + {"_id": 0, "host": nodes[0], priority: 4}, + {"_id": 1, "host": nodes[1]}, + {"_id": 2, "host": nodes[2]} + ] +}; +var r = replTest.initiate(config); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); +// Make sure we have a master +var master = replTest.getPrimary(); +var a_conn = conns[0]; +var b_conn = conns[1]; +a_conn.setSlaveOk(); +b_conn.setSlaveOk(); +var A = a_conn.getDB("test"); +var B = b_conn.getDB("test"); +var AID = replTest.getNodeId(a_conn); +var BID = replTest.getNodeId(b_conn); + +assert(master == conns[0], "conns[0] assumed to be master"); +assert(a_conn.host == master.host); + +// create an oplog entry with an insert +assert.writeOK(A.foo.insert({x: 1}, {writeConcern: {w: 1, wtimeout: 60000}})); +replTest.stop(BID); + +print("******************** starting load for 30 secs *********************"); +var work = function() { + print("starting loadgen"); + var start = new Date().getTime(); + + assert.writeOK(db.timeToStartTrigger.insert({_id: 1})); + + while (true) { + for (x = 0; x < 100; x++) { + db["a" + x].insert({a: x}); + } + + var runTime = (new Date().getTime() - start); + if (runTime > 30000) + break; + else if (runTime < 5000) // back-off more during first 2 seconds + sleep(50); + else + sleep(1); + } + print("finshing loadgen"); +}; +// insert enough that resync node has to go through oplog replay in each step +var loadGen = startParallelShell(work, replTest.ports[0]); + +// wait for document to appear to continue +assert.soon(function() { + try { + return 1 == master.getDB("test")["timeToStartTrigger"].find().itcount(); + } catch (e) { + print(e); + return false; + } +}, "waited too long for start trigger", 90 * 1000 /* 90 secs */); + +print("*************** STARTING node without data ***************"); +replTest.start(BID); +// check that it is up +assert.soon(function() { + try { + var result = b_conn.getDB("admin").runCommand({replSetGetStatus: 1}); + return true; + } catch (e) { + print(e); + return false; + } +}, "node didn't come up"); + +print("waiting for load generation to finish"); +loadGen(); + +// load must stop before we await replication. +replTest.awaitReplication(240 * 1000); + +// Make sure oplogs match +try { + replTest.ensureOplogsMatch(); +} catch (e) { + var aDBHash = A.runCommand("dbhash"); + var bDBHash = B.runCommand("dbhash"); + assert.eq( + aDBHash.md5, bDBHash.md5, "hashes differ: " + tojson(aDBHash) + " to " + tojson(bDBHash)); +} +replTest.stopSet(); + +print("*****test done******"); diff --git a/jstests/replsets/read_committed_no_snapshots.js b/jstests/replsets/read_committed_no_snapshots.js index cb187f3b4e5..ee7f329bdae 100644 --- a/jstests/replsets/read_committed_no_snapshots.js +++ b/jstests/replsets/read_committed_no_snapshots.js @@ -7,13 +7,9 @@ load("jstests/replsets/rslib.js"); // For reconfig and startSetIfSupportsReadMajority. -(function(doNotRun) { +(function() { "use strict"; - if (doNotRun) { - return; - } - // Set up a set and grab things for later. var name = "read_committed_no_snapshots"; var replTest = @@ -84,4 +80,4 @@ load("jstests/replsets/rslib.js"); // For reconfig and startSetIfSupportsReadMa // Ensure maxTimeMS times out while waiting for this snapshot assert.commandFailed(primary.getSiblingDB(name).foo.runCommand( 'find', {"readConcern": {"level": "majority"}, "maxTimeMS": 1000})); -})(true /* Disabled until SERVER-23476 re-enabled rsync command */); +})(); diff --git a/jstests/replsets/resync.js b/jstests/replsets/resync.js index d5a127e2877..265504d49c2 100644 --- a/jstests/replsets/resync.js +++ b/jstests/replsets/resync.js @@ -6,13 +6,9 @@ // RECOVERING state. A restarted node with an ephemeral storage engine will not have an oplog upon // restart, so will immediately resync. // @tags: [requires_persistence] -(function(doNotRun) { +(function() { "use strict"; - if (doNotRun) { - return; - } - var replTest = new ReplSetTest({name: 'resync', nodes: 3, oplogSize: 1}); var nodes = replTest.nodeList(); @@ -103,4 +99,4 @@ replTest.stopSet(15); jsTest.log("success"); -})(true /* Disabled until SERVER-23476 re-enabled rsync command */); +})(); diff --git a/jstests/replsets/resync_with_write_load.js b/jstests/replsets/resync_with_write_load.js index 1a782ffacbe..49dd74a1526 100644 --- a/jstests/replsets/resync_with_write_load.js +++ b/jstests/replsets/resync_with_write_load.js @@ -1,9 +1,7 @@ /** - * This test creates a 2 node replica set and then puts load on the primary with writes during - * the resync in order to verify that all phases of the initial sync work correctly. + * This test creates a replica set and writes during the resync call in order to verify + * that all phases of the resync/initial-sync process work correctly. * - * We cannot test each phase of the initial sync directly but by providing constant writes we can - * assume that each individual phase will have data to work with, and therefore tested. */ var testName = "resync_with_write_load"; var replTest = new ReplSetTest({name: testName, nodes: 3, oplogSize: 100}); @@ -36,7 +34,6 @@ assert(a_conn.host == master.host); // create an oplog entry with an insert assert.writeOK(A.foo.insert({x: 1}, {writeConcern: {w: 1, wtimeout: 60000}})); -replTest.stop(BID); print("******************** starting load for 30 secs *********************"); var work = function() { @@ -73,18 +70,8 @@ assert.soon(function() { } }, "waited too long for start trigger", 90 * 1000 /* 90 secs */); -print("*************** STARTING node without data ***************"); -replTest.start(BID); -// check that it is up -assert.soon(function() { - try { - var result = b_conn.getDB("admin").runCommand({replSetGetStatus: 1}); - return true; - } catch (e) { - print(e); - return false; - } -}, "node didn't come up"); +print("*************** issuing resync command ***************"); +assert.commandWorked(B.adminCommand("resync")); print("waiting for load generation to finish"); loadGen(); |