summaryrefslogtreecommitdiff
path: root/jstests/replsets/replset3.js
diff options
context:
space:
mode:
authorKyle Banker <kylebanker@gmail.com>2010-07-26 15:08:04 -0400
committerKyle Banker <kylebanker@gmail.com>2010-07-26 15:08:04 -0400
commite94cc361ed088b5cb1f2cfe8ab30fc641c74639e (patch)
treeb28b1fd585eb56da95acb58dae464657d9683a7b /jstests/replsets/replset3.js
parent9d08a04e8e0faa13ac62c1cc1997822339fb6950 (diff)
downloadmongo-e94cc361ed088b5cb1f2cfe8ab30fc641c74639e.tar.gz
SERVER-1479 and replSet js test cleanup
Diffstat (limited to 'jstests/replsets/replset3.js')
-rw-r--r--jstests/replsets/replset3.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/jstests/replsets/replset3.js b/jstests/replsets/replset3.js
new file mode 100644
index 00000000000..cda84501c26
--- /dev/null
+++ b/jstests/replsets/replset3.js
@@ -0,0 +1,42 @@
+
+doTest = function( signal ) {
+
+ // Test replica set step down
+
+ // Replica set testing API
+ // Create a new replica set test. Specify set name and the number of nodes you want.
+ var replTest = new ReplSetTest( {name: 'testSet', nodes: 3} );
+
+ // call startSet() to start each mongod in the replica set
+ // this returns a list of nodes
+ var nodes = replTest.startSet();
+
+ // Call initiate() to send the replSetInitiate command
+ // This will wait for initiation
+ replTest.initiate();
+
+ // Get master node
+ var master = replTest.getMaster();
+
+ // Step down master
+ master.getDB("admin").runCommand({replSetStepDown: true});
+
+ try {
+ var new_master = replTest.getMaster();
+ }
+ catch( err ) {
+ throw( "Could not elect new master before timeout." );
+ }
+
+ assert( master != new_master, "Old master shouldn't be equal to new master." );
+
+ // Make sure that slaves are still up
+ var result = new_master.runCommand({replSetGetStatus: true});
+
+ assert( result['ok'] == 1, "Could not verify that slaves were still up:" + result );
+ printjson( result );
+
+ replTest.stopSet( 15 );
+}
+
+// doTest( 15 );