diff options
author | Eric Milkie <milkie@10gen.com> | 2014-11-24 17:12:40 -0500 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2014-11-24 17:15:41 -0500 |
commit | fdb0c2b3b6d42da84acc2748662246e18ae8ecde (patch) | |
tree | 3ffc701ab11ec11d9ef9bdca8b47aa039331759e /jstests/replsets/auth2.js | |
parent | 0ad070c47135f205c638b47e217d46d7da9fd329 (diff) | |
download | mongo-fdb0c2b3b6d42da84acc2748662246e18ae8ecde.tar.gz |
SERVER-16306 fix primary to node 0 in auth2.js
Diffstat (limited to 'jstests/replsets/auth2.js')
-rw-r--r-- | jstests/replsets/auth2.js | 72 |
1 files changed, 20 insertions, 52 deletions
diff --git a/jstests/replsets/auth2.js b/jstests/replsets/auth2.js index 443eb9a971f..8dab1918d23 100644 --- a/jstests/replsets/auth2.js +++ b/jstests/replsets/auth2.js @@ -1,72 +1,40 @@ -var name = "rs_auth2"; -var port = allocatePorts(3); -var path = "jstests/libs/"; - -print("change permissions on #1 & #2"); -run("chmod", "600", path+"key1"); -run("chmod", "600", path+"key2"); - -var setupReplSet = function() { - print("start up rs"); - var rs = new ReplSetTest({"name" : name, "nodes" : 3, "startPort" : port[0]}); - rs.startSet(); - rs.initiate(); - - print("getting master"); - rs.getMaster(); - - print("getting secondaries"); - assert.soon(function() { - var result1 = rs.nodes[1].getDB("admin").runCommand({isMaster: 1}); - var result2 = rs.nodes[2].getDB("admin").runCommand({isMaster: 1}); - return result1.secondary && result2.secondary; - }); - - return rs; -}; var testInvalidAuthStates = function() { print("check that 0 is in recovering"); - assert.soon(function() { - try { - var result = m.adminCommand({isMaster: 1}); - printjson(result); - printjson(m.adminCommand("replSetGetStatus")); - printjson(rs.nodes[1].adminCommand("replSetGetStatus")); - printjson(rs.nodes[2].adminCommand("replSetGetStatus")); - return !result.ismaster && !result.secondary; - } - catch ( e ) { - print( e ); - } - }, "node0 isn't recovering"); + rs.waitForState(rs.nodes[0], rs.RECOVERING); print("shut down 1, 0 still in recovering."); rs.stop(1); sleep(5); - assert.soon(function() { - var result = m.adminCommand({isMaster: 1}); - printjson(m.adminCommand("replSetGetStatus")); - printjson(result); - return !result.ismaster && !result.secondary; - }, "node0 isn't recovering"); + rs.waitForState(rs.nodes[0], rs.RECOVERING); print("shut down 2, 0 becomes a secondary."); rs.stop(2); - assert.soon(function() { - var result = m.adminCommand({isMaster: 1}); - printjson(m.adminCommand("replSetGetStatus")); - printjson(result); - return result.secondary; - }, "node0 isn't secondary"); + rs.waitForState(rs.nodes[0], rs.SECONDARY); rs.restart(1, {"keyFile" : path+"key1"}); rs.restart(2, {"keyFile" : path+"key1"}); }; -var rs = setupReplSet(); +var name = "rs_auth2"; +var path = "jstests/libs/"; + +print("change permissions on #1 & #2"); +run("chmod", "600", path+"key1"); +run("chmod", "600", path+"key2"); + +var rs = new ReplSetTest({name: name, nodes: 3}); +var nodes = rs.startSet(); +var hostnames = rs.nodeList(); +rs.initiate({ "_id" : name, + "members" : [ + {"_id" : 0, "host" : hostnames[0], "priority" : 2}, + {"_id" : 1, "host" : hostnames[1]}, + {"_id" : 2, "host" : hostnames[2]} + ]}); + var master = rs.getMaster(); print("add an admin user"); |