diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2014-03-20 11:29:32 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2014-03-20 11:29:35 -0400 |
commit | 7001e916bd78097b34812c263274eaeb5fd712cf (patch) | |
tree | 0c5a15c6ce8aafbf1aa8079a60595353e5490962 /jstests/replsets/auth_no_pri.js | |
parent | bd89a2c8040b17a7bd2c6d7e94199f26316bbd9b (diff) | |
download | mongo-7001e916bd78097b34812c263274eaeb5fd712cf.tar.gz |
SERVER-13295 Ensure that user and data documents reach all nodes in auth_no_pri.js.
In order to confirm that you can authenticate to and read data from a
non-primary node with auth enabled, the test set up phase must write some data
and wait for it to reach all nodes, before taking down the majority of them.
This patch achieves this by setting an appropriate write concern on the user and
data document inserts.
Diffstat (limited to 'jstests/replsets/auth_no_pri.js')
-rw-r--r-- | jstests/replsets/auth_no_pri.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/jstests/replsets/auth_no_pri.js b/jstests/replsets/auth_no_pri.js index 684b754d30f..fb9755da228 100644 --- a/jstests/replsets/auth_no_pri.js +++ b/jstests/replsets/auth_no_pri.js @@ -1,17 +1,18 @@ // Test that you can still authenticate a replset connection to a RS with no primary (SERVER-6665). -var rs = new ReplSetTest({"nodes" : 3, keyFile : "jstests/libs/key1"}); +(function () { +var NODE_COUNT = 3; +var rs = new ReplSetTest({"nodes" : NODE_COUNT, keyFile : "jstests/libs/key1"}); rs.startSet(); rs.initiate(); // Add user var master = rs.getMaster(); -master.getDB("admin").createUser({user: "admin", pwd: "pwd", roles: ["root"]}, {w: 'majority'}); +master.getDB("admin").createUser({user: "admin", pwd: "pwd", roles: ["root"]}, {w: NODE_COUNT}); // Can authenticate replset connection when whole set is up. var conn = new Mongo(rs.getURL()); assert(conn.getDB('admin').auth('admin', 'pwd')); -conn.getDB('admin').foo.insert({a:1}); -assert.gleSuccess(conn.getDB('admin')); +assert.writeOK(conn.getDB('admin').foo.insert({a:1}, { writeConcern: { w: NODE_COUNT } })); // Make sure there is no primary rs.stop(0); @@ -24,4 +25,5 @@ conn2.setSlaveOk(true); assert(conn2.getDB('admin').auth('admin', 'pwd')); assert.eq(1, conn2.getDB('admin').foo.findOne().a); -rs.stopSet();
\ No newline at end of file +rs.stopSet(); +}()); |