diff options
author | Eric Milkie <milkie@10gen.com> | 2015-09-28 14:21:40 -0400 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2015-10-08 05:27:10 -0400 |
commit | 5c4b2cb0f86431bd773b27c247044209af1e6751 (patch) | |
tree | 8e76c21c283070b641e1b9bb4aa09d2f8d1667be /jstests | |
parent | 0eccf941d808bdf0b2dcf73398ca69e03f0b3065 (diff) | |
download | mongo-5c4b2cb0f86431bd773b27c247044209af1e6751.tar.gz |
SERVER-20649 add slaveOk read test coverage for drain mode
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/replsets/drain.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/jstests/replsets/drain.js b/jstests/replsets/drain.js index 127b5835999..059f3fc4188 100644 --- a/jstests/replsets/drain.js +++ b/jstests/replsets/drain.js @@ -4,7 +4,8 @@ // 3. Insert data to ensure the SECONDARY has ops to apply in its queue. // 4. Shutdown PRIMARY. // 5. Wait for SECONDARY to become PRIMARY. -// 6. Confirm that the new PRIMARY cannot accept writes until its queue is empty. +// 6. Confirm that the new PRIMARY cannot accept writes while in drain mode. +// 6a. Confirm that the new PRIMARY cannot accept reads while in drain mode. // 7. Enable applying ops. // 8. Ensure the ops in queue are applied and that the PRIMARY begins to accept writes as usual. @@ -62,6 +63,21 @@ assert.writeError(secondary.getDB("foo").flag.insert({sentinel:2})); assert(!secondary.getDB("admin").runCommand({"isMaster": 1}).ismaster); + // Ensure new primary is not yet readable without slaveOk bit. + secondary.slaveOk = false; + jsTestLog('New primary should not be readable yet, without slaveOk bit'); + var res = secondary.getDB("foo").runCommand({find: "foo"}); + assert.commandFailed(res); + assert.eq(ErrorCodes.NotMasterNoSlaveOkCode, res.code, + "find failed with unexpected error code: " + tojson(res)); + // Nor should it be readable with the slaveOk bit. + secondary.slaveOk = true; + res = secondary.getDB("foo").runCommand({find: "foo"}); + assert.commandFailed(res); + assert.eq(ErrorCodes.NotMasterOrSecondaryCode, res.code, + "find failed with unexpected error code: " + tojson(res)); + secondary.slaveOk = false; + // Allow draining to complete jsTestLog('Enabling fail point on new primary to allow draining to complete'); assert.commandWorked( |