From 73d13ccc6e1fce3204318bea0bb366c9e4a2cc70 Mon Sep 17 00:00:00 2001 From: Amirsaman Memaripour Date: Mon, 30 Mar 2020 12:02:04 -0400 Subject: [PATCH] SERVER-46922 Verify minimum number of reads for mirrored_reads.js --- jstests/noPassthrough/mirror_reads.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/jstests/noPassthrough/mirror_reads.js b/jstests/noPassthrough/mirror_reads.js index da65b8e19ef..2d7d89d848c 100644 --- a/jstests/noPassthrough/mirror_reads.js +++ b/jstests/noPassthrough/mirror_reads.js @@ -15,9 +15,12 @@ const kBurstCount = 1000; const kDbName = "mirrored_reads_test"; const kCollName = "test"; +function getMirroredReadsStats(rst) { + return rst.getPrimary().getDB(kDbName).serverStatus({mirroredReads: 1}).mirroredReads; +} + function sendAndCheckReads({rst, cmd, minRate, maxRate}) { - let startMirroredReads = - rst.getPrimary().getDB(kDbName).serverStatus({mirroredReads: 1}).mirroredReads; + let startMirroredReads = getMirroredReadsStats(rst); jsTestLog(`Sending ${kBurstCount} request burst of ${tojson(cmd)} to primary`); @@ -30,15 +33,13 @@ function sendAndCheckReads({rst, cmd, minRate, maxRate}) { // Verify that the reads have been observed on the primary { - let currentMirroredReads = - rst.getPrimary().getDB(kDbName).serverStatus({mirroredReads: 1}).mirroredReads; - assert.eq(startMirroredReads.seen + kBurstCount, currentMirroredReads.seen); + let currentMirroredReads = getMirroredReadsStats(rst); + assert.lte(startMirroredReads.seen + kBurstCount, currentMirroredReads.seen); } // Verify that the reads mirrored to the secondaries have responded assert.soon(() => { - let currentMirroredReads = - rst.getPrimary().getDB(kDbName).serverStatus({mirroredReads: 1}).mirroredReads; + let currentMirroredReads = getMirroredReadsStats(rst); let readsSeen = currentMirroredReads.seen - startMirroredReads.seen; let readsMirrored = currentMirroredReads.resolved - startMirroredReads.resolved;