diff --git a/test/raft/replication_test.cc b/test/raft/replication_test.cc index 3223768203..8c32a491c9 100644 --- a/test/raft/replication_test.cc +++ b/test/raft/replication_test.cc @@ -75,6 +75,61 @@ lowres_clock::duration tick_delta = 1ms; auto dummy_command = std::numeric_limits::min(); +// Updates can be +// - Entries +// - Leader change +// - Configuration change +struct entries { + size_t n; +}; +struct new_leader { + size_t id; +}; +struct leader { + size_t id; +}; +using partition = std::vector>; + +struct set_config_entry { + size_t node_idx; + bool can_vote; + + set_config_entry(size_t idx, bool can_vote = true) + : node_idx(idx), can_vote(can_vote) + {} +}; +using set_config = std::vector; + +struct tick { + uint64_t ticks; +}; + +using update = std::variant; + +struct log_entry { + unsigned term; + int value; +}; + +struct initial_log { + std::vector le; +}; + +struct initial_snapshot { + raft::snapshot snap; +}; + +struct test_case { + const size_t nodes; + const size_t total_values = 100; + uint64_t initial_term = 1; + const size_t initial_leader = 0; + const std::vector initial_states; + const std::vector initial_snapshots; + const std::vector config; + const std::vector updates; +}; + std::mt19937 random_generator() { auto& gen = seastar::testing::local_random_engine; return std::mt19937(gen()); @@ -396,16 +451,6 @@ public: std::unordered_map rpc::net; -struct set_config_entry { - size_t node_idx; - bool can_vote; - - set_config_entry(size_t idx, bool can_vote = true) - : node_idx(idx), can_vote(can_vote) - {} -}; -using set_config = std::vector; - struct test_server { std::unique_ptr server; state_machine* sm; @@ -521,11 +566,6 @@ void raft_cluster::connect_all() { _connected->connect_all(); } -struct log_entry { - unsigned term; - int value; -}; - std::vector create_log(std::vector list, unsigned start_idx) { std::vector log; @@ -554,46 +594,6 @@ size_t apply_changes(raft::server_id id, const std::vector& return entries; }; -// Updates can be -// - Entries -// - Leader change -// - Configuration change -struct entries { - size_t n; -}; -struct new_leader { - size_t id; -}; -struct leader { - size_t id; -}; -using partition = std::vector>; - -struct tick { - uint64_t ticks; -}; - -using update = std::variant; - -struct initial_log { - std::vector le; -}; - -struct initial_snapshot { - raft::snapshot snap; -}; - -struct test_case { - const size_t nodes; - const size_t total_values = 100; - uint64_t initial_term = 1; - const size_t initial_leader = 0; - const std::vector initial_states; - const std::vector initial_snapshots; - const std::vector config; - const std::vector updates; -}; - // Wait for leader log to propagate to follower future<> wait_log(raft_cluster& rafts, lw_shared_ptr connected, std::unordered_set& in_configuration,