diff options
Diffstat (limited to 'jstests/replsets/replset5.js')
-rw-r--r-- | jstests/replsets/replset5.js | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/jstests/replsets/replset5.js b/jstests/replsets/replset5.js index fe1761e..13ee5c9 100644 --- a/jstests/replsets/replset5.js +++ b/jstests/replsets/replset5.js @@ -23,15 +23,15 @@ doTest = function (signal) { master.getDB("barDB").bar.save({ a: 1 });
replTest.awaitReplication();
- // These writes should be replicated immediately
- master.getDB(testDB).foo.insert({ n: 1 });
- master.getDB(testDB).foo.insert({ n: 2 });
- master.getDB(testDB).foo.insert({ n: 3 });
-
- // *** NOTE ***: The default doesn't seem to be propogating. - // When I run getlasterror with no defaults, the slaves don't have the data:
- // These getlasterror commands can be run individually to verify this. - //master.getDB("admin").runCommand({ getlasterror: 1, w: 3, wtimeout: 20000 });
+ // These writes should be replicated immediately + var docNum = 5000; + for(var n=0; n<docNum; n++) { + master.getDB(testDB).foo.insert({ n: n });
+ } +
+ // If you want to test failure, just add values for w and wtimeout + // to the following command. This will override the default set above and + // prevent replication from happening in time for the count tests below. master.getDB("admin").runCommand({getlasterror: 1});
var slaves = replTest.liveNodes.slaves;
@@ -40,31 +40,15 @@ doTest = function (signal) { print("Testing slave counts");
- // These should all have 3 documents, but they don't always. - var master1count = master.getDB(testDB).foo.count(); - assert( master1count == 3, "Master has " + master1count + " of 3 documents!"); - var slave0count = slaves[0].getDB(testDB).foo.count(); - assert( slave0count == 3, "Slave 0 has " + slave0count + " of 3 documents!"); + assert( slave0count == docNum, "Slave 0 has " + slave0count + " of " + docNum + " documents!"); var slave1count = slaves[1].getDB(testDB).foo.count(); - assert( slave1count == 3, "Slave 1 has " + slave1count + " of 3 documents!"); + assert( slave1count == docNum, "Slave 1 has " + slave1count + " of " + docNum + " documents!"); - print("Testing slave 0");
+ var master1count = master.getDB(testDB).foo.count(); + assert( master1count == docNum, "Master has " + master1count + " of " + docNum + " documents!"); - var s0 = slaves[0].getDB(testDB).foo.find();
- assert(s0.next()['n']);
- assert(s0.next()['n']);
- assert(s0.next()['n']);
-
- print("Testing slave 1");
-
- var s1 = slaves[1].getDB(testDB).foo.find();
- assert(s1.next()['n']);
- assert(s1.next()['n']);
- assert(s1.next()['n']);
-
- // End test
replTest.stopSet(signal);
} |