-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #810 from Expensify/rafe-bedrock-healthcheck-132972
Respond 200 to STATUS_HANDLING_COMMANDS if LEADING or STANDINGDOWN
- Loading branch information
Showing
3 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "../BedrockClusterTester.h" | ||
|
||
struct StatusHandlingCommandsTest : tpunit::TestFixture { | ||
StatusHandlingCommandsTest() | ||
: tpunit::TestFixture("StatusHandlingCommandsTest", | ||
BEFORE_CLASS(StatusHandlingCommandsTest::setup), | ||
AFTER_CLASS(StatusHandlingCommandsTest::teardown), | ||
TEST(StatusHandlingCommandsTest::test)) { } | ||
|
||
BedrockClusterTester* tester; | ||
|
||
void setup () { | ||
tester = new BedrockClusterTester(); | ||
} | ||
|
||
void teardown() { | ||
delete tester; | ||
} | ||
|
||
void test() { | ||
vector<string> results(3); | ||
BedrockTester& leader = tester->getTester(0); | ||
BedrockTester& follower = tester->getTester(1); | ||
|
||
thread healthCheckThread([this, &results, &follower](){ | ||
SData cmd("GET /status/handlingCommands HTTP/1.1"); | ||
string result; | ||
bool foundLeader = false; | ||
bool foundFollower = false; | ||
bool foundStandingdown = false; | ||
chrono::steady_clock::time_point start = chrono::steady_clock::now(); | ||
|
||
while (chrono::steady_clock::now() < start + 60s && (!foundLeader || !foundFollower || !foundStandingdown)) { | ||
result = follower.executeWaitMultipleData({cmd}, 1, false)[0].methodLine; | ||
if (result == "HTTP/1.1 200 LEADING") { | ||
results[0] = result; | ||
foundLeader = true; | ||
} else if (result == "HTTP/1.1 200 FOLLOWING") { | ||
results[1] = result; | ||
foundFollower = true; | ||
} else if (result == "HTTP/1.1 200 STANDINGDOWN") { | ||
results[2] = result; | ||
foundStandingdown = true; | ||
} | ||
} | ||
}); | ||
|
||
leader.stopServer(); | ||
|
||
// Execute a slow query while the follower is leading so when the | ||
// leader is brought back up, it will be STANDINGDOWN until it finishes | ||
thread slowQueryThread([this, &follower](){ | ||
SData slow("slowquery"); | ||
slow["processTimeout"] = "5000"; // 5s | ||
follower.executeWaitVerifyContent(slow, "555 Timeout peeking command"); | ||
}); | ||
|
||
leader.startServer(true); | ||
slowQueryThread.join(); | ||
healthCheckThread.join(); | ||
|
||
ASSERT_EQUAL(results[0], "HTTP/1.1 200 LEADING") | ||
ASSERT_EQUAL(results[1], "HTTP/1.1 200 FOLLOWING") | ||
ASSERT_EQUAL(results[2], "HTTP/1.1 200 STANDINGDOWN") | ||
} | ||
|
||
} __StatusHandlingCommandsTest; |