From ea53c63af8e58485c268c9f4ca8e6b5a6e52082d Mon Sep 17 00:00:00 2001 From: Eddy Ashton Date: Thu, 5 Jan 2023 09:31:56 +0000 Subject: [PATCH] Only set low timeouts when we expect `wait_for_new_primary` to fail (#4798) --- tests/election.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/election.py b/tests/election.py index 8d8b111c1..d017ab0a2 100644 --- a/tests/election.py +++ b/tests/election.py @@ -37,7 +37,7 @@ def test_kill_primary_no_reqs(network, args): old_primary.stop() - new_primary, _ = network.wait_for_new_primary(old_primary, timeout_multiplier=5) + new_primary, _ = network.wait_for_new_primary(old_primary) with new_primary.client() as c: # Get the current view history @@ -220,14 +220,23 @@ def run(args): network.wait_for_all_nodes_to_commit(tx_id=TxID(res.view, res.seqno)) - try: + if node_to_stop == nodes_to_stop - 1: + # Killing this node goes past the service's fault tolerance threshold, so no primary can now be elected + primary.stop() + + try: + # Use smaller timeout multiplier since we expect the service to be stuck, so must wait this long + network.wait_for_new_primary( + primary, + timeout_multiplier=5, + ) + except PrimaryNotFound: + primary_is_known = False + else: + assert False, "Expected no primary to be found!" + else: test_kill_primary_no_reqs(network, args) test_commit_view_history(network, args) - except PrimaryNotFound: - if node_to_stop < nodes_to_stop - 1: - raise - else: - primary_is_known = False assert not primary_is_known, "Primary is still known" LOG.success("Test ended successfully.")