Skip to content

Commit

Permalink
raft/tests: add test for stuck append_entries
Browse files Browse the repository at this point in the history
Simulates stuck append entries which supress heartbeats resulting
in a leader step down.

(cherry picked from commit 4e92622)
  • Loading branch information
bharathv committed Jul 1, 2024
1 parent dc47651 commit cd0d236
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/v/raft/tests/basic_raft_fixture_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,29 @@ TEST_F(raft_fixture, test_empty_writes) {
replicate(std::move(reader)).get(), "Assert failure.+Empty batch");
}

TEST_F_CORO(raft_fixture, test_stuck_append_entries) {
co_await create_simple_group(3);
auto leader = co_await wait_for_leader(10s);

for (auto& [_, node] : nodes()) {
node->on_dispatch([](model::node_id, raft::msg_type t) {
if (t == raft::msg_type::append_entries) {
return ss::sleep(2s);
}
return ss::now();
});
}
// hold up heartbeats
auto& leader_node = node(leader);
auto raft = leader_node.raft();
auto term_before = raft->term();
auto result = co_await raft->replicate(
make_batches({{"k", "v"}}),
replicate_options(consistency_level::quorum_ack));
ASSERT_TRUE_CORO(!result.has_error());
ASSERT_EQ_CORO(term_before, raft->term());
}

struct test_parameters {
consistency_level c_lvl;
bool write_caching;
Expand Down

0 comments on commit cd0d236

Please sign in to comment.