diff options
Diffstat (limited to 'jstests/libs/clustered_collections')
-rw-r--r-- | jstests/libs/clustered_collections/clustered_capped_utils.js | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/jstests/libs/clustered_collections/clustered_capped_utils.js b/jstests/libs/clustered_collections/clustered_capped_utils.js index 32a397d6b3f..bbe9a71dde8 100644 --- a/jstests/libs/clustered_collections/clustered_capped_utils.js +++ b/jstests/libs/clustered_collections/clustered_capped_utils.js @@ -280,17 +280,21 @@ var ClusteredCappedUtils = class { const oneDayInSeconds = 60 * 60 * 24; const tenDaysInMilliseconds = 10 * oneDayInSeconds * 1000; const tenDaysAgo = new Date(new Date() - tenDaysInMilliseconds); + const earlierTenDaysAgo = new Date(tenDaysAgo.getTime - 1); - // Create clustered capped collection and insert a soon-to-be-expired document. + // Create clustered capped collection and insert soon-to-be-expired documents. assert.commandWorked(db.createCollection(collName, { clusteredIndex: {key: {_id: 1}, unique: true}, capped: true, expireAfterSeconds: oneDayInSeconds })); - assert.commandWorked( - db.getCollection(collName).insertOne({_id: tenDaysAgo, info: "10 days ago"})); + assert.commandWorked(db.getCollection(collName).insertMany([ + {_id: tenDaysAgo, info: "10 days ago"}, + {_id: earlierTenDaysAgo, info: "10 days ago"} + ])); + assert.eq(2, db.getCollection(collName).find().itcount()); - // Expire the document. + // Expire the documents. assert.commandWorked(db.adminCommand({setParameter: 1, ttlMonitorEnabled: true})); ClusteredCollectionUtil.waitForTTL(db); assert.eq(0, db.getCollection(collName).find().itcount()); @@ -306,19 +310,29 @@ var ClusteredCappedUtils = class { }))["featureFlagBatchMultiDeletes"]["value"]; if (featureFlagBatchMultiDeletes && isBatched) { + const ops = + db.getSiblingDB("local") + .oplog.rs + .find({ + op: "c", + ns: "admin.$cmd", + "o.applyOps": { + $elemMatch: + {op: "d", ns: ns, "o._id": {$in: [tenDaysAgo, earlierTenDaysAgo]}} + } + }) + .sort({$natural: -1}) + .limit(1) + .toArray(); + assert.eq(2, ops[0].o.applyOps.length); + } else { assert.eq(1, db.getSiblingDB("local") - .oplog.rs - .find({ - op: "c", - ns: "admin.$cmd", - "o.applyOps": {$elemMatch: {op: "d", ns: ns, "o._id": tenDaysAgo}} - }) + .oplog.rs.find({op: "d", ns: ns, "o._id": tenDaysAgo}) .itcount()); - } else { assert.eq(1, db.getSiblingDB("local") - .oplog.rs.find({op: "d", ns: ns, "o._id": tenDaysAgo}) + .oplog.rs.find({op: "d", ns: ns, "o._id": earlierTenDaysAgo}) .itcount()); } |