2012-08-06 18:03:20 +02:00
|
|
|
/** This tests ensures that when a stand-alone server is started with something in
|
|
|
|
* local.system.replset, it doesn't start the TTL monitor (SERVER-6609). The test creates a
|
|
|
|
* dummy replset config & TTL collection, then restarts the member and ensures that it doesn't
|
|
|
|
* time out the docs in the TTL collection. Then it removes the "config" and
|
|
|
|
* restarts, ensuring that the TTL monitor deletes the docs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var runner;
|
|
|
|
var conn;
|
|
|
|
|
|
|
|
var primeSystemReplset = function() {
|
|
|
|
var port = allocatePorts(1)[0];
|
2013-09-26 03:59:42 +02:00
|
|
|
runner = new MongodRunner(port, MongoRunner.dataDir + "/jstests_slowNightly-ttl");
|
2012-08-06 18:03:20 +02:00
|
|
|
conn = runner.start();
|
|
|
|
var localDB = conn.getDB("local");
|
|
|
|
localDB.system.replset.insert({x:1});
|
|
|
|
|
|
|
|
print("create a TTL collection");
|
|
|
|
var testDB = conn.getDB("test");
|
2014-05-14 20:11:11 +02:00
|
|
|
assert.commandWorked(testDB.foo.ensureIndex({ x: 1 }, { expireAfterSeconds: 2 }));
|
2012-08-06 18:03:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
var restartWithConfig = function() {
|
|
|
|
stopMongod(runner.port(), 15);
|
|
|
|
conn = runner.start(true /* reuse data */);
|
|
|
|
testDB = conn.getDB("test");
|
|
|
|
var n = 100;
|
|
|
|
for (var i=0; i<n; i++) {
|
|
|
|
testDB.foo.insert({x : new Date()});
|
|
|
|
}
|
|
|
|
|
2014-11-12 16:07:29 +01:00
|
|
|
print("sleeping 65 seconds");
|
|
|
|
sleep(65000);
|
2012-08-06 18:03:20 +02:00
|
|
|
|
|
|
|
assert.eq(testDB.foo.count(), n);
|
|
|
|
};
|
|
|
|
|
|
|
|
var restartWithoutConfig = function() {
|
|
|
|
var localDB = conn.getDB("local");
|
2014-05-14 20:11:11 +02:00
|
|
|
assert.writeOK(localDB.system.replset.remove({}));
|
2012-08-06 18:03:20 +02:00
|
|
|
|
|
|
|
stopMongod(runner.port(), 15);
|
|
|
|
|
|
|
|
conn = runner.start(true /* reuse data */);
|
|
|
|
|
|
|
|
assert.soon(function() {
|
|
|
|
return conn.getDB("test").foo.count() < 100;
|
2014-11-12 16:07:29 +01:00
|
|
|
}, "never deleted", 65000);
|
2012-08-06 18:03:20 +02:00
|
|
|
|
|
|
|
stopMongod(runner.port(), 15);
|
|
|
|
};
|
|
|
|
|
|
|
|
print("Create a TTL collection and put doc in local.system.replset");
|
|
|
|
primeSystemReplset();
|
|
|
|
|
|
|
|
print("make sure TTL doesn't work when member is started with system.replset doc")
|
|
|
|
restartWithConfig();
|
|
|
|
|
|
|
|
print("remove system.replset entry & restart");
|
|
|
|
restartWithoutConfig();
|