blob: 97507ea0f19ded995892882d36c82ccb47ed9c53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/** 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];
runner = new MongodRunner(port, "/data/db/jstests_slowNightly-ttl");
conn = runner.start();
var localDB = conn.getDB("local");
localDB.system.replset.insert({x:1});
print("create a TTL collection");
var testDB = conn.getDB("test");
testDB.foo.ensureIndex({x:1}, {expireAfterSeconds : 2});
testDB.getLastError();
};
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()});
}
print("sleeping 60 seconds");
sleep(60000);
assert.eq(testDB.foo.count(), n);
};
var restartWithoutConfig = function() {
var localDB = conn.getDB("local");
localDB.system.replset.remove();
localDB.getLastError();
stopMongod(runner.port(), 15);
conn = runner.start(true /* reuse data */);
assert.soon(function() {
return conn.getDB("test").foo.count() < 100;
}, "never deleted", 60000);
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();
|