20#include <test/nodestore/TestBase.h>
21#include <test/unit_test/SuiteJournal.h>
23#include <xrpld/nodestore/DummyScheduler.h>
24#include <xrpld/nodestore/Manager.h>
26#include <xrpl/basics/BasicConfig.h>
27#include <xrpl/basics/ByteUtilities.h>
28#include <xrpl/beast/utility/temp_dir.h>
44 params.
set(
"type",
"nudb");
45 params.
set(
"path", path);
46 if (!blockSize.empty())
47 params.
set(
"nudb_block_size", blockSize);
63 params,
megabytes(4), scheduler, journal);
65 if (!BEAST_EXPECT(backend))
68 if (!BEAST_EXPECT(backend->getBlockSize() == expectedBlocksize))
73 if (!BEAST_EXPECT(backend->isOpen()))
105 params,
megabytes(4), scheduler, journal);
108 BEAST_EXPECT(logOutput.
find(expectedMessage) != std::string::npos);
123 params,
megabytes(4), scheduler, journal);
127 logOutput.
find(
"Invalid nudb_block_size") != std::string::npos;
129 BEAST_EXPECT(hasWarning == !shouldWork);
136 testcase(
"Default block size (no nudb_block_size specified)");
152 for (
auto const& size : validSizes)
187 for (
auto const& size : invalidSizes)
202 for (
auto const& size : whitespaceInvalidSizes)
215 testcase(
"Log message verification");
225 "Using custom NuDB block size: 8192");
240 params,
megabytes(4), scheduler, journal);
247 logOutput.find(
"Invalid nudb_block_size: 5000") !=
251 "Must be power of 2 between 4096 and 32768") !=
268 params,
megabytes(4), scheduler, journal);
276 logOutput.find(
"Invalid nudb_block_size value: invalid") !=
285 testcase(
"Power of 2 validation logic");
300 for (
auto const& [size, shouldWork] : testCases)
314 params,
megabytes(4), scheduler, journal);
315 BEAST_EXPECT(shouldWork);
321 logOutput.find(
"Invalid nudb_block_size") !=
330 testcase(
"Both constructor variants work with custom block size");
341 params,
megabytes(4), scheduler, journal);
342 BEAST_EXPECT(backend1 !=
nullptr);
355 testcase(
"Configuration parsing edge cases");
372 for (
auto const& format : validFormats)
382 params,
megabytes(4), scheduler, journal);
386 bool hasSuccessMessage =
387 logOutput.
find(
"Using custom NuDB block size") !=
389 BEAST_EXPECT(hasSuccessMessage);
394 for (
auto const& format : whitespaceFormats)
407 params,
megabytes(4), scheduler, journal);
421 testcase(
"Data persistence with different block sizes");
424 "4096",
"8192",
"16384",
"32768"};
426 for (
auto const& size : blockSizes)
440 params,
megabytes(4), scheduler, journal);
449 params,
megabytes(4), scheduler, journal);
A generic endpoint for log messages.
RAII temporary directory.
std::string path() const
Get the native path for the temporary directory.
testcase_t testcase
Memberspace for declaring test cases.
void fail(String const &reason, char const *file, int line)
Record a failure.
Simple NodeStore Scheduler that just peforms the tasks synchronously.
virtual std::unique_ptr< Backend > make_Backend(Section const ¶meters, std::size_t burstSize, Scheduler &scheduler, beast::Journal journal)=0
Create a backend.
static Manager & instance()
Returns the instance of the manager singleton.
void testBothConstructorVariants()
void testInvalidBlockSizes()
Section createSection(std::string const &path, std::string const &blockSize="")
void testDefaultBlockSize()
void testPowerOfTwoValidation()
void testLogMessage(Section const ¶ms, beast::severities::Severity level, std::string const &expectedMessage)
void run() override
Runs the suite.
void testPowerOfTwoValidation(std::string const &size, bool shouldWork)
void testConfigurationParsing()
bool testBackendFunctionality(Section const ¶ms, std::size_t expectedBlocksize)
void testDataPersistence()
void testValidBlockSizes()
static Batch createPredictableBatch(int numObjects, std::uint64_t seed)
static bool areBatchesEqual(Batch const &lhs, Batch const &rhs)
void fetchCopyOfBatch(Backend &backend, Batch *pCopy, Batch const &batch)
void storeBatch(Backend &backend, Batch const &batch)
Holds a collection of configuration values.
void set(std::string const &key, std::string const &value)
Set a key/value pair.
std::stringstream const & messages() const
Severity
Severity level / threshold of a Journal message.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr auto megabytes(T value) noexcept
std::string to_string(base_uint< Bits, Tag > const &a)