summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavithra Vetriselvan <pavithra.vetriselvan@mongodb.com>2019-11-08 23:33:59 +0000
committerevergreen <evergreen@mongodb.com>2019-11-08 23:33:59 +0000
commita53094d8550957c635ce58d7e83dd6d2d64db73e (patch)
treebb29f933399babdfd18fc47f70221438d06a8f0b
parentc77a933373d8a0109d46f8c38842b8b9a47744c5 (diff)
downloadmongo-a53094d8550957c635ce58d7e83dd6d2d64db73e.tar.gz
SERVER-43972 initial_sync_capped_index.js waits for SECONDARY state before running validate
(cherry picked from commit 4cd46444fb5eae68fe40dbbbcbddc209c2eb494f)
-rw-r--r--jstests/replsets/initial_sync_capped_index.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/jstests/replsets/initial_sync_capped_index.js b/jstests/replsets/initial_sync_capped_index.js
index 66895864d03..34ed561e3ce 100644
--- a/jstests/replsets/initial_sync_capped_index.js
+++ b/jstests/replsets/initial_sync_capped_index.js
@@ -27,6 +27,7 @@
"use strict";
load("jstests/libs/check_log.js");
+ load("jstests/replsets/rslib.js"); // for waitForState
/**
* Overflow a capped collection 'coll' by continuously inserting a given document,
@@ -116,6 +117,10 @@
// Wait until initial sync completes.
replTest.awaitReplication();
+ // Before validating the secondary, confirm that it is in the SECONDARY state. Otherwise, the
+ // validate command will fail.
+ waitForState(secondary, ReplSetTest.State.SECONDARY);
+
// Make sure the indexes created during initial sync are valid.
var secondaryCappedColl = secondary.getDB(dbName)[cappedCollName];
var validate_result = secondaryCappedColl.validate(true);
@@ -123,4 +128,5 @@
"Index validation of '" + secondaryCappedColl.name + "' failed: " + tojson(validate_result);
assert(validate_result.valid, failMsg);
replTest.stopSet();
+
})();