summaryrefslogtreecommitdiff
path: root/jstests/replsets
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2023-02-10 14:09:54 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-11 01:10:35 +0000
commit5cfb6fdfb529630eb0cf0d13ac4c71c5e9425b24 (patch)
tree4082a99372752e3ced65a9c3f0fb3e5a80297ea3 /jstests/replsets
parent7930e290348658f8592cabb8826e062e84a69a01 (diff)
downloadmongo-5cfb6fdfb529630eb0cf0d13ac4c71c5e9425b24.tar.gz
SERVER-73896 oplog_sampling.js logs and checks number of entries in oplog before restarting
Diffstat (limited to 'jstests/replsets')
-rw-r--r--jstests/replsets/oplog_sampling.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/jstests/replsets/oplog_sampling.js b/jstests/replsets/oplog_sampling.js
index 93bb6101c97..90c929d0368 100644
--- a/jstests/replsets/oplog_sampling.js
+++ b/jstests/replsets/oplog_sampling.js
@@ -34,6 +34,16 @@ for (let i = 0; i < maxOplogDocsForScanning + 1; i++) {
assert.commandWorked(coll.insert({m: 1 + i}));
}
+// Ensure we have enough oplog entries in the oplog to avoid scanning.
+// Check counts reported by aggregation and fast count.
+const numOplogEntries = replSet.getPrimary().getDB("local").oplog.rs.countDocuments({});
+jsTestLog('Number of oplog entries before restarting (aggregation): ' + numOplogEntries);
+assert.gte(numOplogEntries, maxOplogDocsForScanning);
+const numOplogEntriesFastCount = replSet.getPrimary().getDB("local").oplog.rs.count();
+jsTestLog('Number of oplog entries before restarting (fast count): ' + numOplogEntriesFastCount);
+assert.gte(numOplogEntriesFastCount, maxOplogDocsForScanning);
+assert.lte(numOplogEntriesFastCount, numOplogEntries);
+
// Restart replica set to load entries from the oplog for sampling.
replSet.stopSet(null /* signal */, true /* forRestart */);
replSet.startSet({restart: true});