From df7fd6ab07e41c20e7e4cfffaa819a129f137142 Mon Sep 17 00:00:00 2001 From: Oleksandr <115580134+oleks-rip@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:34:18 -0500 Subject: [PATCH] Attempt 6 --- .github/workflows/macos.yml | 15 ++++++++- src/test/jtx/Env.h | 15 +++++++++ src/test/jtx/impl/Env.cpp | 45 ++++++++++++++------------ src/test/rpc/LedgerRequestRPC_test.cpp | 1 + src/test/rpc/ValidatorInfo_test.cpp | 1 + src/test/rpc/ValidatorRPC_test.cpp | 1 + 6 files changed, 57 insertions(+), 21 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/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 ef5a2124e24..2b1e3c65938 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,21 @@ Env::do_rpc( std::vector const& args, std::unordered_map const& headers) { - return rpcClient(args, app().config(), app().logs(), apiVersion, headers) - .second; + auto response = + rpcClient(args, app().config(), app().logs(), apiVersion, headers); + + for (unsigned ctr = 0; (ctr < retries_) and (response.first == rpcINTERNAL); + ++ctr) + { + JLOG(journal.error()) + << "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 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) {