From 5daf0c7b9946e1fe4cb27b8e855f727faedf13a7 Mon Sep 17 00:00:00 2001 From: Amaury Chamayou Date: Tue, 19 Dec 2023 14:52:53 +0000 Subject: [PATCH] Allow driver to name the first node (#5876) --- src/consensus/aft/test/driver.cpp | 4 ++-- src/consensus/aft/test/driver.h | 5 ++--- tests/raft_scenarios/append | 2 +- tests/raft_scenarios/startup | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/consensus/aft/test/driver.cpp b/src/consensus/aft/test/driver.cpp index a3f9aae90e8d..6b48425ce692 100644 --- a/src/consensus/aft/test/driver.cpp +++ b/src/consensus/aft/test/driver.cpp @@ -83,8 +83,8 @@ int main(int argc, char** argv) switch (shash(in)) { case shash("start_node"): - assert(items.size() == 1); - driver->create_start_node(lineno); + assert(items.size() == 2); + driver->create_start_node(items[1], lineno); break; case shash("trust_node"): assert(items.size() == 3); diff --git a/src/consensus/aft/test/driver.h b/src/consensus/aft/test/driver.h index 5578fe3648b6..19f006832536 100644 --- a/src/consensus/aft/test/driver.h +++ b/src/consensus/aft/test/driver.h @@ -219,13 +219,12 @@ class RaftDriver << std::endl; } - void create_start_node(const size_t lineno) + void create_start_node(const std::string& start_node_id, const size_t lineno) { if (!_nodes.empty()) { throw std::logic_error("Start node already exists"); } - const std::string start_node_id = "0"; kv::Configuration::Nodes configuration; add_node(start_node_id); configuration.try_emplace(start_node_id); @@ -240,7 +239,7 @@ class RaftDriver void trust_nodes( const std::string& term, - std::vector node_ids, + const std::vector& node_ids, const size_t lineno) { for (const auto& node_id : node_ids) diff --git a/tests/raft_scenarios/append b/tests/raft_scenarios/append index 2f9c0a16d28f..4222c2ea6f6d 100644 --- a/tests/raft_scenarios/append +++ b/tests/raft_scenarios/append @@ -1,6 +1,6 @@ # Create a Start Node, commit initial transaction and signature # Append transaction to the node's log, observe that they are committed -start_node +start_node,0 assert_is_primary,0 emit_signature,2 diff --git a/tests/raft_scenarios/startup b/tests/raft_scenarios/startup index 66d682b30bb1..19f23962839b 100644 --- a/tests/raft_scenarios/startup +++ b/tests/raft_scenarios/startup @@ -1,6 +1,6 @@ # Create a Start Node, commit initial transaction and signature # https://microsoft.github.io/CCF/main/operations/start_network.html#starting-the-first-node -start_node +start_node,0 assert_is_primary,0 emit_signature,2