mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-21 12:15:54 +00:00
committed by
GitHub
parent
fc3e60f17f
commit
64b50b419f
@@ -71,8 +71,8 @@ CliArgs::parse(int argc, char const* argv[])
|
|||||||
if (parsed.count("migrate") != 0u) {
|
if (parsed.count("migrate") != 0u) {
|
||||||
auto const opt = parsed["migrate"].as<std::string>();
|
auto const opt = parsed["migrate"].as<std::string>();
|
||||||
if (opt == "status")
|
if (opt == "status")
|
||||||
return Action{Action::Migrate{std::move(configPath), MigrateSubCmd::status()}};
|
return Action{Action::Migrate{.configPath=std::move(configPath), .subCmd=MigrateSubCmd::status()}};
|
||||||
return Action{Action::Migrate{std::move(configPath), MigrateSubCmd::migration(opt)}};
|
return Action{Action::Migrate{.configPath=std::move(configPath), .subCmd=MigrateSubCmd::migration(opt)}};
|
||||||
}
|
}
|
||||||
|
|
||||||
return Action{Action::Run{.configPath = std::move(configPath), .useNgWebServer = parsed.count("ng-web-server") != 0}
|
return Action{Action::Run{.configPath = std::move(configPath), .useNgWebServer = parsed.count("ng-web-server") != 0}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "migration/MigrationApplication.hpp"
|
#include "migration/MigrationApplication.hpp"
|
||||||
#include "rpc/common/impl/HandlerProvider.hpp"
|
#include "rpc/common/impl/HandlerProvider.hpp"
|
||||||
#include "util/TerminationHandler.hpp"
|
#include "util/TerminationHandler.hpp"
|
||||||
#include "util/config/Config.hpp"
|
|
||||||
#include "util/log/Logger.hpp"
|
#include "util/log/Logger.hpp"
|
||||||
#include "util/newconfig/ConfigDefinition.hpp"
|
#include "util/newconfig/ConfigDefinition.hpp"
|
||||||
#include "util/newconfig/ConfigFileJson.hpp"
|
#include "util/newconfig/ConfigFileJson.hpp"
|
||||||
|
|||||||
@@ -89,14 +89,14 @@ class FullTableScanner {
|
|||||||
return {TokenRange{minValue, maxValue}};
|
return {TokenRange{minValue, maxValue}};
|
||||||
|
|
||||||
// Safely calculate the range size using uint64_t to avoid overflow
|
// Safely calculate the range size using uint64_t to avoid overflow
|
||||||
uint64_t rangeSize = (static_cast<uint64_t>(maxValue) * 2) / numRanges_;
|
uint64_t const rangeSize = (static_cast<uint64_t>(maxValue) * 2) / numRanges_;
|
||||||
|
|
||||||
std::vector<TokenRange> ranges;
|
std::vector<TokenRange> ranges;
|
||||||
ranges.reserve(numRanges_);
|
ranges.reserve(numRanges_);
|
||||||
|
|
||||||
for (std::int64_t i = 0; i < numRanges_; ++i) {
|
for (std::int64_t i = 0; i < numRanges_; ++i) {
|
||||||
int64_t start = minValue + i * rangeSize;
|
int64_t const start = minValue + (i * rangeSize);
|
||||||
int64_t end = (i == numRanges_ - 1) ? maxValue : start + static_cast<int64_t>(rangeSize) - 1;
|
int64_t const end = (i == numRanges_ - 1) ? maxValue : start + static_cast<int64_t>(rangeSize) - 1;
|
||||||
ranges.emplace_back(start, end);
|
ranges.emplace_back(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "migration/cassandra/impl/ObjectsAdapter.hpp"
|
#include "migration/cassandra/impl/ObjectsAdapter.hpp"
|
||||||
|
|
||||||
#include <boost/asio/spawn.hpp>
|
|
||||||
#include <xrpl/protocol/STLedgerEntry.h>
|
#include <xrpl/protocol/STLedgerEntry.h>
|
||||||
#include <xrpl/protocol/Serializer.h>
|
#include <xrpl/protocol/Serializer.h>
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "migration/cassandra/impl/TransactionsAdapter.hpp"
|
#include "migration/cassandra/impl/TransactionsAdapter.hpp"
|
||||||
|
|
||||||
#include <boost/asio/spawn.hpp>
|
|
||||||
#include <xrpl/protocol/STTx.h>
|
#include <xrpl/protocol/STTx.h>
|
||||||
#include <xrpl/protocol/Serializer.h>
|
#include <xrpl/protocol/Serializer.h>
|
||||||
#include <xrpl/protocol/TxMeta.h>
|
#include <xrpl/protocol/TxMeta.h>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace migration::impl {
|
namespace migration::impl {
|
||||||
@@ -51,9 +52,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
explicit MigrationManagerBase(
|
explicit MigrationManagerBase(
|
||||||
std::shared_ptr<typename SupportedMigrators::BackendType> backend,
|
std::shared_ptr<typename SupportedMigrators::BackendType> backend,
|
||||||
util::config::ObjectView const& config
|
util::config::ObjectView config
|
||||||
)
|
)
|
||||||
: migrators_{backend}, config_{config}
|
: migrators_{backend}, config_{std::move(config)}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public:
|
|||||||
return "No Description";
|
return "No Description";
|
||||||
} else {
|
} else {
|
||||||
// Fold expression to search through all types
|
// Fold expression to search through all types
|
||||||
std::string result = ([](std::string const& name) {
|
std::string const result = ([](std::string const& name) {
|
||||||
return std::string(getDescriptionIfMatch<MigratorType>(name));
|
return std::string(getDescriptionIfMatch<MigratorType>(name));
|
||||||
}(name) + ...);
|
}(name) + ...);
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,7 @@
|
|||||||
#include "util/newconfig/Types.hpp"
|
#include "util/newconfig/Types.hpp"
|
||||||
|
|
||||||
#include <TestGlobals.hpp>
|
#include <TestGlobals.hpp>
|
||||||
#include <boost/json/parse.hpp>
|
#include <algorithm>
|
||||||
#include <boost/json/value.hpp>
|
|
||||||
#include <fmt/core.h>
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <xrpl/basics/base_uint.h>
|
#include <xrpl/basics/base_uint.h>
|
||||||
|
|
||||||
@@ -215,7 +213,7 @@ class MigrationCassandraManagerTxTableTest : public MigrationCassandraSimpleTest
|
|||||||
Handle const handle{TestGlobals::instance().backendHost};
|
Handle const handle{TestGlobals::instance().backendHost};
|
||||||
EXPECT_TRUE(handle.connect());
|
EXPECT_TRUE(handle.connect());
|
||||||
|
|
||||||
std::for_each(std::begin(TransactionsRawData), std::end(TransactionsRawData), [&](auto const& value) {
|
std::ranges::for_each(TransactionsRawData, [&](auto const& value) {
|
||||||
writeTxFromCSVString(TestGlobals::instance().backendKeyspace, value, handle);
|
writeTxFromCSVString(TestGlobals::instance().backendKeyspace, value, handle);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -24,7 +24,6 @@
|
|||||||
#include "util/Assert.hpp"
|
#include "util/Assert.hpp"
|
||||||
#include "util/newconfig/ObjectView.hpp"
|
#include "util/newconfig/ObjectView.hpp"
|
||||||
|
|
||||||
#include <boost/asio/io_context.hpp>
|
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ ExampleTransactionsMigrator::runMigration(
|
|||||||
backend,
|
backend,
|
||||||
[&](ripple::STTx const& tx, ripple::TxMeta const&) {
|
[&](ripple::STTx const& tx, ripple::TxMeta const&) {
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> const lock(mtx);
|
||||||
hashSet.insert(ripple::to_string(tx.getTransactionID()));
|
hashSet.insert(ripple::to_string(tx.getTransactionID()));
|
||||||
}
|
}
|
||||||
auto const json = tx.getJson(ripple::JsonOptions::none);
|
auto const json = tx.getJson(ripple::JsonOptions::none);
|
||||||
|
|||||||
@@ -22,37 +22,36 @@
|
|||||||
#include "data/cassandra/impl/Result.hpp"
|
#include "data/cassandra/impl/Result.hpp"
|
||||||
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
data::cassandra::ResultOrError
|
static data::cassandra::ResultOrError
|
||||||
writeTxFromCSVString(std::string const& space, std::string const& record, data::cassandra::Handle const& handler)
|
writeTxFromCSVString(std::string const& space, std::string const& record, data::cassandra::Handle const& handler)
|
||||||
{
|
{
|
||||||
std::string statement = fmt::format(
|
std::string const statement = fmt::format(
|
||||||
"INSERT INTO {}.transactions (hash, date, ledger_sequence, metadata, transaction) VALUES ({})", space, record
|
"INSERT INTO {}.transactions (hash, date, ledger_sequence, metadata, transaction) VALUES ({})", space, record
|
||||||
);
|
);
|
||||||
|
|
||||||
return handler.execute(statement);
|
return handler.execute(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
data::cassandra::ResultOrError
|
static data::cassandra::ResultOrError
|
||||||
writeObjectFromCSVString(std::string const& space, std::string const& record, data::cassandra::Handle const& handler)
|
writeObjectFromCSVString(std::string const& space, std::string const& record, data::cassandra::Handle const& handler)
|
||||||
{
|
{
|
||||||
std::string statement = fmt::format("INSERT INTO {}.objects (key, sequence, object) VALUES ({})", space, record);
|
std::string const statement = fmt::format("INSERT INTO {}.objects (key, sequence, object) VALUES ({})", space, record);
|
||||||
|
|
||||||
return handler.execute(statement);
|
return handler.execute(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
data::cassandra::ResultOrError
|
static data::cassandra::ResultOrError
|
||||||
writeLedgerFromCSVString(std::string const& space, std::string const& record, data::cassandra::Handle const& handler)
|
writeLedgerFromCSVString(std::string const& space, std::string const& record, data::cassandra::Handle const& handler)
|
||||||
{
|
{
|
||||||
std::string statement = fmt::format("INSERT INTO {}.ledgers (sequence, header) VALUES ({})", space, record);
|
std::string const statement = fmt::format("INSERT INTO {}.ledgers (sequence, header) VALUES ({})", space, record);
|
||||||
return handler.execute(statement);
|
return handler.execute(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
data::cassandra::ResultOrError
|
static data::cassandra::ResultOrError
|
||||||
writeLedgerRange(
|
writeLedgerRange(
|
||||||
std::string const& space,
|
std::string const& space,
|
||||||
std::uint32_t minSeq,
|
std::uint32_t minSeq,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ struct MigrationManagerBaseTest : public util::prometheus::WithMockPrometheus, p
|
|||||||
MigrationManagerBaseTest()
|
MigrationManagerBaseTest()
|
||||||
{
|
{
|
||||||
auto mockBackendPtr = backend_.operator std::shared_ptr<MockMigrationBackend>();
|
auto mockBackendPtr = backend_.operator std::shared_ptr<MockMigrationBackend>();
|
||||||
TestMigratorRegister migratorRegister(mockBackendPtr);
|
TestMigratorRegister const migratorRegister(mockBackendPtr);
|
||||||
migrationManager = std::make_shared<TestCassandraMigrationManager>(mockBackendPtr, cfg.getObject("migration"));
|
migrationManager = std::make_shared<TestCassandraMigrationManager>(mockBackendPtr, cfg.getObject("migration"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -67,13 +67,13 @@ TEST_F(MigrationManagerBaseTest, AllStatus)
|
|||||||
auto const status = migrationManager->allMigratorsStatusPairs();
|
auto const status = migrationManager->allMigratorsStatusPairs();
|
||||||
EXPECT_EQ(status.size(), 2);
|
EXPECT_EQ(status.size(), 2);
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
std::find(
|
std::ranges::find(
|
||||||
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::Migrated)
|
status, std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::Migrated)
|
||||||
) != status.end()
|
) != status.end()
|
||||||
);
|
);
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
std::find(
|
std::ranges::find(
|
||||||
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
|
status, std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
|
||||||
) != status.end()
|
) != status.end()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#include "util/newconfig/ConfigValue.hpp"
|
#include "util/newconfig/ConfigValue.hpp"
|
||||||
#include "util/newconfig/Types.hpp"
|
#include "util/newconfig/Types.hpp"
|
||||||
|
|
||||||
#include <boost/json/parse.hpp>
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
struct MigrationManagerFactoryTests : public NoLoggerFixture {};
|
struct MigrationManagerFactoryTests : public NoLoggerFixture {};
|
||||||
|
|||||||
@@ -88,13 +88,13 @@ TEST_F(MultipleMigratorRegisterTests, GetMigratorsStatusWhenError)
|
|||||||
auto const status = migratorRegister->getMigratorsStatus();
|
auto const status = migratorRegister->getMigratorsStatus();
|
||||||
EXPECT_EQ(status.size(), 2);
|
EXPECT_EQ(status.size(), 2);
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
std::find(
|
std::ranges::find(
|
||||||
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::NotMigrated)
|
status, std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::NotMigrated)
|
||||||
) != status.end()
|
) != status.end()
|
||||||
);
|
);
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
std::find(
|
std::ranges::find(
|
||||||
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
|
status, std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
|
||||||
) != status.end()
|
) != status.end()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -108,13 +108,13 @@ TEST_F(MultipleMigratorRegisterTests, GetMigratorsStatusWhenReturnInvalidStatus)
|
|||||||
auto const status = migratorRegister->getMigratorsStatus();
|
auto const status = migratorRegister->getMigratorsStatus();
|
||||||
EXPECT_EQ(status.size(), 2);
|
EXPECT_EQ(status.size(), 2);
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
std::find(
|
std::ranges::find(
|
||||||
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::NotMigrated)
|
status, std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::NotMigrated)
|
||||||
) != status.end()
|
) != status.end()
|
||||||
);
|
);
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
std::find(
|
std::ranges::find(
|
||||||
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
|
status, std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
|
||||||
) != status.end()
|
) != status.end()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -128,13 +128,13 @@ TEST_F(MultipleMigratorRegisterTests, GetMigratorsStatusWhenOneMigrated)
|
|||||||
auto const status = migratorRegister->getMigratorsStatus();
|
auto const status = migratorRegister->getMigratorsStatus();
|
||||||
EXPECT_EQ(status.size(), 2);
|
EXPECT_EQ(status.size(), 2);
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
std::find(
|
std::ranges::find(
|
||||||
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::Migrated)
|
status, std::make_tuple("SimpleTestMigrator", migration::MigratorStatus::Migrated)
|
||||||
) != status.end()
|
) != status.end()
|
||||||
);
|
);
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
std::find(
|
std::ranges::find(
|
||||||
status.begin(), status.end(), std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
|
status, std::make_tuple("SimpleTestMigrator2", migration::MigratorStatus::NotMigrated)
|
||||||
) != status.end()
|
) != status.end()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -165,8 +165,8 @@ TEST_F(MultipleMigratorRegisterTests, Names)
|
|||||||
{
|
{
|
||||||
auto names = migratorRegister->getMigratorNames();
|
auto names = migratorRegister->getMigratorNames();
|
||||||
EXPECT_EQ(names.size(), 2);
|
EXPECT_EQ(names.size(), 2);
|
||||||
EXPECT_TRUE(std::find(names.begin(), names.end(), "SimpleTestMigrator") != names.end());
|
EXPECT_TRUE(std::ranges::find(names, "SimpleTestMigrator") != names.end());
|
||||||
EXPECT_TRUE(std::find(names.begin(), names.end(), "SimpleTestMigrator2") != names.end());
|
EXPECT_TRUE(std::ranges::find(names, "SimpleTestMigrator2") != names.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultipleMigratorRegisterTests, Description)
|
TEST_F(MultipleMigratorRegisterTests, Description)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ TEST(MigratiorStatus, FromString)
|
|||||||
|
|
||||||
TEST(MigratiorStatus, Compare)
|
TEST(MigratiorStatus, Compare)
|
||||||
{
|
{
|
||||||
migration::MigratorStatus status1(migration::MigratorStatus::Migrated);
|
migration::MigratorStatus const status1(migration::MigratorStatus::Migrated);
|
||||||
migration::MigratorStatus status2(migration::MigratorStatus::Migrated);
|
migration::MigratorStatus status2(migration::MigratorStatus::Migrated);
|
||||||
EXPECT_TRUE(status1 == status2);
|
EXPECT_TRUE(status1 == status2);
|
||||||
status2 = migration::MigratorStatus(migration::MigratorStatus::NotMigrated);
|
status2 = migration::MigratorStatus(migration::MigratorStatus::NotMigrated);
|
||||||
|
|||||||
Reference in New Issue
Block a user