-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test upgrades for HC-Tree #2045
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -576,7 +576,7 @@ bool BedrockTester::readDB(const string& query, SQResult& result, bool online) | |
SData command("Query"); | ||
command["Query"] = fixedQuery; | ||
command["Format"] = "JSON"; | ||
auto commandResult = executeWaitMultipleData({command}); | ||
auto commandResult = executeWaitMultipleData({command}, 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This creates 10 connections by default and we only need one. Normally it works fine, but it's a waste of effort. IF we get into a state where the connections are failing, we fail 10 connections instead of 1 which is noisy. |
||
auto row0 = SParseJSONObject(commandResult[0].content)["rows"]; | ||
auto headerString = SParseJSONObject(commandResult[0].content)["headers"]; | ||
|
||
|
@@ -622,6 +622,24 @@ bool BedrockTester::waitForStatusTerm(const string& term, const string& testValu | |
return false; | ||
} | ||
|
||
bool BedrockTester::waitForLeadingFollowing(uint64_t timeoutUS) { | ||
uint64_t start = STimeNow(); | ||
while (STimeNow() < start + timeoutUS) { | ||
try { | ||
string result = SParseJSONObject(BedrockTester::executeWaitVerifyContent(SData("Status"), "200", true))["state"]; | ||
|
||
// if the value matches, return, otherwise wait | ||
if (result == "LEADING" || result == "FOLLOWING") { | ||
return true; | ||
} | ||
} catch (...) { | ||
// Doesn't do anything, we'll fall through to the sleep and try again. | ||
} | ||
usleep(100'000); | ||
} | ||
return false; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is added just so that we wan wait for either LEADING or FOLLOWING instead of just one or the other. |
||
bool BedrockTester::waitForState(const string& state, uint64_t timeoutUS) | ||
{ | ||
return waitForStatusTerm("state", state, timeoutUS); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ class BedrockTester { | |
string startServer(bool wait = true); | ||
|
||
// Stop a server by sending it a signal. | ||
void stopServer(int signal = SIGTERM); | ||
virtual void stopServer(int signal = SIGTERM); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This allows auth to override this to do extra checks. |
||
|
||
// Shuts down all bedrock servers associated with any existing testers. | ||
static void stopAll(); | ||
|
@@ -89,6 +89,9 @@ class BedrockTester { | |
// true if a match was found, or times out otherwose. | ||
bool waitForStatusTerm(const string& term, const string& testValue, uint64_t timeoutUS = 60'000'000); | ||
|
||
// Waits for the status to be either LEADING or FOLLOWING | ||
bool waitForLeadingFollowing(uint64_t timeoutUS = 60'000'000); | ||
|
||
// This is just a convenience wrapper around `waitForStatusTerm` looking for the state of the node. | ||
bool waitForState(const string& state, uint64_t timeoutUS = 60'000'000); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just style here.