2009-02-02 11:17:18 -05:00
|
|
|
// Test autoresync
|
|
|
|
|
|
|
|
|
|
var baseName = "jstests_repl3test";
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
soonCount = function(count) {
|
|
|
|
|
assert.soon(function() {
|
|
|
|
|
// print( "check count" );
|
|
|
|
|
// print( "count: " + s.getDB( baseName ).z.find().count() + ", expected: " +
|
|
|
|
|
// count );
|
|
|
|
|
return s.getDB(baseName).a.find().itcount() == count;
|
|
|
|
|
});
|
2016-02-04 12:30:30 -05:00
|
|
|
};
|
2009-03-17 17:20:08 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
doTest = function(signal) {
|
2011-07-22 13:36:24 -04:00
|
|
|
|
2016-02-04 12:30:30 -05:00
|
|
|
print("repl3.js doTest(" + signal + ")");
|
2011-07-22 13:36:24 -04:00
|
|
|
|
|
|
|
|
rt = new ReplTest("repl3tests");
|
|
|
|
|
|
|
|
|
|
m = rt.start(true);
|
|
|
|
|
s = rt.start(false);
|
|
|
|
|
|
2016-02-04 12:30:30 -05:00
|
|
|
am = m.getDB(baseName).a;
|
2011-07-22 13:36:24 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
am.save({_id: new ObjectId()});
|
2011-07-22 13:36:24 -04:00
|
|
|
soonCount(1);
|
|
|
|
|
rt.stop(false, signal);
|
|
|
|
|
|
|
|
|
|
big = new Array(2000).toString();
|
|
|
|
|
for (i = 0; i < 1000; ++i)
|
2016-03-09 12:17:50 -05:00
|
|
|
am.save({_id: new ObjectId(), i: i, b: big});
|
2011-07-22 13:36:24 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
s = rt.start(false, {autoresync: null}, true);
|
2011-07-22 13:36:24 -04:00
|
|
|
|
2009-03-12 13:08:16 -04:00
|
|
|
// after SyncException, mongod waits 10 secs.
|
2011-07-22 13:36:24 -04:00
|
|
|
sleep(15000);
|
|
|
|
|
|
2009-03-12 13:08:16 -04:00
|
|
|
// Need the 2 additional seconds timeout, since commands don't work on an 'allDead' node.
|
2011-07-22 13:36:24 -04:00
|
|
|
soonCount(1001);
|
2016-02-04 12:30:30 -05:00
|
|
|
as = s.getDB(baseName).a;
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(1, as.find({i: 0}).count());
|
|
|
|
|
assert.eq(1, as.find({i: 999}).count());
|
2011-07-22 13:36:24 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.commandFailed(s.getDB("admin").runCommand({"resync": 1}));
|
2009-04-01 19:51:41 -04:00
|
|
|
|
2009-12-09 17:38:48 -08:00
|
|
|
rt.stop();
|
2016-02-04 12:30:30 -05:00
|
|
|
};
|
2009-03-12 13:08:16 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
doTest(15); // SIGTERM
|
2016-03-17 14:41:31 -04:00
|
|
|
doTest(9); // SIGKILL
|
2011-07-22 13:36:24 -04:00
|
|
|
|
2016-02-04 12:30:30 -05:00
|
|
|
print("repl3.js OK");
|