From 6d4323d2e05ee7404da4160aa66d6dcae2725da0 Mon Sep 17 00:00:00 2001 From: Eddy Ashton Date: Tue, 24 Oct 2023 16:08:28 +0100 Subject: [PATCH] Modify `bad_network` scenario to be deterministic (#5767) --- tests/raft_scenarios/bad_network | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/raft_scenarios/bad_network b/tests/raft_scenarios/bad_network index 11fd7f73aa86..2627eba06521 100644 --- a/tests/raft_scenarios/bad_network +++ b/tests/raft_scenarios/bad_network @@ -9,6 +9,7 @@ dispatch_all periodic_all,10 dispatch_all +assert_is_primary,0 # An initial entry is written and successfully replicated replicate,1,helloworld @@ -35,10 +36,6 @@ periodic_all,10 drop_pending,0 dispatch_all -periodic_all,10 -drop_pending,0 -dispatch_all - # Before either follower times out, the message eventually reaches Node 1 (though not Node 2) periodic_all,10 drop_pending_to,0,2 @@ -60,9 +57,11 @@ dispatch_all_once # Eventually Node 2 is partitioned for so long that it calls an election periodic_one,2,100 +assert_is_candidate,2 # But this RequestVote is lost! periodic_all,10 +assert_is_backup,1 drop_pending,1 #< The ACKs from 1 are constantly dropped drop_pending,2 dispatch_all_once @@ -82,12 +81,13 @@ drop_pending,2 periodic_one,2,100 drop_pending,2 -# TODO: Add more precise state assert? Currently 2 is @5.1, and is a Candidate +assert_is_candidate,2 # Eventually Node 1 stops hearing from Node 0, and calls an election state_all drop_pending,1 periodic_one,1,100 +assert_is_candidate,1 dispatch_all_once #< Finally, everyone hears about this! drop_pending,0 #< Node 0's response (in favour is dropped) @@ -111,6 +111,7 @@ dispatch_all_once # Node 1 is now primary, though it still doesn't know that 2 is committed state_all +assert_is_primary,1 # Now we allow the network to heal and return to normal periodic_all,10