Reduce console noise coming from unit tests:

A few unit tests have historically generated a lot of noise
to the console from log writes.  This noise was not useful
and made it harder to locate actual test failures.

By changing the log level of these tests from
- severities::kError to
- severities::kDisabled
it was possible to remove that noise coming from the logs.
This commit is contained in:
Scott Schurr
2022-05-13 17:06:14 -07:00
committed by Nik Bougalis
parent ee60b16b3a
commit 0839a202c9
19 changed files with 116 additions and 60 deletions

View File

@@ -21,11 +21,12 @@
#include <ripple/beast/utility/temp_dir.h> #include <ripple/beast/utility/temp_dir.h>
#include <ripple/protocol/SField.h> #include <ripple/protocol/SField.h>
#include <ripple/protocol/jss.h> #include <ripple/protocol/jss.h>
#include <test/jtx.h>
#include <test/jtx/Env.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <fstream> #include <fstream>
#include <test/jtx.h>
#include <test/jtx/Env.h>
namespace ripple { namespace ripple {
@@ -111,7 +112,9 @@ class LedgerLoad_test : public beast::unit_test::suite
Env env( Env env(
*this, *this,
envconfig( envconfig(
ledgerConfig, sd.dbPath, sd.ledgerFile, Config::LOAD_FILE)); ledgerConfig, sd.dbPath, sd.ledgerFile, Config::LOAD_FILE),
nullptr,
beast::severities::kDisabled);
auto jrb = env.rpc("ledger", "current", "full")[jss::result]; auto jrb = env.rpc("ledger", "current", "full")[jss::result];
BEAST_EXPECT( BEAST_EXPECT(
sd.ledger[jss::ledger][jss::accountState].size() == sd.ledger[jss::ledger][jss::accountState].size() ==
@@ -129,7 +132,9 @@ class LedgerLoad_test : public beast::unit_test::suite
except([&] { except([&] {
Env env( Env env(
*this, *this,
envconfig(ledgerConfig, sd.dbPath, "", Config::LOAD_FILE)); envconfig(ledgerConfig, sd.dbPath, "", Config::LOAD_FILE),
nullptr,
beast::severities::kDisabled);
}); });
// file does not exist // file does not exist
@@ -137,10 +142,9 @@ class LedgerLoad_test : public beast::unit_test::suite
Env env( Env env(
*this, *this,
envconfig( envconfig(
ledgerConfig, ledgerConfig, sd.dbPath, "badfile.json", Config::LOAD_FILE),
sd.dbPath, nullptr,
"badfile.json", beast::severities::kDisabled);
Config::LOAD_FILE));
}); });
// make a corrupted version of the ledger file (last 10 bytes removed). // make a corrupted version of the ledger file (last 10 bytes removed).
@@ -168,7 +172,9 @@ class LedgerLoad_test : public beast::unit_test::suite
ledgerConfig, ledgerConfig,
sd.dbPath, sd.dbPath,
ledgerFileCorrupt.string(), ledgerFileCorrupt.string(),
Config::LOAD_FILE)); Config::LOAD_FILE),
nullptr,
beast::severities::kDisabled);
}); });
} }
@@ -183,7 +189,9 @@ class LedgerLoad_test : public beast::unit_test::suite
boost::erase_all(ledgerHash, "\""); boost::erase_all(ledgerHash, "\"");
Env env( Env env(
*this, *this,
envconfig(ledgerConfig, sd.dbPath, ledgerHash, Config::LOAD)); envconfig(ledgerConfig, sd.dbPath, ledgerHash, Config::LOAD),
nullptr,
beast::severities::kDisabled);
auto jrb = env.rpc("ledger", "current", "full")[jss::result]; auto jrb = env.rpc("ledger", "current", "full")[jss::result];
BEAST_EXPECT(jrb[jss::ledger][jss::accountState].size() == 97); BEAST_EXPECT(jrb[jss::ledger][jss::accountState].size() == 97);
BEAST_EXPECT( BEAST_EXPECT(
@@ -199,7 +207,10 @@ class LedgerLoad_test : public beast::unit_test::suite
// create a new env with the ledger "latest" specified for startup // create a new env with the ledger "latest" specified for startup
Env env( Env env(
*this, envconfig(ledgerConfig, sd.dbPath, "latest", Config::LOAD)); *this,
envconfig(ledgerConfig, sd.dbPath, "latest", Config::LOAD),
nullptr,
beast::severities::kDisabled);
auto jrb = env.rpc("ledger", "current", "full")[jss::result]; auto jrb = env.rpc("ledger", "current", "full")[jss::result];
BEAST_EXPECT( BEAST_EXPECT(
sd.ledger[jss::ledger][jss::accountState].size() == sd.ledger[jss::ledger][jss::accountState].size() ==
@@ -213,7 +224,11 @@ class LedgerLoad_test : public beast::unit_test::suite
using namespace test::jtx; using namespace test::jtx;
// create a new env with specific ledger index at startup // create a new env with specific ledger index at startup
Env env(*this, envconfig(ledgerConfig, sd.dbPath, "43", Config::LOAD)); Env env(
*this,
envconfig(ledgerConfig, sd.dbPath, "43", Config::LOAD),
nullptr,
beast::severities::kDisabled);
auto jrb = env.rpc("ledger", "current", "full")[jss::result]; auto jrb = env.rpc("ledger", "current", "full")[jss::result];
BEAST_EXPECT( BEAST_EXPECT(
sd.ledger[jss::ledger][jss::accountState].size() == sd.ledger[jss::ledger][jss::accountState].size() ==

View File

@@ -465,7 +465,7 @@ struct LedgerServer
assert(param.initLedgers > 0); assert(param.initLedgers > 0);
createAccounts(param.initAccounts); createAccounts(param.initAccounts);
createLedgerHistory(); createLedgerHistory();
app.logs().threshold(beast::severities::Severity::kWarning); app.logs().threshold(beast::severities::kWarning);
} }
/** /**
@@ -567,7 +567,10 @@ public:
PeerSetBehavior behavior = PeerSetBehavior::Good, PeerSetBehavior behavior = PeerSetBehavior::Good,
InboundLedgersBehavior inboundBhvr = InboundLedgersBehavior::Good, InboundLedgersBehavior inboundBhvr = InboundLedgersBehavior::Good,
PeerFeature peerFeature = PeerFeature::LedgerReplayEnabled) PeerFeature peerFeature = PeerFeature::LedgerReplayEnabled)
: env(suite, jtx::envconfig(jtx::port_increment, 3)) : env(suite,
jtx::envconfig(jtx::port_increment, 3),
nullptr,
beast::severities::kDisabled)
, app(env.app()) , app(env.app())
, ledgerMaster(env.app().getLedgerMaster()) , ledgerMaster(env.app().getLedgerMaster())
, inboundLedgers( , inboundLedgers(

View File

@@ -388,7 +388,12 @@ class NFTokenDir_test : public beast::unit_test::suite
auto exerciseFixNFTokenDirV1 = auto exerciseFixNFTokenDirV1 =
[this, [this,
&features](std::initializer_list<std::string_view const> seeds) { &features](std::initializer_list<std::string_view const> seeds) {
Env env{*this, features}; Env env{
*this,
envconfig(),
features,
nullptr,
beast::severities::kDisabled};
// Eventually all of the NFTokens will be owned by buyer. // Eventually all of the NFTokens will be owned by buyer.
Account const buyer{"buyer"}; Account const buyer{"buyer"};

View File

@@ -23,8 +23,9 @@
#include <ripple/beast/unit_test.h> #include <ripple/beast/unit_test.h>
#include <ripple/core/Config.h> #include <ripple/core/Config.h>
#include <ripple/core/ConfigSections.h> #include <ripple/core/ConfigSections.h>
#include <test/jtx/Env.h>
#include <string> #include <string>
#include <test/unit_test/SuiteJournal.h>
namespace ripple { namespace ripple {
namespace test { namespace test {
@@ -75,7 +76,14 @@ public:
void void
run() override run() override
{ {
SuiteJournal journal("ValidatorKeys_test", *this); // We're only using Env for its Journal. That Journal gives better
// coverage in unit tests.
test::jtx::Env env{
*this,
test::jtx::envconfig(),
nullptr,
beast::severities::kDisabled};
beast::Journal journal{env.app().journal("ValidatorKeys_test")};
// Keys/ID when using [validation_seed] // Keys/ID when using [validation_seed]
SecretKey const seedSecretKey = SecretKey const seedSecretKey =

View File

@@ -29,9 +29,10 @@
#include <ripple/protocol/digest.h> #include <ripple/protocol/digest.h>
#include <ripple/protocol/jss.h> #include <ripple/protocol/jss.h>
#include <ripple/protocol/messages.h> #include <ripple/protocol/messages.h>
#include <boost/beast/core/multi_buffer.hpp>
#include <test/jtx.h> #include <test/jtx.h>
#include <boost/beast/core/multi_buffer.hpp>
namespace ripple { namespace ripple {
namespace test { namespace test {
@@ -217,7 +218,8 @@ private:
{ {
testcase("Config Load"); testcase("Config Load");
jtx::Env env(*this); jtx::Env env(
*this, jtx::envconfig(), nullptr, beast::severities::kDisabled);
auto& app = env.app(); auto& app = env.app();
PublicKey emptyLocalKey; PublicKey emptyLocalKey;
std::vector<std::string> const emptyCfgKeys; std::vector<std::string> const emptyCfgKeys;

View File

@@ -69,7 +69,7 @@ private:
using namespace jtx; using namespace jtx;
Env env(*this); Env env(*this, envconfig(), nullptr, beast::severities::kDisabled);
auto trustedSites = auto trustedSites =
std::make_unique<ValidatorSite>(env.app(), env.journal); std::make_unique<ValidatorSite>(env.app(), env.journal);
@@ -282,9 +282,6 @@ private:
if (u.cfg.failFetch) if (u.cfg.failFetch)
{ {
using namespace std::chrono; using namespace std::chrono;
log << " -- Msg: "
<< myStatus[jss::last_refresh_message].asString()
<< std::endl;
std::stringstream nextRefreshStr{ std::stringstream nextRefreshStr{
myStatus[jss::next_refresh_time].asString()}; myStatus[jss::next_refresh_time].asString()};
system_clock::time_point nextRefresh; system_clock::time_point nextRefresh;
@@ -357,9 +354,6 @@ private:
sink.messages().str().find(u.expectMsg) != sink.messages().str().find(u.expectMsg) !=
std::string::npos, std::string::npos,
sink.messages().str()); sink.messages().str());
log << " -- Msg: "
<< myStatus[jss::last_refresh_message].asString()
<< std::endl;
} }
} }
} }

View File

@@ -24,12 +24,13 @@
#include <ripple/json/json_reader.h> #include <ripple/json/json_reader.h>
#include <ripple/protocol/jss.h> #include <ripple/protocol/jss.h>
#include <ripple/rpc/impl/Handler.h> #include <ripple/rpc/impl/Handler.h>
#include <test/jtx/Env.h>
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
#include <cmath> #include <cmath>
#include <random> #include <random>
#include <string> #include <string>
#include <test/jtx/Env.h>
#include <thread> #include <thread>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -44,7 +45,11 @@ class PerfLog_test : public beast::unit_test::suite
// We're only using Env for its Journal. That Journal gives better // We're only using Env for its Journal. That Journal gives better
// coverage in unit tests. // coverage in unit tests.
test::jtx::Env env_{*this}; test::jtx::Env env_{
*this,
test::jtx::envconfig(),
nullptr,
beast::severities::kDisabled};
beast::Journal j_{env_.app().journal("PerfLog_test")}; beast::Journal j_{env_.app().journal("PerfLog_test")};
struct Fixture struct Fixture

View File

@@ -200,9 +200,6 @@ class io_latency_probe_test : public beast::unit_test::suite,
duration_cast<milliseconds>(probe_duration).count()) / duration_cast<milliseconds>(probe_duration).count()) /
static_cast<size_t>(tt.getMean<milliseconds>()); static_cast<size_t>(tt.getMean<milliseconds>());
#endif #endif
log << "expected_probe_count_min: " << expected_probe_count_min << "\n";
log << "expected_probe_count_max: " << expected_probe_count_max << "\n";
test_sampler io_probe{interval, get_io_service()}; test_sampler io_probe{interval, get_io_service()};
io_probe.start(); io_probe.start();
MyTimer timer{get_io_service(), probe_duration}; MyTimer timer{get_io_service(), probe_duration};

View File

@@ -19,9 +19,10 @@
#include <ripple/beast/unit_test.h> #include <ripple/beast/unit_test.h>
#include <ripple/core/ClosureCounter.h> #include <ripple/core/ClosureCounter.h>
#include <test/jtx/Env.h>
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
#include <test/jtx/Env.h>
#include <thread> #include <thread>
namespace ripple { namespace ripple {
@@ -31,9 +32,14 @@ namespace test {
class ClosureCounter_test : public beast::unit_test::suite class ClosureCounter_test : public beast::unit_test::suite
{ {
// We're only using Env for its Journal. // We're only using Env for its Journal. That Journal gives better
jtx::Env env{*this}; // coverage in unit tests.
beast::Journal j{env.app().journal("ClosureCounter_test")}; test::jtx::Env env_{
*this,
jtx::envconfig(),
nullptr,
beast::severities::kDisabled};
beast::Journal j{env_.app().journal("ClosureCounter_test")};
void void
testConstruction() testConstruction()

View File

@@ -154,7 +154,7 @@ public:
rmDataDir_ = !exists(dataDir_); rmDataDir_ = !exists(dataDir_);
config_.setup( config_.setup(
file_.string(), file_.string(),
/*bQuiet*/ true, /* bQuiet */ true,
/* bSilent */ false, /* bSilent */ false,
/* bStandalone */ false); /* bStandalone */ false);
} }
@@ -190,9 +190,6 @@ public:
using namespace boost::filesystem; using namespace boost::filesystem;
if (rmDataDir_) if (rmDataDir_)
rmDir(dataDir_); rmDir(dataDir_);
else
test_.log << "Skipping rm dir: " << dataDir_.string()
<< std::endl;
} }
catch (std::exception& e) catch (std::exception& e)
{ {

View File

@@ -888,10 +888,14 @@ public:
testExceptionalShutdown() testExceptionalShutdown()
{ {
except([this] { except([this] {
jtx::Env env{*this, jtx::envconfig([](std::unique_ptr<Config> cfg) { jtx::Env env{
(*cfg).deprecatedClearSection("port_rpc"); *this,
return cfg; jtx::envconfig([](std::unique_ptr<Config> cfg) {
})}; (*cfg).deprecatedClearSection("port_rpc");
return cfg;
}),
nullptr,
beast::severities::kDisabled};
}); });
pass(); pass();
} }

View File

@@ -130,6 +130,8 @@ class View_test : public beast::unit_test::suite
void void
testLedger() testLedger()
{ {
testcase("Ledger");
using namespace jtx; using namespace jtx;
Env env(*this); Env env(*this);
Config config; Config config;
@@ -165,6 +167,8 @@ class View_test : public beast::unit_test::suite
void void
testMeta() testMeta()
{ {
testcase("Meta");
using namespace jtx; using namespace jtx;
Env env(*this); Env env(*this);
wipe(env.app().openLedger()); wipe(env.app().openLedger());
@@ -196,6 +200,8 @@ class View_test : public beast::unit_test::suite
void void
testMetaSucc() testMetaSucc()
{ {
testcase("Meta succ");
using namespace jtx; using namespace jtx;
Env env(*this); Env env(*this);
wipe(env.app().openLedger()); wipe(env.app().openLedger());
@@ -260,6 +266,8 @@ class View_test : public beast::unit_test::suite
void void
testStacked() testStacked()
{ {
testcase("Stacked");
using namespace jtx; using namespace jtx;
Env env(*this); Env env(*this);
wipe(env.app().openLedger()); wipe(env.app().openLedger());
@@ -325,6 +333,8 @@ class View_test : public beast::unit_test::suite
void void
testContext() testContext()
{ {
testcase("Context");
using namespace jtx; using namespace jtx;
using namespace std::chrono; using namespace std::chrono;
{ {
@@ -387,6 +397,8 @@ class View_test : public beast::unit_test::suite
void void
testUpperAndLowerBound() testUpperAndLowerBound()
{ {
testcase("Upper and lower bound");
using namespace jtx; using namespace jtx;
Env env(*this); Env env(*this);
Config config; Config config;
@@ -654,6 +666,8 @@ class View_test : public beast::unit_test::suite
void void
testSles() testSles()
{ {
testcase("Sles");
using namespace jtx; using namespace jtx;
Env env(*this); Env env(*this);
Config config; Config config;
@@ -786,6 +800,8 @@ class View_test : public beast::unit_test::suite
void void
testFlags() testFlags()
{ {
testcase("Flags");
using namespace jtx; using namespace jtx;
Env env(*this); Env env(*this);
@@ -949,6 +965,8 @@ class View_test : public beast::unit_test::suite
void void
testTransferRate() testTransferRate()
{ {
testcase("Transfer rate");
using namespace jtx; using namespace jtx;
Env env(*this); Env env(*this);
@@ -975,12 +993,14 @@ class View_test : public beast::unit_test::suite
// construct and manage two different Env instances at the same // construct and manage two different Env instances at the same
// time. So we can use two Env instances to produce mutually // time. So we can use two Env instances to produce mutually
// incompatible ledgers. // incompatible ledgers.
testcase("Are compatible");
using namespace jtx; using namespace jtx;
auto const alice = Account("alice"); auto const alice = Account("alice");
auto const bob = Account("bob"); auto const bob = Account("bob");
// The first Env. // The first Env.
Env eA(*this); Env eA(*this, envconfig(), nullptr, beast::severities::kDisabled);
eA.fund(XRP(10000), alice); eA.fund(XRP(10000), alice);
eA.close(); eA.close();
@@ -990,9 +1010,13 @@ class View_test : public beast::unit_test::suite
eA.close(); eA.close();
auto const rdViewA4 = eA.closed(); auto const rdViewA4 = eA.closed();
// The two Env's can't share the same ports, so modifiy the config // The two Env's can't share the same ports, so modify the config
// of the second Env to use higher port numbers // of the second Env to use higher port numbers
Env eB{*this, envconfig(port_increment, 3)}; Env eB{
*this,
envconfig(port_increment, 3),
nullptr,
beast::severities::kDisabled};
// Make ledgers that are incompatible with the first ledgers. Note // Make ledgers that are incompatible with the first ledgers. Note
// that bob is funded before alice. // that bob is funded before alice.
@@ -1029,6 +1053,8 @@ class View_test : public beast::unit_test::suite
void void
testRegressions() testRegressions()
{ {
testcase("Regressions");
using namespace jtx; using namespace jtx;
// Create a ledger with 1 item, put a // Create a ledger with 1 item, put a

View File

@@ -195,8 +195,6 @@ private:
{ {
acceptor_.listen(); acceptor_.listen();
server_.endpoint_ = acceptor_.local_endpoint(); server_.endpoint_ = acceptor_.local_endpoint();
test_.log << "[server] up on port: " << server_.endpoint_.port()
<< std::endl;
} }
void void

View File

@@ -1250,13 +1250,10 @@ class LedgerRPC_test : public beast::unit_test::suite
// no amendments // no amendments
env.fund(XRP(10000), "alice"); env.fund(XRP(10000), "alice");
env.close(); env.close();
log << env.closed()->info().hash;
env.fund(XRP(10000), "bob"); env.fund(XRP(10000), "bob");
env.close(); env.close();
log << env.closed()->info().hash;
env.fund(XRP(10000), "jim"); env.fund(XRP(10000), "jim");
env.close(); env.close();
log << env.closed()->info().hash;
env.fund(XRP(10000), "jill"); env.fund(XRP(10000), "jill");
{ {

View File

@@ -276,7 +276,8 @@ public:
sectionNode.set("ledgers_per_shard", "256"); sectionNode.set("ledgers_per_shard", "256");
c->setupControl(true, true, true); c->setupControl(true, true, true);
return jtx::Env(*this, std::move(c)); return jtx::Env(
*this, std::move(c), nullptr, beast::severities::kDisabled);
}(); }();
std::uint8_t const numberOfShards = 10; std::uint8_t const numberOfShards = 10;

View File

@@ -173,7 +173,8 @@ public:
} }
c->setupControl(true, true, true); c->setupControl(true, true, true);
jtx::Env env(*this, std::move(c)); jtx::Env env(
*this, std::move(c), nullptr, beast::severities::kDisabled);
std::uint8_t const numberOfDownloads = 10; std::uint8_t const numberOfDownloads = 10;
@@ -276,7 +277,8 @@ public:
} }
c->setupControl(true, true, true); c->setupControl(true, true, true);
jtx::Env env(*this, std::move(c)); jtx::Env env(
*this, std::move(c), nullptr, beast::severities::kDisabled);
std::uint8_t const numberOfDownloads = 10; std::uint8_t const numberOfDownloads = 10;
@@ -380,7 +382,8 @@ public:
} }
c->setupControl(true, true, true); c->setupControl(true, true, true);
jtx::Env env(*this, std::move(c)); jtx::Env env(
*this, std::move(c), nullptr, beast::severities::kDisabled);
std::uint8_t const numberOfDownloads = 10; std::uint8_t const numberOfDownloads = 10;
// Create some ledgers so that the ShardArchiveHandler // Create some ledgers so that the ShardArchiveHandler

View File

@@ -299,7 +299,6 @@ public:
serverPort.back().port = 0; serverPort.back().port = 0;
serverPort.back().protocol.insert("http"); serverPort.back().protocol.insert("http");
auto eps = s->ports(serverPort); auto eps = s->ports(serverPort);
log << "server listening on port " << eps[0].port() << std::endl;
test_request(eps[0]); test_request(eps[0]);
test_keepalive(eps[0]); test_keepalive(eps[0]);
// s->close(); // s->close();

View File

@@ -184,7 +184,6 @@ public:
BEAST_EXPECT(source.deepCompare(destination)); BEAST_EXPECT(source.deepCompare(destination));
log << "Checking destination invariants..." << std::endl;
destination.invariants(); destination.invariants();
} }
}; };

View File

@@ -86,9 +86,6 @@ public:
if (rmSubDir_) if (rmSubDir_)
rmDir(subDir_); rmDir(subDir_);
else
test_.log << "Skipping rm dir: " << subDir_.string()
<< std::endl;
} }
catch (std::exception& e) catch (std::exception& e)
{ {