diff options
author | XueruiFa <xuerui.fa@mongodb.com> | 2020-07-10 15:19:26 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-10 18:49:44 +0000 |
commit | c1c0d2822ebc8f55a2b01e07b5bd324f299c8389 (patch) | |
tree | 9de5866d1bdb42b505e280e1ccf6ee2c00659fd2 | |
parent | 8296b34e798ac4d3879f2f2c8216ef3f17ced1cc (diff) | |
download | mongo-c1c0d2822ebc8f55a2b01e07b5bd324f299c8389.tar.gz |
SERVER-49426: Improve metrics robustness in sync source JS tests
-rw-r--r-- | jstests/replsets/nodes_eventually_sync_from_closer_data_center.js | 7 | ||||
-rw-r--r-- | jstests/replsets/nodes_in_primarys_datacenter_dont_sync_across_datacenters.js | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/jstests/replsets/nodes_eventually_sync_from_closer_data_center.js b/jstests/replsets/nodes_eventually_sync_from_closer_data_center.js index 1a198e1767d..6e9c5aaa432 100644 --- a/jstests/replsets/nodes_eventually_sync_from_closer_data_center.js +++ b/jstests/replsets/nodes_eventually_sync_from_closer_data_center.js @@ -50,9 +50,9 @@ assert.commandWorked(primaryColl.insert({"steady": "state"}, {writeConcern: {w: // Ensure we see the sync source progress logs. setLogVerbosity(rst.nodes, {"replication": {"verbosity": 2}}); -// Verify we haven't changed sync sources due to finding a significantly closer node yet. let serverStatus = assert.commandWorked(testNode.adminCommand({serverStatus: 1})).metrics.repl; -assert.eq(0, serverStatus.syncSource.numSyncSourceChangesDueToSignificantlyCloserNode); +const numSyncSourceChanges = + serverStatus.syncSource.numSyncSourceChangesDueToSignificantlyCloserNode; jsTestLog("Forcing sync sources for the secondaries"); forceSyncSource(rst, centralSecondary, primary); @@ -113,7 +113,8 @@ rst.awaitSyncSource(testNode, centralSecondary); // Verify that the metric was incremented correctly. serverStatus = assert.commandWorked(testNode.adminCommand({serverStatus: 1})).metrics.repl; -assert.eq(1, serverStatus.syncSource.numSyncSourceChangesDueToSignificantlyCloserNode); +assert.eq(numSyncSourceChanges + 1, + serverStatus.syncSource.numSyncSourceChangesDueToSignificantlyCloserNode); rst.stopSet(); })(); diff --git a/jstests/replsets/nodes_in_primarys_datacenter_dont_sync_across_datacenters.js b/jstests/replsets/nodes_in_primarys_datacenter_dont_sync_across_datacenters.js index c8b20212272..873bdd12728 100644 --- a/jstests/replsets/nodes_in_primarys_datacenter_dont_sync_across_datacenters.js +++ b/jstests/replsets/nodes_in_primarys_datacenter_dont_sync_across_datacenters.js @@ -50,9 +50,9 @@ assert.commandWorked(primaryColl.insert({"steady": "state"}, {writeConcern: {w: // Ensure we see the sync source progress logs. setLogVerbosity(rst.nodes, {"replication": {"verbosity": 2}}); -// Verify we haven't changed sync sources due to finding a significantly closer node yet. let serverStatus = assert.commandWorked(testNode.adminCommand({serverStatus: 1})).metrics.repl; -assert.eq(0, serverStatus.syncSource.numSyncSourceChangesDueToSignificantlyCloserNode); +const numSyncSourceChanges = + serverStatus.syncSource.numSyncSourceChangesDueToSignificantlyCloserNode; jsTestLog("Forcing sync sources for the secondaries"); const secondaryForceSyncSource = forceSyncSource(rst, secondary, primary); @@ -110,7 +110,8 @@ rst.awaitSyncSource(testNode, primary); // Verify that the metric was incremented correctly. serverStatus = assert.commandWorked(testNode.adminCommand({serverStatus: 1})).metrics.repl; -assert.eq(1, serverStatus.syncSource.numSyncSourceChangesDueToSignificantlyCloserNode); +assert.eq(numSyncSourceChanges + 1, + serverStatus.syncSource.numSyncSourceChangesDueToSignificantlyCloserNode); rst.stopSet(); })(); |