summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_impl_test.cpp
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2020-05-07 11:04:47 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-11 13:31:05 +0000
commitc5f84d128c27f0f603afeffb6717ee823d57606d (patch)
treee740cf740069bd6333438fc288ff7abc8fe79284 /src/mongo/db/repl/replication_coordinator_impl_test.cpp
parent087d6aeaaa10f401b22fa8c39be427150804aa2c (diff)
downloadmongo-c5f84d128c27f0f603afeffb6717ee823d57606d.tar.gz
SERVER-47832 ReplicationCoordinatorImpl::_makeIsMasterResponse() should check for quiesce mode
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl_test.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index be6f01d1a30..403dd3ab420 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -3318,6 +3318,52 @@ TEST_F(ReplCoordTest, IsMasterReturnsErrorOnEnteringQuiesceMode) {
getIsMasterThread.join();
}
+TEST_F(ReplCoordTest, IsMasterReturnsErrorOnEnteringQuiesceModeAfterWaitingTimesOut) {
+ init();
+ assertStartSuccess(BSON("_id"
+ << "mySet"
+ << "version" << 1 << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node1:12345"
+ << "_id" << 0))),
+ HostAndPort("node1", 12345));
+ ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
+
+ auto opCtx = makeOperationContext();
+ auto currentTopologyVersion = getTopoCoord().getTopologyVersion();
+
+ auto maxAwaitTime = Milliseconds(5000);
+ auto deadline = getNet()->now() + maxAwaitTime;
+
+ stdx::thread getIsMasterThread([&] {
+ ASSERT_THROWS_CODE(getReplCoord()->awaitIsMasterResponse(
+ opCtx.get(), {}, currentTopologyVersion, deadline),
+ AssertionException,
+ ErrorCodes::ShutdownInProgress);
+ });
+
+ auto failPoint = globalFailPointRegistry().find("hangAfterWaitingForTopologyChangeTimesOut");
+ auto timesEnteredFailPoint = failPoint->setMode(FailPoint::alwaysOn);
+ ON_BLOCK_EXIT([&] { failPoint->setMode(FailPoint::off, 0); });
+
+ getNet()->enterNetwork();
+ getNet()->advanceTime(deadline);
+ ASSERT_EQUALS(deadline, getNet()->now());
+ getNet()->exitNetwork();
+
+ // Ensure that waiting for a topology change timed out before entering quiesce mode.
+ failPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
+ ASSERT(getReplCoord()->enterQuiesceModeIfSecondary());
+ failPoint->setMode(FailPoint::off, 0);
+
+ // Advance the clock so that pauseWhileSet() will wake up.
+ getNet()->enterNetwork();
+ getNet()->advanceTime(getNet()->now() + Milliseconds(100));
+ getNet()->exitNetwork();
+
+ getIsMasterThread.join();
+}
+
TEST_F(ReplCoordTest, IsMasterReturnsErrorInQuiesceMode) {
init();
assertStartSuccess(BSON("_id"