2010-08-12 17:28:27 +02:00
|
|
|
// rs test getlasterrordefaults
|
|
|
|
|
2010-08-10 22:25:22 +02:00
|
|
|
doTest = function (signal) {
|
|
|
|
|
|
|
|
// Test getLastError defaults
|
|
|
|
var replTest = new ReplSetTest({ name: 'testSet', nodes: 3 });
|
|
|
|
|
|
|
|
var nodes = replTest.startSet();
|
|
|
|
|
|
|
|
// Initiate set with default for getLastError
|
|
|
|
var config = replTest.getReplSetConfig();
|
|
|
|
config.settings = {};
|
2010-08-10 23:44:38 +02:00
|
|
|
config.settings.getLastErrorDefaults = { 'w': 3, 'wtimeout': 20000 };
|
2010-08-10 22:25:22 +02:00
|
|
|
|
|
|
|
replTest.initiate(config);
|
|
|
|
|
|
|
|
//
|
|
|
|
var master = replTest.getMaster();
|
|
|
|
replTest.awaitSecondaryNodes();
|
|
|
|
var testDB = "foo";
|
|
|
|
|
|
|
|
// Initial replication
|
2010-08-10 23:44:38 +02:00
|
|
|
master.getDB("barDB").bar.save({ a: 1 });
|
2010-08-10 22:25:22 +02:00
|
|
|
replTest.awaitReplication();
|
|
|
|
|
2010-09-03 19:12:36 +02:00
|
|
|
// These writes should be replicated immediately
|
|
|
|
var docNum = 5000;
|
|
|
|
for(var n=0; n<docNum; n++) {
|
|
|
|
master.getDB(testDB).foo.insert({ n: n });
|
|
|
|
}
|
2010-08-10 22:25:22 +02:00
|
|
|
|
2010-09-03 20:57:36 +02:00
|
|
|
// 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.
|
2010-08-10 23:44:38 +02:00
|
|
|
master.getDB("admin").runCommand({getlasterror: 1});
|
2010-08-10 22:25:22 +02:00
|
|
|
|
2010-08-10 23:44:38 +02:00
|
|
|
var slaves = replTest.liveNodes.slaves;
|
2010-08-10 22:25:22 +02:00
|
|
|
slaves[0].setSlaveOk();
|
|
|
|
slaves[1].setSlaveOk();
|
|
|
|
|
2010-08-10 23:44:38 +02:00
|
|
|
print("Testing slave counts");
|
2010-08-10 22:25:22 +02:00
|
|
|
|
2010-08-10 23:44:38 +02:00
|
|
|
var slave0count = slaves[0].getDB(testDB).foo.count();
|
2010-09-03 19:12:36 +02:00
|
|
|
assert( slave0count == docNum, "Slave 0 has " + slave0count + " of " + docNum + " documents!");
|
2010-08-10 23:44:38 +02:00
|
|
|
|
|
|
|
var slave1count = slaves[1].getDB(testDB).foo.count();
|
2010-09-03 19:12:36 +02:00
|
|
|
assert( slave1count == docNum, "Slave 1 has " + slave1count + " of " + docNum + " documents!");
|
2010-08-10 23:44:38 +02:00
|
|
|
|
2010-09-03 19:12:36 +02:00
|
|
|
var master1count = master.getDB(testDB).foo.count();
|
|
|
|
assert( master1count == docNum, "Master has " + master1count + " of " + docNum + " documents!");
|
2010-08-10 23:44:38 +02:00
|
|
|
|
2010-08-10 22:25:22 +02:00
|
|
|
replTest.stopSet(signal);
|
2010-08-04 18:19:16 +02:00
|
|
|
}
|
|
|
|
|
2010-08-11 22:44:31 +02:00
|
|
|
doTest( 15 );
|
|
|
|
print("replset5.js success");
|