summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@mongodb.com>2020-01-11 01:02:39 +0000
committerevergreen <evergreen@mongodb.com>2020-01-11 01:02:39 +0000
commitdc711f478d75eeb00a33f8653334fd32616f4b2f (patch)
treecb6a7e4e0a1f8c87b614128678b6b9d3020afdb0 /jstests
parentb94da86ea3f85d4ba97ed14b0cef97d3df241902 (diff)
downloadmongo-dc711f478d75eeb00a33f8653334fd32616f4b2f.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.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/jstests/replsets/apply_batches_totalMillis.js b/jstests/replsets/apply_batches_totalMillis.js
index b8b2ee74f7c..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