summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@mongodb.com>2020-01-11 01:05:34 +0000
committerevergreen <evergreen@mongodb.com>2020-01-11 01:05:34 +0000
commitcc283da7cdac667c1941b40d1fb155dbd15afe20 (patch)
treec6b6fc999d5a3189fe831cfa742ee0a58af14ae5
parent205998b8e452cc18e27b9226d5b38f2fccaa02b8 (diff)
downloadmongo-cc283da7cdac667c1941b40d1fb155dbd15afe20.tar.gz
SERVER-34844 Relax timing requirements in apply_batches_totalMillis.js
(cherry picked from commit 604e8e63813f090b7565f0a1094f7bb63dae57fc)
-rw-r--r--jstests/replsets/apply_batches_totalMillis.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/jstests/replsets/apply_batches_totalMillis.js b/jstests/replsets/apply_batches_totalMillis.js
index fd8b2872065..7808eb4c869 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,26 +39,25 @@ let coll = primary.getDB(name)["foo"];
// 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