diff options
author | Eric Milkie <milkie@10gen.com> | 2013-04-29 13:34:43 -0400 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2013-04-30 08:26:20 -0400 |
commit | 62ce2b986cc35eecf43a2e35d3361bbf30329a2e (patch) | |
tree | 0b296f1e0f0af4db834d96c102ea50a9ea20cc63 /jstests/replsets/stepdown3.js | |
parent | 60a1d258892f09572a0b6bb7507381f2086b1887 (diff) | |
download | mongo-62ce2b986cc35eecf43a2e35d3361bbf30329a2e.tar.gz |
SERVER-9417 assert if we stepDown while waiting to satisfy GLE
Diffstat (limited to 'jstests/replsets/stepdown3.js')
-rw-r--r-- | jstests/replsets/stepdown3.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/jstests/replsets/stepdown3.js b/jstests/replsets/stepdown3.js new file mode 100644 index 00000000000..ec3261b6637 --- /dev/null +++ b/jstests/replsets/stepdown3.js @@ -0,0 +1,39 @@ +// Test that GLE asserts when the primary steps down while we're waiting for w: + +var replTest = new ReplSetTest({ name: 'testSet', nodes: 2 }); +var nodes = replTest.startSet(); +replTest.initiate(); +var master = replTest.getMaster(); + +// do a write to allow stepping down of the primary; +// otherwise, the primary will refuse to step down +print("\ndo a write"); +master.getDB("test").foo.insert({x:1}); +replTest.awaitReplication(); + +// lock secondary, to pause replication +print("\nlock secondary"); +var locked = replTest.liveNodes.slaves[0]; +printjson( locked.getDB("admin").runCommand({fsync : 1, lock : 1}) ); + +// do a write +print("\ndo a write"); +master.getDB("test").foo.insert({x:2}); + +// step down the primary asyncronously +print("stepdown"); +var command = "sleep(4000); tojson(rs.stepDown());" +var mongoprogram = startMongoProgram( "mongo", "--quiet", "--port", "" + master.port, + "--eval", command ); + +print("getlasterror; should assert"); +var gleFunction = function() { + master.getDB("test").runCommand({getLastError : 1, w: 2 , wtimeout :30000 }) +}; +var result = assert.throws(gleFunction); +print("result of gle:"); +printjson(result); + +// unlock and shut down +printjson(locked.getDB("admin").$cmd.sys.unlock.findOne()); +replTest.stopSet(); |