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

Update expensify_prod branch #1642

Merged
merged 2 commits into from
Feb 12, 2024
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
4 changes: 3 additions & 1 deletion test/clustertest/BedrockClusterTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class ClusterTester {
// Stops a given node.
void stopNode(size_t index);

atomic<uint64_t> groupCommitCount{0};

private:

// The number of nodes in the cluster.
Expand Down Expand Up @@ -140,7 +142,7 @@ ClusterTester<T>::ClusterTester(ClusterSize size,
}

// And add the new entry in the map.
_cluster.emplace_back(args, queries, serverPort, nodePort, controlPort, false, processPath);
_cluster.emplace_back(args, queries, serverPort, nodePort, controlPort, false, processPath, &groupCommitCount);
}

// Now start them all.
Expand Down
19 changes: 17 additions & 2 deletions test/lib/BedrockTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ BedrockTester::BedrockTester(const map<string, string>& args,
uint16_t nodePort,
uint16_t controlPort,
bool startImmediately,
const string& bedrockBinary) :
const string& bedrockBinary,
atomic<uint64_t>* alternateCounter) :
_serverPort(serverPort ?: ports.getPort()),
_nodePort(nodePort ?: ports.getPort()),
_controlPort(controlPort ?: ports.getPort()),
_commandPortPrivate(ports.getPort())
_commandPortPrivate(ports.getPort()),
_commitCount(alternateCounter ? *alternateCounter : _commitCountBase)
{
{
lock_guard<decltype(_testersMutex)> lock(_testersMutex);
Expand Down Expand Up @@ -396,6 +398,9 @@ vector<SData> BedrockTester::executeWaitMultipleData(vector<SData> requests, int
break;
} else {
myRequest = requests[myIndex];
if (_enforceCommandOrder) {
myRequest["commitCount"] = to_string(_commitCount);
}
}

// Reset this for the next request that might need it.
Expand Down Expand Up @@ -490,6 +495,12 @@ vector<SData> BedrockTester::executeWaitMultipleData(vector<SData> requests, int
} else if (!timedOut) {
// Ok, done, let's lock again and insert this in the results.
SData responseData;
if (headers.find("commitCount") != headers.end()) {
uint64_t newCommitCount = SToUInt64(headers["commitCount"]);
if (newCommitCount > _commitCount) {
_commitCount = newCommitCount;
}
}
responseData.nameValueMap = headers;
responseData.methodLine = methodLine;
responseData.content = content;
Expand Down Expand Up @@ -611,3 +622,7 @@ int BedrockTester::getPID() const
{
return _serverPID;
}

void BedrockTester::setEnforceCommandOrder(bool enforce) {
_enforceCommandOrder = enforce;
}
11 changes: 10 additions & 1 deletion test/lib/BedrockTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class BedrockTester {
uint16_t nodePort = 0,
uint16_t controlPort = 0,
bool startImmediately = true,
const string& bedrockBinary = "");
const string& bedrockBinary = "",
atomic<uint64_t>* alternateCounter = nullptr);

// Destructor.
~BedrockTester();
Expand All @@ -47,6 +48,10 @@ class BedrockTester {
// Shuts down all bedrock servers associated with any existing testers.
static void stopAll();

// If enabled, commands will send the most recent `commitCount` received back from this BedrockTester with each new request,
// enforcing that prior commands finish before later commands.
void setEnforceCommandOrder(bool enforce);

// Generate a temporary filename with an optional prefix. Used particularly to create new DB files for each server,
// but can generally be used for any temporary file required.
static string getTempFileName(string prefix = "");
Expand Down Expand Up @@ -120,5 +125,9 @@ class BedrockTester {
uint16_t _nodePort;
uint16_t _controlPort;
uint16_t _commandPortPrivate;

bool _enforceCommandOrder = false;
atomic<uint64_t> _commitCountBase = 0;
atomic<uint64_t>& _commitCount;
};