summaryrefslogtreecommitdiff
path: root/jstests/replsets/replset1.js
diff options
context:
space:
mode:
authorKyle Banker <kylebanker@gmail.com>2010-07-30 16:22:54 -0400
committerKyle Banker <kylebanker@gmail.com>2010-07-30 16:41:42 -0400
commitf4578edbe534d2f2c27e9d5dc7f840752881570c (patch)
treec02e67987e68fbc585dd7a585503b157e406605d /jstests/replsets/replset1.js
parent39a3e9f4a1b209014d4384b8a74f79d37fed1708 (diff)
downloadmongo-f4578edbe534d2f2c27e9d5dc7f840752881570c.tar.gz
SERVER-1463 failing count even when oplog is up to date
Diffstat (limited to 'jstests/replsets/replset1.js')
-rw-r--r--jstests/replsets/replset1.js39
1 files changed, 37 insertions, 2 deletions
diff --git a/jstests/replsets/replset1.js b/jstests/replsets/replset1.js
index bc6c20e874a..61f3d99d549 100644
--- a/jstests/replsets/replset1.js
+++ b/jstests/replsets/replset1.js
@@ -59,7 +59,6 @@ doTest = function( signal ) {
assert( master_id != new_master_id, "Old master shouldn't be equal to new master." );
-
{
// this may fail since it has to reconnect
try {
@@ -74,8 +73,44 @@ doTest = function( signal ) {
// Here's how to restart a node:
replTest.restart( master_id );
+ // Now let's write some documents to the new master
+ for(var i=0; i<1000; i++) {
+ new_master.getDB("bar").bar.save({a: i});
+ }
+ new_master.getDB("admin").runCommand({getlasterror: 1});
+
+ // Here's how to restart the old master node:
+ slave = replTest.restart( master_id );
+
+ // Now, let's make sure that the old master comes up as a slave
+ assert.soon(function() {
+ var res = slave.getDB("admin").runCommand({ismaster: 1});
+ printjson(res);
+ return res['ok'] == 1 && res['ismaster'] == false;
+ });
+
+ // And we need to make sure that the replset comes back up
+ assert.soon(function() {
+ var res = new_master.getDB("admin").runCommand({replSetGetStatus: 1});
+ printjson( res );
+ return res.myState == 1;
+ });
+
+ // And that both slave nodes have all the updates
+ new_master = replTest.getMaster();
+ replTest.awaitReplication();
+
+ slaves = replTest.liveNodes.slaves;
+ assert( slaves.length == 2, "Expected 2 slaves but length was " + slaves.length );
+ slaves.forEach(function(slave) {
+ slave.setSlaveOk();
+ var count = slave.getDB("bar").runCommand({count: "bar"});
+ printjson( count );
+ assert( count.n == 1000 , slave + " expected 1000 but count was " + count.n);
+ });
+
// Shut down the set and finish the test.
replTest.stopSet( signal );
}
-doTest( 15 );
+// doTest( 15 );