diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2015-09-28 05:47:57 -0400 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2015-10-01 08:00:10 -0400 |
commit | d789bca4c9fe76cd4d5375e66e281ed5a349e8fd (patch) | |
tree | d98b551b8e00ba0c320666f855f3c878414a990a /jstests/replsets | |
parent | 1cd101f5bdaae56d67ba7df527da5c6e9352620b (diff) | |
download | mongo-d789bca4c9fe76cd4d5375e66e281ed5a349e8fd.tar.gz |
SERVER-18498 New replica set configurations have protocolVersion=1 by default
This re-adds Siyuan's work from commits 19d2885ec51768ab73eee0c7239d8eadc0c51d8d and 362aac3937e3ff39ee995919a529297488537191.
Diffstat (limited to 'jstests/replsets')
-rw-r--r-- | jstests/replsets/bulk_api_wc.js | 2 | ||||
-rw-r--r-- | jstests/replsets/election_not_blocked.js | 3 | ||||
-rw-r--r-- | jstests/replsets/initial_sync1.js | 37 | ||||
-rw-r--r-- | jstests/replsets/initial_sync2.js | 22 | ||||
-rw-r--r-- | jstests/replsets/maintenance.js | 5 | ||||
-rw-r--r-- | jstests/replsets/oplog_note_cmd.js | 2 | ||||
-rw-r--r-- | jstests/replsets/protocol_version_upgrade_downgrade.js | 1 | ||||
-rw-r--r-- | jstests/replsets/read_after_optime.js | 8 | ||||
-rw-r--r-- | jstests/replsets/remove1.js | 27 | ||||
-rw-r--r-- | jstests/replsets/replset1.js | 3 | ||||
-rw-r--r-- | jstests/replsets/replsetadd_profile.js | 4 | ||||
-rw-r--r-- | jstests/replsets/tags.js | 3 |
12 files changed, 48 insertions, 69 deletions
diff --git a/jstests/replsets/bulk_api_wc.js b/jstests/replsets/bulk_api_wc.js index 05f28d573ab..86348943644 100644 --- a/jstests/replsets/bulk_api_wc.js +++ b/jstests/replsets/bulk_api_wc.js @@ -4,7 +4,7 @@ jsTest.log("Starting bulk api write concern tests..."); -// Start a single-node replica set with no journal +// Start a 2-node replica set with no journal //Allows testing immediate write concern failures and wc application failures var rst = new ReplSetTest({ nodes : 2 }); rst.startSet({ nojournal : "" }); diff --git a/jstests/replsets/election_not_blocked.js b/jstests/replsets/election_not_blocked.js index f15efa1635b..20c2ff7cc59 100644 --- a/jstests/replsets/election_not_blocked.js +++ b/jstests/replsets/election_not_blocked.js @@ -20,7 +20,8 @@ {_id: 1, host: host+":"+port[1]}, {_id: 2, host: host+":"+port[2], hidden: true, priority: 0}, ], - // vetos only exist in protocol version 0, so we use PV0 explicitly here. + // In PV1, a voter writes the last vote to disk before granting the vote, + // so it cannot vote while fsync locked in PV1. Use PV0 explicitly here. protocolVersion: 0}); replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); var master = replTest.getMaster(); diff --git a/jstests/replsets/initial_sync1.js b/jstests/replsets/initial_sync1.js index f55ae0b4910..a3ecaf5db68 100644 --- a/jstests/replsets/initial_sync1.js +++ b/jstests/replsets/initial_sync1.js @@ -20,7 +20,7 @@ print("1. Bring up set"); // SERVER-7455, this test is called from ssl/auth_x509.js var x509_options1; var x509_options2; -var replTest = new ReplSetTest({name: basename, +var replTest = new ReplSetTest({name: basename, nodes : {node0 : x509_options1, node1 : x509_options2}}); var conns = replTest.startSet(); @@ -61,7 +61,7 @@ var admin_s2 = slave2.getDB("admin"); var config = replTest.getReplSetConfig(); config.version = 2; -config.members.push({_id:2, host:hostname+":"+slave2.port}); +config.members.push({_id:2, host: slave2.host}); try { admin.runCommand({replSetReconfig:config}); } @@ -82,37 +82,20 @@ wait(function() { (config3 && config3.version == config.version); }); -wait(function() { - var status = admin_s2.runCommand({replSetGetStatus:1}); - printjson(status); - return status.members && - (status.members[2].state == 3 || status.members[2].state == 2); - }); +replTest.waitForState(slave2, [replTest.SECONDARY, replTest.RECOVERING], 60 * 1000); +print("7. Kill the secondary in the middle of syncing"); +replTest.stop(slave1); -print("7. Kill #2 in the middle of syncing"); -replTest.stop(1); - -print("8. Eventually it should become a secondary"); +print("8. Eventually the new node should become a secondary"); print("if initial sync has started, this will cause it to fail and sleep for 5 minutes"); -wait(function() { - var status = admin_s2.runCommand({replSetGetStatus:1}); - occasionally(function() { printjson(status); }); - return status.members[2].state == 2; - }, 350); +replTest.waitForState(slave2, replTest.SECONDARY, 60 * 1000); - -print("9. Bring #2 back up"); -replTest.start(1, {}, true); +print("9. Bring the secondary back up"); +replTest.start(slave1, {}, true); reconnect(slave1); -wait(function() { - var status = admin_s1.runCommand({replSetGetStatus:1}); - printjson(status); - return status.ok === 1 && status.members && status.members.length >= 2 && - (status.members[1].state === 2 || status.members[1].state === 1); - }); - +replTest.waitForState(slave1, [replTest.PRIMARY, replTest.SECONDARY], 60 * 1000); print("10. Insert some stuff"); master = replTest.getMaster(); diff --git a/jstests/replsets/initial_sync2.js b/jstests/replsets/initial_sync2.js index 1e519048fae..7888f7d3354 100644 --- a/jstests/replsets/initial_sync2.js +++ b/jstests/replsets/initial_sync2.js @@ -147,27 +147,7 @@ for (var i=0; i<10000; i++) { print("12. Everyone happy eventually"); -// if 3 is master... -if (master+"" != origMaster+"") { - print("3 is master"); - slave2 = origMaster; -} - -wait(function() { - var op1 = getLatestOp(master); - var op2 = getLatestOp(slave1); - var op3 = getLatestOp(slave2); - - occasionally(function() { - print("latest ops:"); - printjson(op1); - printjson(op2); - printjson(op3); - }); - - return friendlyEqual(getLatestOp(master), getLatestOp(slave1)) && - friendlyEqual(getLatestOp(master), getLatestOp(slave2)); - }); +replTest.awaitReplication(2 * 60 * 1000); replTest.stopSet(); }; diff --git a/jstests/replsets/maintenance.js b/jstests/replsets/maintenance.js index 506e885e0c4..34c0e83993b 100644 --- a/jstests/replsets/maintenance.js +++ b/jstests/replsets/maintenance.js @@ -2,7 +2,10 @@ var replTest = new ReplSetTest( {name: 'unicomplex', nodes: 2} ); var conns = replTest.startSet({ verbose: 1 }); -replTest.initiate(); +var config = replTest.getReplSetConfig(); +config.members[0].priority = 2; +replTest.initiate(config); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60000); // Make sure we have a master var master = replTest.getMaster(); diff --git a/jstests/replsets/oplog_note_cmd.js b/jstests/replsets/oplog_note_cmd.js index 25e60e0a94c..4a501211cd6 100644 --- a/jstests/replsets/oplog_note_cmd.js +++ b/jstests/replsets/oplog_note_cmd.js @@ -12,7 +12,7 @@ db.foo.insert({a:1}); var statusBefore = db.runCommand({replSetGetStatus: 1}); assert.commandWorked(db.runCommand({appendOplogNote: 1, data: {a: 1}})); var statusAfter = db.runCommand({replSetGetStatus: 1}); -assert.lt(statusBefore.members[0].optime, statusAfter.members[0].optime); +assert.lt(statusBefore.members[0].optime.ts, statusAfter.members[0].optime.ts); // Make sure note written successfully var op = db.getSiblingDB('local').oplog.rs.find().sort({$natural: -1}).limit(1).next(); diff --git a/jstests/replsets/protocol_version_upgrade_downgrade.js b/jstests/replsets/protocol_version_upgrade_downgrade.js index d599492ec1d..a5906d2e88d 100644 --- a/jstests/replsets/protocol_version_upgrade_downgrade.js +++ b/jstests/replsets/protocol_version_upgrade_downgrade.js @@ -37,6 +37,7 @@ assert.writeOK(primaryColl.bar.insert({x: 1}, {writeConcern: {w: 3}})); // Check optime format in protocol version 0, which is a Timestamp. var res = primary.adminCommand({replSetGetStatus: 1}); assert.commandWorked(res); +// Check the optime is a Timestamp, not an OpTime { ts: Timestamp, t: int } assert.eq(res.members[0].optime.ts, null); // diff --git a/jstests/replsets/read_after_optime.js b/jstests/replsets/read_after_optime.js index cb19940ee05..c73ab4574a8 100644 --- a/jstests/replsets/read_after_optime.js +++ b/jstests/replsets/read_after_optime.js @@ -14,15 +14,15 @@ var runTest = function(testDB, primaryConn) { var localDB = primaryConn.getDB('local'); - var oplogTS = localDB.oplog.rs.find().sort({ $natural: -1 }).limit(1).next().ts; - var twoSecTS = new Timestamp(oplogTS.getTime() + 2, 0); + var oplogTS = localDB.oplog.rs.find().sort({ $natural: -1 }).limit(1).next(); + var twoSecTS = new Timestamp(oplogTS.ts.getTime() + 2, 0); // Test timeout with maxTimeMS var res = assert.commandFailed(testDB.runCommand({ find: 'user', filter: { x: 1 }, readConcern: { - afterOpTime: { ts: twoSecTS, t: 0 } + afterOpTime: { ts: twoSecTS, t: oplogTS.t } }, maxTimeMS: 1000 })); @@ -40,7 +40,7 @@ var runTest = function(testDB, primaryConn) { find: 'user', filter: { x: 1 }, readConcern: { - afterOpTime: { ts: twoSecTS, t: 0 }, + afterOpTime: { ts: twoSecTS, t: oplogTS.t }, maxTimeMS: 10 * 1000 } })); diff --git a/jstests/replsets/remove1.js b/jstests/replsets/remove1.js index ca2055bf566..b70de7c257d 100644 --- a/jstests/replsets/remove1.js +++ b/jstests/replsets/remove1.js @@ -17,6 +17,7 @@ var replTest = new ReplSetTest( {name: name, nodes: 2} ); var nodes = replTest.startSet(); replTest.initiate(); var master = replTest.getMaster(); +var secondary = replTest.getSecondary(); print("Initial sync"); master.getDB("foo").bar.baz.insert({x:1}); @@ -25,11 +26,17 @@ replTest.awaitReplication(); print("Remove secondary"); var config = replTest.getReplSetConfig(); - -config.members.pop(); +for (var i = 0; i < config.members.length; i++) { + if (config.members[i].host == secondary.host) { + config.members.splice(i, 1); + break; + } +}; config.version = 2; -assert.eq(replTest.nodes[1].getDB("admin").runCommand({ping:1}).ok, 1, "we are connected to node[1]"); +assert.eq(secondary.getDB("admin").runCommand({ping:1}).ok, + 1, + "we should be connected to the secondary"); try { master.getDB("admin").runCommand({replSetReconfig:config}); @@ -38,11 +45,11 @@ catch(e) { print(e); } -// This test that nodes[1] disconnects us when it picks up the new config +// This tests that the secondary disconnects us when it picks up the new config. assert.soon( function() { try { - replTest.nodes[1].getDB("admin").runCommand({ping:1}); + secondary.getDB("admin").runCommand({ping:1}); } catch (e) { return true; } @@ -50,9 +57,9 @@ assert.soon( } ); -// Now we should successfully reconnect to nodes[1] -assert.eq(replTest.nodes[1].getDB("admin").runCommand({ping:1}).ok, 1, - "we are connected to node[1]"); +// Now we should successfully reconnect to the secondary. +assert.eq(secondary.getDB("admin").runCommand({ping:1}).ok, 1, + "we aren't connected to the secondary"); reconnect(master); @@ -62,7 +69,7 @@ assert.soon(function() { }); print("Add it back as a secondary"); -config.members.push({_id:1, host : host+":"+replTest.getPort(1)}); +config.members.push({_id:2, host : secondary.host}); config.version = 3; printjson(config); wait(function() { @@ -105,7 +112,7 @@ wait(function() { } , "wait2" ); print("reconfig with minority"); -replTest.stop(1); +replTest.stop(secondary); assert.soon(function() { try { diff --git a/jstests/replsets/replset1.js b/jstests/replsets/replset1.js index 4688b8d7e04..6a4b1063de9 100644 --- a/jstests/replsets/replset1.js +++ b/jstests/replsets/replset1.js @@ -132,7 +132,8 @@ var doTest = function( signal ) { printjson(result); var lastOp = result.lastOp; var lastOplogOp = master.getDB("local").oplog.rs.find().sort({$natural : -1}).limit(1).next(); - assert.eq(lastOplogOp['ts'], lastOp); + assert.eq(lastOplogOp['ts'], lastOp['ts']); + assert.eq(lastOplogOp['t'], lastOp['t']); ts.forEach( function(z){ assert.eq( 2 , z.getIndexKeys().length , "A " + z.getMongo() ); } ); diff --git a/jstests/replsets/replsetadd_profile.js b/jstests/replsets/replsetadd_profile.js index d0cc27bf7ec..45267f9ed4f 100644 --- a/jstests/replsets/replsetadd_profile.js +++ b/jstests/replsets/replsetadd_profile.js @@ -9,8 +9,7 @@ var collectionName = 'jstests_replsetadd_profile'; var replTest = new ReplSetTest({name: 'ReplSetAddProfileTestSet', - nodes: [{profile: 2}], - host: "localhost"}); + nodes: [{profile: 2}]}); replTest.startSet(); replTest.initiate(); var master = replTest.getMaster(); @@ -21,6 +20,7 @@ masterCollection.save({a: 1}); var newNode = replTest.add(); replTest.reInitiate(); +replTest.waitForState(replTest.nodes[1], replTest.SECONDARY, 60 * 1000); // Allow documents to propagate to new replica set member. replTest.awaitReplication(); diff --git a/jstests/replsets/tags.js b/jstests/replsets/tags.js index 2a1f77608a6..f58e255b53a 100644 --- a/jstests/replsets/tags.js +++ b/jstests/replsets/tags.js @@ -164,6 +164,9 @@ replTest.partition(2, 0); replTest.partition(2, 1); replTest.stop(2); +// Node 1 with slightly higher priority will take over. +replTest.waitForState(nodes[1], replTest.PRIMARY, 60 * 1000); + myprint("1 must become primary here because otherwise the other members will take too long " + "timing out their old sync threads"); master = replTest.getMaster(); |