summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Banker <kylebanker@gmail.com>2010-08-10 17:44:38 -0400
committerEliot Horowitz <eliot@10gen.com>2010-09-15 15:00:54 -0400
commitcfeb9c90fd34ce92f8e054245825aacf10b3c20f (patch)
treec2e97d47fed6bea642a52f66a66dd16f8fd7322e
parent5ecb7b97d214415387fed085a6b903b03fe91862 (diff)
downloadmongo-cfeb9c90fd34ce92f8e054245825aacf10b3c20f.tar.gz
SERVER-1598 rs getlasterror default test refinement
-rw-r--r--jstests/replsets/replset5.js52
1 files changed, 22 insertions, 30 deletions
diff --git a/jstests/replsets/replset5.js b/jstests/replsets/replset5.js
index 1196358046e..aa95484c227 100644
--- a/jstests/replsets/replset5.js
+++ b/jstests/replsets/replset5.js
@@ -8,7 +8,7 @@ doTest = function (signal) {
// Initiate set with default for getLastError
var config = replTest.getReplSetConfig();
config.settings = {};
- config.settings.getLastErrorDefaults = { 'w': 3, 'wtimeout': 10000 };
+ config.settings.getLastErrorDefaults = { 'w': 3, 'wtimeout': 20000 };
replTest.initiate(config);
@@ -18,59 +18,51 @@ doTest = function (signal) {
var testDB = "foo";
// Initial replication
- master.getDB(testDB).bar.save({ a: 1 });
+ master.getDB("barDB").bar.save({ a: 1 });
replTest.awaitReplication();
- var slaves = replTest.liveNodes.slaves;
// 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 slaves have the data when I run this:
- master.getDB("admin").runCommand({ getlasterror: 1, w: 3, wtimeout: 5000 });
-
- // But when I run the test with no defaults, they don't:
- // master.getDB("admin").runCommand({getlasterror: 1});
+ // *** 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 });
+ master.getDB("admin").runCommand({getlasterror: 1});
+ var slaves = replTest.liveNodes.slaves;
slaves[0].setSlaveOk();
slaves[1].setSlaveOk();
- print("Testing slave I");
+ 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!");
+
+ var slave1count = slaves[1].getDB(testDB).foo.count();
+ assert( slave1count == 3, "Slave 1 has " + slave1count + " of 3 documents!");
+
+ print("Testing slave 0");
+
var s0 = slaves[0].getDB(testDB).foo.find();
assert(s0.next()['n']);
assert(s0.next()['n']);
assert(s0.next()['n']);
- print("Testing slave II");
+ print("Testing slave 1");
var s1 = slaves[1].getDB(testDB).foo.find();
assert(s1.next()['n']);
assert(s1.next()['n']);
assert(s1.next()['n']);
- // Let's re-initialize the replica set with a new getlasterror
- var config = replTest.getReplSetConfig();
- var c = master.getDB("local")['system.replset'].findOne();
- printjson(c);
- config.settings = {};
- config.settings.getLastErrorDefaults = { 'w': 5, 'wtimeout': 1000000 };
- config.version = c.version + 1;
-
- print("Reinitiating");
- replTest.initiate(config, 'replSetReconfig');
-
- var master = replTest.getMaster();
-
- master.getDB(testDB).baz.insert({ n: 3 });
-
- // *** NOTE ***: This should never return given the timeout set above, but it returns right away.
- print("NOTE");
- master.getDB(testDB).runCommand({ getlasterror: 1, w: 5, wtimeout: 5000000 });
- print("NOTE2");
-
// End test
replTest.stopSet(signal);
}