summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorXueruiFa <xuerui.fa@mongodb.com>2020-09-25 17:35:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-30 20:31:01 +0000
commitb40d4b7eaf6239f83b0d6fbcf27de520bfd89df4 (patch)
tree55986393abde618c2b515db441a4f563ea294c38 /jstests
parentdd3d60643b760ee60d9445e4769fa68b35e0eba7 (diff)
downloadmongo-b40d4b7eaf6239f83b0d6fbcf27de520bfd89df4.tar.gz
SERVER-51057: Test that getMore metrics are incremented in server_status_metrics.js
(cherry picked from commit 2cb22c8caaf2be4025d93e5fb75afc8e4be3287e)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/server_status_metrics.js60
1 files changed, 10 insertions, 50 deletions
diff --git a/jstests/replsets/server_status_metrics.js b/jstests/replsets/server_status_metrics.js
index 5d0878dc519..226e9816dc1 100644
--- a/jstests/replsets/server_status_metrics.js
+++ b/jstests/replsets/server_status_metrics.js
@@ -91,34 +91,12 @@ var secondary = rt.getSecondary();
var primary = rt.getPrimary();
var testDB = primary.getDB("test");
-// Even though initial sync has finished, the oplog exhaust cursor used by the oplog fetcher during
-// initial sync could be still alive because it has not yet reached an interrupt point. Do a dummy
-// write to unblock any oplog getMore that is currently waiting for inserts. After this, the oplog
-// exhaust cursor used by initial sync should terminate itself because the connection was closed.
-// Wait until there is only 1 oplog exhaust cursor in progress to avoid races on the oplog metrics.
-assert.commandWorked(testDB.dummy.insert({a: "dummy"}));
-assert.soon(() => testDB.currentOp({"appName": "OplogFetcher", "command.collection": "oplog.rs"})
- .inprog.length === 1,
- `Timed out waiting for initial sync exhaust oplog stream to terminate: ${
- tojson(testDB.currentOp())}`);
-
-// Hang steady state replication oplog getMore before awaitData to avoid races on the oplog metrics
-// between primary and secondary.
-var hangOplogGetMore = configureFailPoint(
- primary, 'planExecutorHangBeforeShouldWaitForInserts', {namespace: "local.oplog.rs"});
-// Do a dummy write to unblock the oplog getMore that is currently waiting for inserts (if any)
-// after enabling the failpoint so the next oplog getMore that waits for inserts will block.
-assert.commandWorked(testDB.dummy.insert({a: "dummy"}));
-hangOplogGetMore.wait();
-
// Record the base oplogGetMoresProcessed on primary and the base oplog getmores on secondary.
const primaryBaseOplogGetMoresProcessedNum =
primary.getDB("test").serverStatus().metrics.repl.network.oplogGetMoresProcessed.num;
const secondaryBaseGetMoresNum =
secondary.getDB("test").serverStatus().metrics.repl.network.getmores.num;
-hangOplogGetMore.off();
-
assert.commandWorked(testDB.createCollection('a'));
assert.commandWorked(testDB.b.insert({}, {writeConcern: {w: 2}}));
@@ -143,38 +121,20 @@ assert.commandWorked(testDB.a.update({}, {$set: {d: new Date()}}, options));
testSecondaryMetrics(secondary, 2000, secondaryBaseOplogOpsApplied, secondaryBaseOplogOpsReceived);
-const localDB = primary.getDB("local");
-const oplogCursorId =
- assert.commandWorked(localDB.runCommand({"find": "oplog.rs", batchSize: 0})).cursor.id;
-// Do an external oplog getMore.
-assert.commandWorked(
- localDB.runCommand({"getMore": oplogCursorId, collection: "oplog.rs", batchSize: 1}));
-
-// Hang steady state replication oplog getMore before awaitData to avoid races on the oplog metrics
-// between primary and secondary.
-var hangOplogGetMore = configureFailPoint(
- primary, 'planExecutorHangBeforeShouldWaitForInserts', {namespace: "local.oplog.rs"});
-// Do a dummy write to unblock the oplog getMore that is currently waiting for inserts (if any)
-// after enabling the failpoint so the next oplog getMore that waits for inserts will block.
-assert.commandWorked(testDB.dummy.insert({a: "dummy"}));
-hangOplogGetMore.wait();
-
-// Test that the number of oplog getMore requested by the secondary since the beginning of the test
-// is equal to the number of oplog getMore processed by the primary since the beginning of the test.
-// This will also imply that the external oplog getMore done above is excluded from the
-// oplogGetMoresProcessed.num metrics.
+// Test that the number of oplog getMore requested by the secondary and processed by the primary has
+// increased since the start of the test.
const primaryOplogGetMoresProcessedNum =
primary.getDB("test").serverStatus().metrics.repl.network.oplogGetMoresProcessed.num;
const secondaryGetMoresNum =
secondary.getDB("test").serverStatus().metrics.repl.network.getmores.num;
-assert.eq(
- primaryOplogGetMoresProcessedNum - primaryBaseOplogGetMoresProcessedNum,
- secondaryGetMoresNum - secondaryBaseGetMoresNum,
- `primary and secondary oplog getmore count mismatch: primary ${
- primaryOplogGetMoresProcessedNum}:${primaryBaseOplogGetMoresProcessedNum}, secondary ${
- secondaryGetMoresNum}:${secondaryBaseGetMoresNum}`);
-
-hangOplogGetMore.off();
+assert.gt(primaryOplogGetMoresProcessedNum,
+ primaryBaseOplogGetMoresProcessedNum,
+ `primary getMores processed have not increased; final: ${
+ primaryOplogGetMoresProcessedNum}, base: ${primaryBaseOplogGetMoresProcessedNum}`);
+assert.gt(secondaryGetMoresNum,
+ secondaryBaseGetMoresNum,
+ `secondary getMores received have not increased; final: ${secondaryGetMoresNum}, base: ${
+ secondaryBaseGetMoresNum}`);
// Test getLastError.wtime and that it only records stats for w > 1, see SERVER-9005
var startMillis = testDB.serverStatus().metrics.getLastError.wtime.totalMillis;