fix: Fix flaky CI tests (#7005)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Mayukha Vadari
2026-04-24 09:23:43 -04:00
committed by Bart
parent 93be0797f0
commit 06f9b04634
2 changed files with 23 additions and 3 deletions

View File

@@ -3530,9 +3530,18 @@ public:
jv.isMember(jss::load_factor_fee_reference) &&
jv[jss::load_factor_fee_reference] == 256;
}));
BEAST_EXPECT(
!wsc->findMsg(1s, [&](auto const& jv) { return jv[jss::type] == "serverStatus"; }));
// Drain any extra serverStatus messages that may arrive
// asynchronously from the ledger close processing. The drain
// is bounded so the test cannot hang if serverStatus keeps
// arriving (e.g. LoadManager raising/lowering fees).
auto const drainDeadline = std::chrono::steady_clock::now() + 5s;
while (std::chrono::steady_clock::now() < drainDeadline)
{
if (!wsc->findMsg(1s, [&](auto const& jv) { return jv[jss::type] == "serverStatus"; }))
{
break;
}
}
auto jv = wsc->invoke("unsubscribe", stream);
BEAST_EXPECT(jv[jss::status] == "success");

View File

@@ -58,6 +58,17 @@ class PerfLog_test : public beast::unit_test::suite
explicit Fixture(Application& app, beast::Journal j) : app_(app), j_(j)
{
// Clean up any stale state from a previous test run. On
// self-hosted CI runners the temp directory persists between
// runs, so the "nasty file" test may have left a regular file
// (or a non-empty directory) at the logDir path.
//
// The error code is intentionally ignored: if the path doesn't
// exist (the common case on a clean runner) remove_all returns
// an error, and that's fine — there's nothing to clean up.
using namespace boost::filesystem;
boost::system::error_code ec;
remove_all(logDir(), ec);
}
~Fixture()