summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@mongodb.com>2020-01-11 01:07:34 +0000
committerevergreen <evergreen@mongodb.com>2020-01-11 01:07:34 +0000
commit462cc0e91455e0c18f40722ab1dab3ea2bdca581 (patch)
treedbbf25333288f7d46794ce3b659d08bb5698e175 /jstests
parent4ae068133a41cec565e507006acd5f11a90564cf (diff)
downloadmongo-462cc0e91455e0c18f40722ab1dab3ea2bdca581.tar.gz
SERVER-34844 Relax timing requirements in apply_batches_totalMillis.js
(cherry picked from commit 604e8e63813f090b7565f0a1094f7bb63dae57fc)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/apply_batches_totalMillis.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/jstests/replsets/apply_batches_totalMillis.js b/jstests/replsets/apply_batches_totalMillis.js
index 9e093211cb6..d45374c0f6b 100644
--- a/jstests/replsets/apply_batches_totalMillis.js
+++ b/jstests/replsets/apply_batches_totalMillis.js
@@ -1,7 +1,9 @@
/**
* serverStatus.metrics.repl.apply.batches.totalMillis is a cumulative measure of how much time a
* node spends applying batches. This test checks that it includes the time spent waiting for
- * batches to finish, by comparing the time recorded after replicating a small and a large load.
+ * batches to finish by making sure that the timer is cumulative and monotonic. We cannot make
+ * any assumptions about how long batches actually take as that can vary enormously between
+ * machines and test runs.
*/
(function() {
@@ -37,27 +39,25 @@
// Perform an initial write on the system and ensure steady state.
assert.writeOK(coll.insert({init: 0}));
rst.awaitReplication();
+
let baseTime = getTotalMillis(secondary);
+ jsTestLog(`Base time recorded: ${baseTime}ms`);
// Introduce a small load and wait for it to be replicated.
performBulkInsert(coll, "small", 1000);
- // Record the time spent applying the small load.
+ // Record the time spent applying the small load. The timer should not move backwards.
let timeAfterSmall = getTotalMillis(secondary);
- let deltaSmall = timeAfterSmall - baseTime;
+ jsTestLog(`Time recorded after smaller batch: ${timeAfterSmall}ms`);
+ assert.gte(timeAfterSmall, baseTime);
// Insert a significantly larger load.
performBulkInsert(coll, "large", 20000);
// Record the time spent applying the large load.
let timeAfterLarge = getTotalMillis(secondary);
- let deltaLarge = timeAfterLarge - timeAfterSmall;
-
- jsTestLog(`Recorded deltas: {small: ${deltaSmall}ms, large: ${deltaLarge}ms}.`);
+ jsTestLog(`Time recorded after larger batch: ${timeAfterLarge}ms`);
+ assert.gte(timeAfterLarge, timeAfterSmall);
- // We should have recorded at least as much time on the second load as we did on the first.
- // This is a crude comparison that is only taken to check that the timer is used correctly.
- assert(deltaLarge >= deltaSmall, "Expected a higher net totalMillis for the larger load.");
rst.stopSet();
-
})(); \ No newline at end of file