blob: d9c509740861a46eda2f3d414de69e9084b2e6d1 (
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
|
// Ensure that changes to the TTL sleep time are reflected immediately.
(function() {
"use strict";
load("jstests/libs/ttl_util.js");
let runner = MongoRunner.runMongod({setParameter: "ttlMonitorSleepSecs=1000"});
let db = runner.getDB("test");
let coll = db.ttl_collection;
coll.drop();
// Create TTL index.
assert.commandWorked(coll.createIndex({x: 1}, {expireAfterSeconds: 0}));
// Insert expired docs.
let now = new Date();
assert.commandWorked(coll.insert({x: now}));
assert.commandWorked(coll.insert({x: now}));
// TTL monitor should now be waiting for 1000 seconds. Modify it to 1 second.
assert.commandWorked(db.adminCommand({setParameter: 1, ttlMonitorSleepSecs: 1}));
// TTL Monitor should now perform passes every second. A timeout here would mean we fail the test.
TTLUtil.waitForPass(coll.getDB(), true, 20 * 1000);
assert.eq(coll.count(), 0, "We should get 0 documents after TTL monitor run");
MongoRunner.stopMongod(runner);
})();
|