chore: No ALL_CAPS (#1760)

Fixes #1680
This commit is contained in:
Alex Kremer
2025-01-02 11:39:31 +00:00
committed by GitHub
parent efe5d08205
commit 820b32c6d7
361 changed files with 10061 additions and 9724 deletions

View File

@@ -71,7 +71,7 @@ using CassandraMigrationTestManager = migration::impl::MigrationManagerBase<Cass
namespace {
std::pair<std::shared_ptr<migration::MigrationManagerInterface>, std::shared_ptr<CassandraMigrationTestBackend>>
make_MigrationTestManagerAndBackend(ClioConfigDefinition const& config)
makeMigrationTestManagerAndBackend(ClioConfigDefinition const& config)
{
auto const cfg = config.getObject("database.cassandra");
@@ -93,7 +93,7 @@ class MigrationCassandraSimpleTest : public WithPrometheus, public NoLoggerFixtu
}
protected:
ClioConfigDefinition cfg{
ClioConfigDefinition cfg_{
{{"database.type", ConfigValue{ConfigType::String}.defaultValue("cassandra")},
{"database.cassandra.contact_points",
@@ -104,46 +104,46 @@ protected:
{"database.cassandra.replication_factor", ConfigValue{ConfigType::Integer}.defaultValue(1)},
{"database.cassandra.connect_timeout", ConfigValue{ConfigType::Integer}.defaultValue(2)},
{"database.cassandra.secure_connect_bundle", ConfigValue{ConfigType::String}.optional()},
{"database.cassandra.port", ConfigValue{ConfigType::Integer}.withConstraint(validatePort).optional()},
{"database.cassandra.port", ConfigValue{ConfigType::Integer}.withConstraint(gValidatePort).optional()},
{"database.cassandra.replication_factor",
ConfigValue{ConfigType::Integer}.defaultValue(3u).withConstraint(validateUint16)},
ConfigValue{ConfigType::Integer}.defaultValue(3u).withConstraint(gValidateUint16)},
{"database.cassandra.table_prefix", ConfigValue{ConfigType::String}.optional()},
{"database.cassandra.max_write_requests_outstanding",
ConfigValue{ConfigType::Integer}.defaultValue(10'000).withConstraint(validateUint32)},
ConfigValue{ConfigType::Integer}.defaultValue(10'000).withConstraint(gValidateUint32)},
{"database.cassandra.max_read_requests_outstanding",
ConfigValue{ConfigType::Integer}.defaultValue(100'000).withConstraint(validateUint32)},
ConfigValue{ConfigType::Integer}.defaultValue(100'000).withConstraint(gValidateUint32)},
{"database.cassandra.threads",
ConfigValue{ConfigType::Integer}
.defaultValue(static_cast<uint32_t>(std::thread::hardware_concurrency()))
.withConstraint(validateUint32)},
.withConstraint(gValidateUint32)},
{"database.cassandra.core_connections_per_host",
ConfigValue{ConfigType::Integer}.defaultValue(1).withConstraint(validateUint16)},
{"database.cassandra.queue_size_io", ConfigValue{ConfigType::Integer}.optional().withConstraint(validateUint16)
},
ConfigValue{ConfigType::Integer}.defaultValue(1).withConstraint(gValidateUint16)},
{"database.cassandra.queue_size_io",
ConfigValue{ConfigType::Integer}.optional().withConstraint(gValidateUint16)},
{"database.cassandra.write_batch_size",
ConfigValue{ConfigType::Integer}.defaultValue(20).withConstraint(validateUint16)},
ConfigValue{ConfigType::Integer}.defaultValue(20).withConstraint(gValidateUint16)},
{"database.cassandra.connect_timeout",
ConfigValue{ConfigType::Integer}.optional().withConstraint(validateUint32)},
ConfigValue{ConfigType::Integer}.optional().withConstraint(gValidateUint32)},
{"database.cassandra.request_timeout",
ConfigValue{ConfigType::Integer}.optional().withConstraint(validateUint32)},
ConfigValue{ConfigType::Integer}.optional().withConstraint(gValidateUint32)},
{"database.cassandra.username", ConfigValue{ConfigType::String}.optional()},
{"database.cassandra.password", ConfigValue{ConfigType::String}.optional()},
{"database.cassandra.certfile", ConfigValue{ConfigType::String}.optional()},
{"migration.full_scan_threads", ConfigValue{ConfigType::Integer}.defaultValue(2).withConstraint(validateUint32)
},
{"migration.full_scan_jobs", ConfigValue{ConfigType::Integer}.defaultValue(4).withConstraint(validateUint32)},
{"migration.cursors_per_job", ConfigValue{ConfigType::Integer}.defaultValue(100).withConstraint(validateUint32)
}}
{"migration.full_scan_threads",
ConfigValue{ConfigType::Integer}.defaultValue(2).withConstraint(gValidateUint32)},
{"migration.full_scan_jobs", ConfigValue{ConfigType::Integer}.defaultValue(4).withConstraint(gValidateUint32)},
{"migration.cursors_per_job",
ConfigValue{ConfigType::Integer}.defaultValue(100).withConstraint(gValidateUint32)}}
};
std::shared_ptr<migration::MigrationManagerInterface> testMigrationManager;
std::shared_ptr<CassandraMigrationTestBackend> testMigrationBackend;
std::shared_ptr<migration::MigrationManagerInterface> testMigrationManager_;
std::shared_ptr<CassandraMigrationTestBackend> testMigrationBackend_;
MigrationCassandraSimpleTest()
{
auto const testBundle = make_MigrationTestManagerAndBackend(cfg);
testMigrationManager = testBundle.first;
testMigrationBackend = testBundle.second;
auto const testBundle = makeMigrationTestManagerAndBackend(cfg_);
testMigrationManager_ = testBundle.first;
testMigrationBackend_ = testBundle.second;
}
void
@@ -167,7 +167,7 @@ struct MigrationCassandraManagerCleanDBTest : public MigrationCassandraSimpleTes
TEST_F(MigrationCassandraManagerCleanDBTest, GetAllMigratorNames)
{
auto const names = testMigrationManager->allMigratorsNames();
auto const names = testMigrationManager_->allMigratorsNames();
EXPECT_EQ(names.size(), 4);
EXPECT_EQ(names[0], "ExampleObjectsMigrator");
EXPECT_EQ(names[1], "ExampleTransactionsMigrator");
@@ -177,7 +177,7 @@ TEST_F(MigrationCassandraManagerCleanDBTest, GetAllMigratorNames)
TEST_F(MigrationCassandraManagerCleanDBTest, AllMigratorStatusBeforeAnyMigration)
{
auto const status = testMigrationManager->allMigratorsStatusPairs();
auto const status = testMigrationManager_->allMigratorsStatusPairs();
EXPECT_EQ(status.size(), 4);
EXPECT_EQ(std::get<1>(status[0]), MigratorStatus::NotMigrated);
EXPECT_EQ(std::get<1>(status[1]), MigratorStatus::NotMigrated);
@@ -187,19 +187,19 @@ TEST_F(MigrationCassandraManagerCleanDBTest, AllMigratorStatusBeforeAnyMigration
TEST_F(MigrationCassandraManagerCleanDBTest, MigratorStatus)
{
auto status = testMigrationManager->getMigratorStatusByName("ExampleObjectsMigrator");
auto status = testMigrationManager_->getMigratorStatusByName("ExampleObjectsMigrator");
EXPECT_EQ(status, MigratorStatus::NotMigrated);
status = testMigrationManager->getMigratorStatusByName("ExampleTransactionsMigrator");
status = testMigrationManager_->getMigratorStatusByName("ExampleTransactionsMigrator");
EXPECT_EQ(status, MigratorStatus::NotMigrated);
status = testMigrationManager->getMigratorStatusByName("ExampleLedgerMigrator");
status = testMigrationManager_->getMigratorStatusByName("ExampleLedgerMigrator");
EXPECT_EQ(status, MigratorStatus::NotMigrated);
status = testMigrationManager->getMigratorStatusByName("ExampleDropTableMigrator");
status = testMigrationManager_->getMigratorStatusByName("ExampleDropTableMigrator");
EXPECT_EQ(status, MigratorStatus::NotMigrated);
status = testMigrationManager->getMigratorStatusByName("NonExistentMigrator");
status = testMigrationManager_->getMigratorStatusByName("NonExistentMigrator");
EXPECT_EQ(status, MigratorStatus::NotKnown);
}
@@ -212,7 +212,7 @@ class MigrationCassandraManagerTxTableTest : public MigrationCassandraSimpleTest
Handle const handle{TestGlobals::instance().backendHost};
EXPECT_TRUE(handle.connect());
std::ranges::for_each(TransactionsRawData, [&](auto const& value) {
std::ranges::for_each(gTransactionsRawData, [&](auto const& value) {
writeTxFromCSVString(TestGlobals::instance().backendKeyspace, value, handle);
});
}
@@ -220,23 +220,23 @@ class MigrationCassandraManagerTxTableTest : public MigrationCassandraSimpleTest
TEST_F(MigrationCassandraManagerTxTableTest, MigrateExampleTransactionsMigrator)
{
auto constexpr TransactionsMigratorName = "ExampleTransactionsMigrator";
EXPECT_EQ(testMigrationManager->getMigratorStatusByName(TransactionsMigratorName), MigratorStatus::NotMigrated);
auto constexpr kTRANSACTIONS_MIGRATOR_NAME = "ExampleTransactionsMigrator";
EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kTRANSACTIONS_MIGRATOR_NAME), MigratorStatus::NotMigrated);
ExampleTransactionsMigrator::count = 0;
testMigrationManager->runMigration(TransactionsMigratorName);
EXPECT_EQ(ExampleTransactionsMigrator::count, TransactionsRawData.size());
testMigrationManager_->runMigration(kTRANSACTIONS_MIGRATOR_NAME);
EXPECT_EQ(ExampleTransactionsMigrator::count, gTransactionsRawData.size());
auto const newTableSize =
data::synchronous([&](auto ctx) { return testMigrationBackend->fetchTxIndexTableSize(ctx); });
data::synchronous([&](auto ctx) { return testMigrationBackend_->fetchTxIndexTableSize(ctx); });
EXPECT_TRUE(newTableSize.has_value());
EXPECT_EQ(newTableSize, TransactionsRawData.size());
EXPECT_EQ(newTableSize, gTransactionsRawData.size());
// check a few tx types
auto const getTxType = [&](ripple::uint256 const& txHash) -> std::optional<std::string> {
return data::synchronous([&](auto ctx) {
return testMigrationBackend->fetchTxTypeViaID(uint256ToString(txHash), ctx);
return testMigrationBackend_->fetchTxTypeViaID(uint256ToString(txHash), ctx);
});
};
@@ -252,7 +252,7 @@ TEST_F(MigrationCassandraManagerTxTableTest, MigrateExampleTransactionsMigrator)
EXPECT_TRUE(txType.has_value());
EXPECT_EQ(txType.value(), "AMMCreate");
EXPECT_EQ(testMigrationManager->getMigratorStatusByName(TransactionsMigratorName), MigratorStatus::Migrated);
EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kTRANSACTIONS_MIGRATOR_NAME), MigratorStatus::Migrated);
}
// The test suite for testing migration process for ExampleObjectsMigrator. In this test suite, the objects are written
@@ -263,7 +263,7 @@ class MigrationCassandraManagerObjectsTableTest : public MigrationCassandraSimpl
{
Handle const handle{TestGlobals::instance().backendHost};
EXPECT_TRUE(handle.connect());
for (auto const& value : ObjectsRawData) {
for (auto const& value : gObjectsRawData) {
writeObjectFromCSVString(TestGlobals::instance().backendKeyspace, value, handle);
}
}
@@ -271,15 +271,15 @@ class MigrationCassandraManagerObjectsTableTest : public MigrationCassandraSimpl
TEST_F(MigrationCassandraManagerObjectsTableTest, MigrateExampleObjectsMigrator)
{
auto constexpr ObjectsMigratorName = "ExampleObjectsMigrator";
EXPECT_EQ(testMigrationManager->getMigratorStatusByName(ObjectsMigratorName), MigratorStatus::NotMigrated);
auto constexpr kOBJECTS_MIGRATOR_NAME = "ExampleObjectsMigrator";
EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kOBJECTS_MIGRATOR_NAME), MigratorStatus::NotMigrated);
testMigrationManager->runMigration(ObjectsMigratorName);
testMigrationManager_->runMigration(kOBJECTS_MIGRATOR_NAME);
EXPECT_EQ(ExampleObjectsMigrator::count, ObjectsRawData.size());
EXPECT_EQ(ExampleObjectsMigrator::count, gObjectsRawData.size());
EXPECT_EQ(ExampleObjectsMigrator::accountCount, 37);
EXPECT_EQ(testMigrationManager->getMigratorStatusByName(ObjectsMigratorName), MigratorStatus::Migrated);
EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kOBJECTS_MIGRATOR_NAME), MigratorStatus::Migrated);
}
// The test suite for testing migration process for ExampleLedgerMigrator. In this test suite, the ledger headers are
@@ -290,7 +290,7 @@ class MigrationCassandraManagerLedgerTableTest : public MigrationCassandraSimple
{
Handle const handle{TestGlobals::instance().backendHost};
EXPECT_TRUE(handle.connect());
for (auto const& value : LedgerHeaderRawData) {
for (auto const& value : gLedgerHeaderRawData) {
writeLedgerFromCSVString(TestGlobals::instance().backendKeyspace, value, handle);
}
writeLedgerRange(TestGlobals::instance().backendKeyspace, 5619393, 5619442, handle);
@@ -299,18 +299,18 @@ class MigrationCassandraManagerLedgerTableTest : public MigrationCassandraSimple
TEST_F(MigrationCassandraManagerLedgerTableTest, MigrateExampleLedgerMigrator)
{
auto constexpr HeaderMigratorName = "ExampleLedgerMigrator";
EXPECT_EQ(testMigrationManager->getMigratorStatusByName(HeaderMigratorName), MigratorStatus::NotMigrated);
auto constexpr kHEADER_MIGRATOR_NAME = "ExampleLedgerMigrator";
EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kHEADER_MIGRATOR_NAME), MigratorStatus::NotMigrated);
testMigrationManager->runMigration(HeaderMigratorName);
EXPECT_EQ(testMigrationManager->getMigratorStatusByName(HeaderMigratorName), MigratorStatus::Migrated);
testMigrationManager_->runMigration(kHEADER_MIGRATOR_NAME);
EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kHEADER_MIGRATOR_NAME), MigratorStatus::Migrated);
auto const newTableSize =
data::synchronous([&](auto ctx) { return testMigrationBackend->fetchLedgerTableSize(ctx); });
EXPECT_EQ(newTableSize, LedgerHeaderRawData.size());
data::synchronous([&](auto ctx) { return testMigrationBackend_->fetchLedgerTableSize(ctx); });
EXPECT_EQ(newTableSize, gLedgerHeaderRawData.size());
auto const getAccountHash = [this](std::uint32_t seq) {
return data::synchronous([&](auto ctx) { return testMigrationBackend->fetchAccountHashViaSequence(seq, ctx); });
return data::synchronous([&](auto ctx) { return testMigrationBackend_->fetchAccountHashViaSequence(seq, ctx); });
};
EXPECT_EQ(
@@ -329,17 +329,17 @@ class MigrationCassandraManagerDropTableTest : public MigrationCassandraSimpleTe
TEST_F(MigrationCassandraManagerDropTableTest, MigrateDropTableMigrator)
{
auto constexpr DropTableMigratorName = "ExampleDropTableMigrator";
EXPECT_EQ(testMigrationManager->getMigratorStatusByName(DropTableMigratorName), MigratorStatus::NotMigrated);
auto constexpr kDROP_TABLE_MIGRATOR_NAME = "ExampleDropTableMigrator";
EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kDROP_TABLE_MIGRATOR_NAME), MigratorStatus::NotMigrated);
auto const beforeDropSize =
data::synchronous([&](auto ctx) { return testMigrationBackend->fetchDiffTableSize(ctx); });
data::synchronous([&](auto ctx) { return testMigrationBackend_->fetchDiffTableSize(ctx); });
EXPECT_EQ(beforeDropSize, 0);
testMigrationManager->runMigration(DropTableMigratorName);
EXPECT_EQ(testMigrationManager->getMigratorStatusByName(DropTableMigratorName), MigratorStatus::Migrated);
testMigrationManager_->runMigration(kDROP_TABLE_MIGRATOR_NAME);
EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kDROP_TABLE_MIGRATOR_NAME), MigratorStatus::Migrated);
auto const newTableSize =
data::synchronous([&](auto ctx) { return testMigrationBackend->fetchDiffTableSize(ctx); });
data::synchronous([&](auto ctx) { return testMigrationBackend_->fetchDiffTableSize(ctx); });
EXPECT_EQ(newTableSize, std::nullopt);
}

