diff options
Diffstat (limited to 'jstests/noPassthroughWithMongod/ttl_repl.js')
-rw-r--r-- | jstests/noPassthroughWithMongod/ttl_repl.js | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/jstests/noPassthroughWithMongod/ttl_repl.js b/jstests/noPassthroughWithMongod/ttl_repl.js index 1d1f3f001ee..ff15887b93b 100644 --- a/jstests/noPassthroughWithMongod/ttl_repl.js +++ b/jstests/noPassthroughWithMongod/ttl_repl.js @@ -16,73 +16,73 @@ var rt = new ReplSetTest({name: "ttl_repl", nodes: 2}); // setup set var nodes = rt.startSet(); rt.initiate(); -var master = rt.getPrimary(); +var primary = rt.getPrimary(); rt.awaitSecondaryNodes(); -var slave1 = rt._slaves[0]; +var secondary1 = rt.getSecondary(); // shortcuts -var masterdb = master.getDB('d'); -var slave1db = slave1.getDB('d'); -var mastercol = masterdb['c']; -var slave1col = slave1db['c']; +var primarydb = primary.getDB('d'); +var secondary1db = secondary1.getDB('d'); +var primarycol = primarydb['c']; +var secondary1col = secondary1db['c']; -mastercol.drop(); -masterdb.createCollection(mastercol.getName()); +primarycol.drop(); +primarydb.createCollection(primarycol.getName()); // create new collection. insert 24 docs, aged at one-hour intervalss now = (new Date()).getTime(); -var bulk = mastercol.initializeUnorderedBulkOp(); +var bulk = primarycol.initializeUnorderedBulkOp(); for (i = 0; i < 24; i++) { bulk.insert({x: new Date(now - (3600 * 1000 * i))}); } assert.commandWorked(bulk.execute()); rt.awaitReplication(); -assert.eq(24, mastercol.count(), "docs not inserted on primary"); -assert.eq(24, slave1col.count(), "docs not inserted on secondary"); +assert.eq(24, primarycol.count(), "docs not inserted on primary"); +assert.eq(24, secondary1col.count(), "docs not inserted on secondary"); print("Initial Stats:"); -print("Master:"); -printjson(mastercol.stats()); -print("Slave1:"); -printjson(slave1col.stats()); +print("Primary:"); +printjson(primarycol.stats()); +print("Secondary1:"); +printjson(secondary1col.stats()); // create TTL index, wait for TTL monitor to kick in, then check that // the correct number of docs age out var initialExpireAfterSeconds = 20000; assert.commandWorked( - mastercol.ensureIndex({x: 1}, {expireAfterSeconds: initialExpireAfterSeconds})); + primarycol.ensureIndex({x: 1}, {expireAfterSeconds: initialExpireAfterSeconds})); rt.awaitReplication(); sleep(70 * 1000); // TTL monitor runs every 60 seconds, so wait 70 print("Stats after waiting for TTL Monitor:"); -print("Master:"); -printjson(mastercol.stats()); -print("Slave1:"); -printjson(slave1col.stats()); +print("Primary:"); +printjson(primarycol.stats()); +print("Secondary1:"); +printjson(secondary1col.stats()); -assert.eq(6, mastercol.count(), "docs not deleted on primary"); -assert.eq(6, slave1col.count(), "docs not deleted on secondary"); +assert.eq(6, primarycol.count(), "docs not deleted on primary"); +assert.eq(6, secondary1col.count(), "docs not deleted on secondary"); /******** Part 2 ***************/ // add a new secondary, wait for it to fully join -var slave = rt.add(); +var secondary = rt.add(); var config = rt.getReplSetConfig(); config.version = rt.getReplSetConfigFromNode().version + 1; reconfig(rt, config); -var slave2col = slave.getDB('d')['c']; +var secondary2col = secondary.getDB('d')['c']; // check that the new secondary has the correct number of docs -print("New Slave stats:"); -printjson(slave2col.stats()); +print("New Secondary stats:"); +printjson(secondary2col.stats()); -assert.eq(6, slave2col.count(), "wrong number of docs on new secondary"); +assert.eq(6, secondary2col.count(), "wrong number of docs on new secondary"); /******* Part 3 *****************/ // Check that the collMod command successfully updates the expireAfterSeconds field -masterdb.runCommand({collMod: "c", index: {keyPattern: {x: 1}, expireAfterSeconds: 10000}}); +primarydb.runCommand({collMod: "c", index: {keyPattern: {x: 1}, expireAfterSeconds: 10000}}); rt.awaitReplication(); function getTTLTime(theCollection, theKey) { @@ -94,14 +94,14 @@ function getTTLTime(theCollection, theKey) { throw "not found"; } -printjson(masterdb.c.getIndexes()); -assert.eq(10000, getTTLTime(masterdb.c, {x: 1})); -assert.eq(10000, getTTLTime(slave1db.c, {x: 1})); +printjson(primarydb.c.getIndexes()); +assert.eq(10000, getTTLTime(primarydb.c, {x: 1})); +assert.eq(10000, getTTLTime(secondary1db.c, {x: 1})); // Verify the format of TTL collMod oplog entry. The old expiration time should be saved, // and index key patterns should be normalized to index names. -var masterOplog = master.getDB('local').oplog.rs.find().sort({$natural: 1}).toArray(); -var collModEntry = masterOplog.find(op => op.o.collMod); +var primaryOplog = primary.getDB('local').oplog.rs.find().sort({$natural: 1}).toArray(); +var collModEntry = primaryOplog.find(op => op.o.collMod); assert(collModEntry, "collMod entry was not present in the oplog."); assert.eq(initialExpireAfterSeconds, collModEntry.o2["expireAfterSeconds_old"]); |