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 #1668

Merged
merged 3 commits into from
Mar 11, 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
5 changes: 5 additions & 0 deletions sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,11 @@ int SQLiteNode::_handleCommitTransaction(SQLite& db, SQLitePeer* peer, const uin
return result;
}

// If the commit completed, interrupt the sync thread `poll` loop in case any other threads were waiting on this commit to complete.
if (result == SQLITE_OK) {
notifyCommit();
}

// Clear the list of committed transactions. We're following, so we don't need to send these.
db.popCommittedTransactions();

Expand Down
2 changes: 1 addition & 1 deletion test/clustertest/BedrockClusterTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ ClusterTester<T>::ClusterTester(ClusterSize size,
} catch (...) {
// This will happen if the server's not up yet. We'll just try again.
}
usleep(500000); // 0.5 seconds.
usleep(100000); // 0.1 seconds.
}
}
}
Expand Down
36 changes: 34 additions & 2 deletions test/lib/tpunit++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <string.h>
#include <iostream>
#include <regex>
#include <chrono>
using namespace tpunit;

bool tpunit::TestFixture::exitFlag = false;
Expand Down Expand Up @@ -166,11 +167,15 @@ int tpunit::TestFixture::tpunit_detail_do_run(const set<string>& include, const
}

list<TestFixture*> afterTests;
mutex testTimeLock;
multimap<chrono::milliseconds, string> testTimes;

for (int threadID = 0; threadID < threads; threadID++) {
// Capture everything by reference except threadID, because we don't want it to be incremented for the
// next thread in the loop.
thread t = thread([&, threadID]{
auto start = chrono::steady_clock::now();

threadInitFunction();
try {
// Do test.
Expand Down Expand Up @@ -258,6 +263,11 @@ int tpunit::TestFixture::tpunit_detail_do_run(const set<string>& include, const
exitFlag = true;
printf("Thread %d caught shutdown exception, exiting.\n", threadID);
}
auto end = chrono::steady_clock::now();
if (currentTestName.size()) {
lock_guard<mutex> lock(testTimeLock);
testTimes.emplace(make_pair(chrono::duration_cast<std::chrono::milliseconds>(end - start), currentTestName));
}
});
threadList.push_back(move(t));
}
Expand Down Expand Up @@ -293,6 +303,18 @@ int tpunit::TestFixture::tpunit_detail_do_run(const set<string>& include, const
printf("%s\n", failure.c_str());
}
}

cout << endl;
cout << "Slowest Test Classes: " << endl;
auto it = testTimes.rbegin();
for (size_t i = 0; i < 10; i++) {
if (it == testTimes.rend()) {
break;
}
cout << it->first << ": " << it->second << endl;
it++;
}

return tpunit_detail_stats()._failures;
}
return 1;
Expand Down Expand Up @@ -418,23 +440,33 @@ void tpunit::TestFixture::tpunit_detail_do_tests(TestFixture* f) {
f->_stats._assertions = 0;
f->_stats._exceptions = 0;
f->testOutputBuffer = "";
auto start = chrono::steady_clock::now();
tpunit_detail_do_methods(f->_befores);
tpunit_detail_do_method(t);
tpunit_detail_do_methods(f->_afters);
auto end = chrono::steady_clock::now();
stringstream timeStream;
timeStream << "(" << chrono::duration_cast<std::chrono::milliseconds>(end - start);
if (chrono::duration_cast<std::chrono::milliseconds>(end - start) > 5000ms) {
timeStream << " \xF0\x9F\x90\x8C";
}
timeStream << ")";
string timeStr = timeStream.str();
const char* time = timeStr.c_str();

// No new assertions or exceptions. This not currently synchronized correctly. They can cause tests that
// passed to appear failed when another test failed while this test was running. They cannot cause failed
// tests to appear to have passed.
if(!f->_stats._assertions && !f->_stats._exceptions) {
lock_guard<recursive_mutex> lock(m);
printf("\xE2\x9C\x85 %s\n", t->_name);
printf("\xE2\x9C\x85 %s %s\n", t->_name, time);
tpunit_detail_stats()._passes++;
} else {
lock_guard<recursive_mutex> lock(m);

// Dump the test buffer if the test included any log lines.
f->printTestBuffer();
printf("\xE2\x9D\x8C !FAILED! \xE2\x9D\x8C %s\n", t->_name);
printf("\xE2\x9D\x8C !FAILED! \xE2\x9D\x8C %s %s\n", t->_name, time);
tpunit_detail_stats()._failures++;
tpunit_detail_stats()._failureNames.emplace(t->_name);
}
Expand Down