View File

@@ -70,7 +70,7 @@ public:
void
writeTxIndexExample(std::string const& hash, std::string const& txType)
{
auto static insertTxIndexExample = [this]() {
auto static kINSERT_TX_INDEX_EXAMPLE = [this]() {
return handle_.prepare(fmt::format(
R"(
INSERT INTO {}
@@ -80,7 +80,7 @@ public:
data::cassandra::qualifiedTableName(settingsProvider_, "tx_index_example")
));
}();
executor_.writeSync(insertTxIndexExample.bind(hash, data::cassandra::Text(txType)));
executor_.writeSync(kINSERT_TX_INDEX_EXAMPLE.bind(hash, data::cassandra::Text(txType)));
}
/**
@@ -94,7 +94,7 @@ public:
std::optional<std::string>
fetchTxTypeViaID(std::string const& hash, boost::asio::yield_context ctx)
{
auto static fetchTxType = [this]() {
auto static kFETCH_TX_TYPE = [this]() {
return handle_.prepare(fmt::format(
R"(
SELECT tx_type FROM {} WHERE hash = ?
@@ -102,7 +102,7 @@ public:
data::cassandra::qualifiedTableName(settingsProvider_, "tx_index_example")
));
}();
auto const res = executor_.read(ctx, fetchTxType.bind(hash));
auto const res = executor_.read(ctx, kFETCH_TX_TYPE.bind(hash));
if (not res) {
return std::nullopt;
}
@@ -127,7 +127,7 @@ public:
std::optional<std::uint64_t>
fetchTxIndexTableSize(boost::asio::yield_context ctx)
{
auto static insertTxIndexExample = [this]() {
auto static kINSERT_TX_INDEX_EXAMPLE = [this]() {
return handle_.prepare(fmt::format(
R"(
SELECT COUNT(*) FROM {}
@@ -138,7 +138,7 @@ public:
// This function will be called after table being dropped, catch the exception
try {
auto const res = executor_.read(ctx, insertTxIndexExample);
auto const res = executor_.read(ctx, kINSERT_TX_INDEX_EXAMPLE);
if (not res) {
return std::nullopt;
}
@@ -166,7 +166,7 @@ public:
void
writeLedgerAccountHash(std::uint64_t sequence, std::string const& accountHash)
{
auto static insertLedgerExample = [this]() {
auto static kINSERT_LEDGER_EXAMPLE = [this]() {
return handle_.prepare(fmt::format(
R"(
INSERT INTO {}
@@ -176,7 +176,7 @@ public:
data::cassandra::qualifiedTableName(settingsProvider_, "ledger_example")
));
}();
executor_.writeSync(insertLedgerExample.bind(sequence, accountHash));
executor_.writeSync(kINSERT_LEDGER_EXAMPLE.bind(sequence, accountHash));
}
/**
@@ -190,7 +190,7 @@ public:
std::optional<ripple::uint256>
fetchAccountHashViaSequence(std::uint64_t sequence, boost::asio::yield_context ctx)
{
auto static fetchAccountHash = [this]() {
auto static kFETCH_ACCOUNT_HASH = [this]() {
return handle_.prepare(fmt::format(
R"(
SELECT account_hash FROM {} WHERE sequence = ?
@@ -198,7 +198,7 @@ public:
data::cassandra::qualifiedTableName(settingsProvider_, "ledger_example")
));
}();
auto const res = executor_.read(ctx, fetchAccountHash.bind(sequence));
auto const res = executor_.read(ctx, kFETCH_ACCOUNT_HASH.bind(sequence));
if (not res) {
return std::nullopt;
}
@@ -223,7 +223,7 @@ public:
std::optional<std::uint64_t>
fetchLedgerTableSize(boost::asio::yield_context ctx)
{
auto static insertLedgerExample = [this]() {
auto static kINSERT_LEDGER_EXAMPLE = [this]() {
return handle_.prepare(fmt::format(
R"(
SELECT COUNT(*) FROM {}
@@ -234,7 +234,7 @@ public:
// This function will be called after table being dropped, catch the exception
try {
auto const res = executor_.read(ctx, insertLedgerExample);
auto const res = executor_.read(ctx, kINSERT_LEDGER_EXAMPLE);
if (not res) {
return std::nullopt;
}
@@ -278,7 +278,7 @@ public:
std::optional<std::uint64_t>
fetchDiffTableSize(boost::asio::yield_context ctx)
{
auto static countDiff = [this]() {
auto static kCOUNT_DIFF = [this]() {
return handle_.prepare(fmt::format(
R"(
SELECT COUNT(*) FROM {}
@@ -289,7 +289,7 @@ public:
// This function will be called after table being dropped, catch the exception
try {
auto const res = executor_.read(ctx, countDiff);
auto const res = executor_.read(ctx, kCOUNT_DIFF);
if (not res) {
return std::nullopt;
}

File diff suppressed because one or more lines are too long

View File

@@ -22,8 +22,8 @@
#include <array>
#include <string>
extern std::array<std::string, 100> TransactionsRawData;
extern std::array<std::string, 100> gTransactionsRawData;
extern std::array<std::string, 100> ObjectsRawData;
extern std::array<std::string, 100> gObjectsRawData;
extern std::array<std::string, 50> LedgerHeaderRawData;
extern std::array<std::string, 50> gLedgerHeaderRawData;

View File

@@ -31,8 +31,8 @@
struct ExampleDropTableMigrator {
using Backend = CassandraMigrationTestBackend;
static constexpr char const* name = "ExampleDropTableMigrator";
static constexpr char const* description = "The migrator for dropping the table";
static constexpr char const* kNAME = "ExampleDropTableMigrator";
static constexpr char const* kDESCRIPTION = "The migrator for dropping the table";
static void
runMigration(std::shared_ptr<Backend> const& backend, util::config::ObjectView const& config);

View File

@@ -31,8 +31,8 @@
* via ledger sequence without full table scan.
*/
struct ExampleLedgerMigrator {
static constexpr char const* name = "ExampleLedgerMigrator";
static constexpr char const* description = "The migrator for ledgers table";
static constexpr char const* kNAME = "ExampleLedgerMigrator";
static constexpr char const* kDESCRIPTION = "The migrator for ledgers table";
using Backend = CassandraMigrationTestBackend;

View File

@@ -35,8 +35,8 @@
struct ExampleObjectsMigrator {
using Backend = CassandraMigrationTestBackend;
static constexpr char const* name = "ExampleObjectsMigrator";
static constexpr char const* description = "The migrator for objects table";
static constexpr char const* kNAME = "ExampleObjectsMigrator";
static constexpr char const* kDESCRIPTION = "The migrator for objects table";
static std::atomic_int64_t count;
static std::atomic_int64_t accountCount;

View File

@@ -30,8 +30,8 @@
* and migrate the data to index table. We create an index table for transaction hash to transaction type string.
*/
struct ExampleTransactionsMigrator {
static constexpr char const* name = "ExampleTransactionsMigrator";
static constexpr char const* description = "The migrator for transactions table";
static constexpr char const* kNAME = "ExampleTransactionsMigrator";
static constexpr char const* kDESCRIPTION = "The migrator for transactions table";
using Backend = CassandraMigrationTestBackend;
static std::uint64_t count;