mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix CI unit tests (#5196)
- Add retries for rpc client - Add dynamic port allocation for rpc servers
This commit is contained in:
@@ -326,24 +326,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()));
|
||||
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);
|
||||
parsedResult = parseResult(jr);
|
||||
test.expect(parsedResult.ter, "ter uninitialized!");
|
||||
ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
|
||||
|
||||
return jr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -576,8 +568,21 @@ Env::do_rpc(
|
||||
std::vector<std::string> const& args,
|
||||
std::unordered_map<std::string, std::string> 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
|
||||
|
||||
Reference in New Issue
Block a user