2014-05-14 20:11:11 +02:00
|
|
|
/**
|
|
|
|
* Basic gle testing for master/slave environment. Write command version also
|
|
|
|
* available at jstests/repl.
|
|
|
|
*/
|
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
var rt = new ReplTest("block1");
|
2014-05-14 20:11:11 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
var m = rt.start(true);
|
|
|
|
var s = rt.start(false);
|
2014-05-14 20:11:11 +02:00
|
|
|
|
|
|
|
if (m.writeMode() == 'commands') {
|
|
|
|
jsTest.log('Skipping test since commands mode is already tested in repl/');
|
2016-03-09 18:17:50 +01:00
|
|
|
} else {
|
|
|
|
function setup() {
|
|
|
|
dbm = m.getDB("foo");
|
|
|
|
dbs = s.getDB("foo");
|
2014-05-14 20:11:11 +02:00
|
|
|
|
|
|
|
tm = dbm.bar;
|
|
|
|
ts = dbs.bar;
|
|
|
|
}
|
|
|
|
setup();
|
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
function check(msg) {
|
|
|
|
assert.eq(tm.count(), ts.count(), "check: " + msg);
|
2014-05-14 20:11:11 +02:00
|
|
|
}
|
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
function worked(w, wtimeout) {
|
|
|
|
var gle = dbm.getLastError(w, wtimeout);
|
2014-05-14 20:11:11 +02:00
|
|
|
if (gle != null) {
|
|
|
|
printjson(gle);
|
|
|
|
}
|
|
|
|
return gle == null;
|
|
|
|
}
|
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
check("A");
|
2014-05-14 20:11:11 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
tm.save({x: 1});
|
|
|
|
assert(worked(2), "B");
|
2014-05-14 20:11:11 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
tm.save({x: 2});
|
|
|
|
assert(worked(2, 3000), "C");
|
2014-05-14 20:11:11 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
rt.stop(false);
|
|
|
|
tm.save({x: 3});
|
|
|
|
assert.eq(3, tm.count(), "D1");
|
|
|
|
assert(!worked(2, 3000), "D2");
|
2014-05-14 20:11:11 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
s = rt.start(false);
|
2014-05-14 20:11:11 +02:00
|
|
|
setup();
|
2016-03-09 18:17:50 +01:00
|
|
|
assert(worked(2, 30000), "E");
|
2014-05-14 20:11:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
rt.stop();
|