summaryrefslogtreecommitdiff
path: root/jstests/replsets
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/replsets')
-rw-r--r--jstests/replsets/server_status_metrics.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/jstests/replsets/server_status_metrics.js b/jstests/replsets/server_status_metrics.js
index 59054f2172a..935b454d92a 100644
--- a/jstests/replsets/server_status_metrics.js
+++ b/jstests/replsets/server_status_metrics.js
@@ -1,7 +1,7 @@
/**
* Test replication metrics
*/
-function testSecondaryMetrics(secondary, opCount, offset) {
+function _testSecondaryMetricsHelper(secondary, opCount, offset) {
var ss = secondary.getDB("test").serverStatus();
printjson(ss.metrics);
@@ -31,6 +31,19 @@ function testSecondaryMetrics(secondary, opCount, offset) {
assert.eq(ss.metrics.repl.apply.ops, opCount + offset, "wrong number of applied ops");
}
+// Metrics are racy, e.g. repl.buffer.count could over- or under-reported briefly. Retry on error.
+function testSecondaryMetrics(secondary, opCount, baseOpsApplied, baseOpsReceived) {
+ assert.soon(() => {
+ try {
+ _testSecondaryMetricsHelper(secondary, opCount, baseOpsApplied, baseOpsReceived);
+ return true;
+ } catch (exc) {
+ jsTestLog(`Caught ${exc}, retrying`);
+ return false;
+ }
+ });
+}
+
var rt = new ReplSetTest({name: "server_status_metrics", nodes: 2, oplogSize: 100});
rt.startSet();
rt.initiate();