From 8e506f10ed2016bb2e875c9290ffaa4fabff07c5 Mon Sep 17 00:00:00 2001 From: Michal Maslanka Date: Thu, 28 Jul 2022 09:11:37 +0200 Subject: [PATCH] r/tests: fixed incorrect assumptions in replace_whole_group test Fixed `replace_whole_group` test by waiting for the whole raft group to be up to date before executing configuration change. The test was flaky as sometimes the configuration was changed before propagating any records to one of the nodes (raft correctness is based on majority). This caused the condition validating if some batches are read to fail permanently. Fixes: #342 Signed-off-by: Michal Maslanka --- src/v/raft/tests/membership_test.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/v/raft/tests/membership_test.cc b/src/v/raft/tests/membership_test.cc index 5eb8839bccc3..231b35da17ef 100644 --- a/src/v/raft/tests/membership_test.cc +++ b/src/v/raft/tests/membership_test.cc @@ -247,6 +247,12 @@ FIXTURE_TEST(replace_whole_group, raft_test_fixture) { gr.enable_all(); info("replicating some batches"); auto res = replicate_random_batches(gr, 5).get0(); + // wait for all group members to have the same log + wait_for( + 10s, + [&] { return are_all_commit_indexes_the_same(gr); }, + "initially all replicas have the same committed offsets"); + // all nodes are replaced with new node gr.create_new_node(model::node_id(5)); std::vector new_members; @@ -292,7 +298,7 @@ FIXTURE_TEST(replace_whole_group, raft_test_fixture) { } auto last_old = old_nodes_log.begin()->second.back().last_offset(); auto last_new = new_nodes_log.begin()->second.back().last_offset(); - if (last_new <= last_old) { + if (last_new < last_old) { return false; } return std::all_of(