Skip to content
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

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/clustertest/BedrockClusterTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ ClusterTester<T>::~ClusterTester()
// Shut down everything but the leader first.
list<thread> threads;

for (int i = 0; i< _size; i++) {
for (int i = 0; i < _size; i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just style here.

// Wait for all the commands to be done before stopping.
// If we don't do this, then if the leader loses quorum, because the other nodes have all shut down,
// it won't run remaining commands, and it will get stuck forever.
Expand Down
20 changes: 19 additions & 1 deletion test/lib/BedrockTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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"];

Expand Down Expand Up @@ -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;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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);
Expand Down
5 changes: 4 additions & 1 deletion test/lib/BedrockTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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();
Expand Down Expand Up @@ -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);

Expand Down