From 3ff1f4304df5166a646965a2fa38cf2eb9a66472 Mon Sep 17 00:00:00 2001 From: Oleksandr <115580134+oleks-rip@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:01:04 -0500 Subject: [PATCH 1/5] Try to fix macos unit tests --- src/test/jtx/impl/Env.cpp | 49 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index ef5a2124e24..a3c1d2a8d00 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -317,24 +317,16 @@ Env::submit(JTx const& jt) auto const jr = [&]() { if (jt.stx) { - // We shouldn't need to retry, but it fixes the test on macOS for - // the moment. - int retries = 3; - do - { - txid_ = jt.stx->getTransactionID(); - Serializer s; - jt.stx->add(s); - auto const jr = rpc("submit", strHex(s.slice())); - - parsedResult = parseResult(jr); - test.expect(parsedResult.ter, "ter uninitialized!"); - ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED); - if (ter_ != telENV_RPC_FAILED || - parsedResult.rpcCode != rpcINTERNAL || - jt.ter == telENV_RPC_FAILED || --retries <= 0) - return jr; - } while (true); + txid_ = jt.stx->getTransactionID(); + Serializer s; + jt.stx->add(s); + auto const jr = rpc("submit", strHex(s.slice())); + + parsedResult = parseResult(jr); + test.expect(parsedResult.ter, "ter uninitialized!"); + ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED); + + return jr; } else { @@ -566,8 +558,25 @@ Env::do_rpc( std::vector const& args, std::unordered_map const& headers) { - return rpcClient(args, app().config(), app().logs(), apiVersion, headers) - .second; + Json::Value ret; + + // Retry 1 - This comment just to make push to ci and retrigger the tests. + // It will be removed. + for (unsigned ctr = 0; ctr < 6; ++ctr) + { + auto response = + rpcClient(args, app().config(), app().logs(), apiVersion, headers); + if (response.first != rpcINTERNAL) + { + ret = std::move(response.second); + break; + } + + JLOG(journal.error()) << "Env::do_rpc error, retrying..."; + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } + + return ret; } void From 406f23dc0f29bd4a3f097e933170ef0b389f0367 Mon Sep 17 00:00:00 2001 From: Oleksandr <115580134+oleks-rip@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:46:06 -0500 Subject: [PATCH 2/5] Attempt 2 --- src/test/jtx/impl/Env.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index a3c1d2a8d00..3cb3b0503df 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -560,9 +560,12 @@ Env::do_rpc( { Json::Value ret; - // Retry 1 - This comment just to make push to ci and retrigger the tests. + static unsigned call_id = 0; // counter to check max retries from one call + + // Retry 2 - This comment just to make push to ci and retrigger the tests. // It will be removed. - for (unsigned ctr = 0; ctr < 6; ++ctr) + ++call_id; + for (unsigned ctr = 0; ctr < 10; ++ctr) { auto response = rpcClient(args, app().config(), app().logs(), apiVersion, headers); @@ -572,7 +575,8 @@ Env::do_rpc( break; } - JLOG(journal.error()) << "Env::do_rpc error, retrying..."; + JLOG(journal.error()) + << "Env::do_rpc error, call_Id: " << call_id << ", retrying..."; std::this_thread::sleep_for(std::chrono::milliseconds(500)); } From 17f8ee5b3e5177849820a13d286e6c07a0d0d37e Mon Sep 17 00:00:00 2001 From: Oleksandr <115580134+oleks-rip@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:02:43 -0500 Subject: [PATCH 3/5] Attempt 3 --- src/test/jtx/Env.h | 15 +++++++++++++++ src/test/jtx/impl/Env.cpp | 26 +++++++++----------------- src/test/rpc/LedgerRequestRPC_test.cpp | 1 + src/test/rpc/ValidatorInfo_test.cpp | 1 + src/test/rpc/ValidatorRPC_test.cpp | 1 + 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index d90d2bc1228..fbaf8e449c5 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -413,6 +413,20 @@ class Env app().checkSigs(false); } + // set rpc retries + void + set_retries(unsigned r = 5) + { + retries_ = r; + } + + // get rpc retries + unsigned + retries() const + { + return retries_; + } + /** Associate AccountID with account. */ void memoize(Account const& account); @@ -693,6 +707,7 @@ class Env TestStopwatch stopwatch_; uint256 txid_; TER ter_ = tesSUCCESS; + unsigned retries_ = 5; Json::Value do_rpc( diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 3cb3b0503df..2b1e3c65938 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -558,29 +558,21 @@ Env::do_rpc( std::vector const& args, std::unordered_map const& headers) { - Json::Value ret; + auto response = + rpcClient(args, app().config(), app().logs(), apiVersion, headers); - static unsigned call_id = 0; // counter to check max retries from one call - - // Retry 2 - This comment just to make push to ci and retrigger the tests. - // It will be removed. - ++call_id; - for (unsigned ctr = 0; ctr < 10; ++ctr) + for (unsigned ctr = 0; (ctr < retries_) and (response.first == rpcINTERNAL); + ++ctr) { - auto response = - rpcClient(args, app().config(), app().logs(), apiVersion, headers); - if (response.first != rpcINTERNAL) - { - ret = std::move(response.second); - break; - } - JLOG(journal.error()) - << "Env::do_rpc error, call_Id: " << call_id << ", retrying..."; + << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ..."; std::this_thread::sleep_for(std::chrono::milliseconds(500)); + + response = + rpcClient(args, app().config(), app().logs(), apiVersion, headers); } - return ret; + return response.second; } void diff --git a/src/test/rpc/LedgerRequestRPC_test.cpp b/src/test/rpc/LedgerRequestRPC_test.cpp index 8922cd38386..61905c99c18 100644 --- a/src/test/rpc/LedgerRequestRPC_test.cpp +++ b/src/test/rpc/LedgerRequestRPC_test.cpp @@ -347,6 +347,7 @@ class LedgerRequestRPC_test : public beast::unit_test::suite auto const USD = gw["USD"]; env.fund(XRP(100000), gw); + env.set_retries(0); auto const result = env.rpc("ledger_request", "1")[jss::result]; // The current HTTP/S ServerHandler returns an HTTP 403 error code here // rather than a noPermission JSON error. The JSONRPCClient just eats diff --git a/src/test/rpc/ValidatorInfo_test.cpp b/src/test/rpc/ValidatorInfo_test.cpp index 603a0ad9d23..5ca1af7a3c3 100644 --- a/src/test/rpc/ValidatorInfo_test.cpp +++ b/src/test/rpc/ValidatorInfo_test.cpp @@ -50,6 +50,7 @@ class ValidatorInfo_test : public beast::unit_test::suite { using namespace test::jtx; Env env{*this, envconfig(no_admin)}; + env.set_retries(0); auto const info = env.rpc("validator_info")[jss::result]; BEAST_EXPECT(info.isNull()); } diff --git a/src/test/rpc/ValidatorRPC_test.cpp b/src/test/rpc/ValidatorRPC_test.cpp index 2bd4b69c37b..b53b8d1f82f 100644 --- a/src/test/rpc/ValidatorRPC_test.cpp +++ b/src/test/rpc/ValidatorRPC_test.cpp @@ -49,6 +49,7 @@ class ValidatorRPC_test : public beast::unit_test::suite for (std::string cmd : {"validators", "validator_list_sites"}) { Env env{*this, isAdmin ? envconfig() : envconfig(no_admin)}; + env.set_retries(isAdmin ? 5 : 0); auto const jrr = env.rpc(cmd)[jss::result]; if (isAdmin) { From 22c6de2d5ea34c007f2b72667d3ec5f6e19d3e18 Mon Sep 17 00:00:00 2001 From: Oleksandr <115580134+oleks-rip@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:38:03 -0500 Subject: [PATCH 4/5] Attempt 4 --- src/test/jtx/impl/Env.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 2b1e3c65938..5381b4335c4 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -565,7 +565,7 @@ Env::do_rpc( ++ctr) { JLOG(journal.error()) - << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ..."; + << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ..."; std::this_thread::sleep_for(std::chrono::milliseconds(500)); response = From 146630dea6676bf47a7589c7063e8ceed523665c Mon Sep 17 00:00:00 2001 From: Oleksandr <115580134+oleks-rip@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:20:46 -0500 Subject: [PATCH 5/5] Attempt 6 --- .github/workflows/macos.yml | 15 ++++++++++++++- src/test/jtx/impl/Env.cpp | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index ab4be74fbf4..9252eaa7309 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -41,6 +41,9 @@ jobs: - name: install Ninja if: matrix.generator == 'Ninja' run: brew install ninja + name: install nproc + run: | + brew install coreutils - name: check environment run: | env | sort @@ -48,6 +51,9 @@ jobs: python --version conan --version cmake --version + nproc --version + echo -n "nproc returns: " + nproc - name: configure Conan run : | conan profile new default --detect || true @@ -66,6 +72,13 @@ jobs: with: generator: ${{ matrix.generator }} configuration: ${{ matrix.configuration }} + cmake-args: ${{ matrix.cmake-args }} - name: test run: | - ${build_dir}/rippled --unittest + n=$(nproc) + if [[ $n -gt 2 ]] + then + : $[ n/=2 ] + fi + echo "Using $n test jobs" + ${build_dir}/rippled --unittest --unittest-jobs $n diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 5381b4335c4..2b1e3c65938 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -565,7 +565,7 @@ Env::do_rpc( ++ctr) { JLOG(journal.error()) - << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ..."; + << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ..."; std::this_thread::sleep_for(std::chrono::milliseconds(500)); response =