Skip to content

Commit e8d4a55

Browse files
author
tbierwiaczon
committed
stop new primary during view chagne testcase
1 parent 4c44668 commit e8d4a55

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/apollo/test_skvbc_restart_recovery.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,50 @@ async def test_recovering_of_primary_with_initiated_view_change(self, bft_networ
492492

493493
await bft_network.wait_for_replicas_to_reach_at_least_view(replicas_ids=bft_network.all_replicas(), expected_view=view, timeout=20 + timeouts)
494494

495+
@with_trio
496+
@with_bft_network(start_replica_cmd, selected_configs=lambda n, f, c: c == 0, rotate_keys=True)
497+
@verify_linearizability()
498+
async def test_stop_primary_during_initiated_view_change(self, bft_network, tracker):
499+
# 1. Start all replicas.
500+
# 2. Introduce client requests.
501+
# 3. In parallel to the requests, crash the Primary.
502+
# 4. Wait for the system to perform a View Change.
503+
# 5. During the View Change Process stop the New Primary while the replicas are rebuilding the previous View's Working Window. This might require functionality not present in Apollo to be able to stop the selected replica in the appropriate moment.
504+
# 6. Wait for the system to move to the next View.
505+
# 7. Start All previously stopped replicas.
506+
# 8. Wait for Fast Commit Path to recover.
507+
# 9. Goto step 2.
508+
509+
skvbc = kvbc.SimpleKVBCProtocol(bft_network, tracker)
510+
511+
[bft_network.start_replica(i) for i in bft_network.all_replicas()]
512+
513+
514+
for i in range(loops):
515+
516+
await skvbc.run_concurrent_ops(100)
517+
518+
primary = await bft_network.get_current_primary()
519+
next_primary = (primary + 1) % bft_network.config.n
520+
expected_final_view = await bft_network.get_current_view() + 1
521+
522+
bft_network.stop_replica(primary)
523+
await skvbc.run_concurrent_ops(10)
524+
await bft_network.wait_for_view(
525+
replica_id=random.choice(bft_network.all_replicas(without={primary})),
526+
expected=lambda v: v == expected_final_view,
527+
err_msg="Make sure view change has been triggered."
528+
)
529+
530+
bft_network.stop_replica(next_primary)
531+
532+
bft_network.start_replica(primary)
533+
bft_network.start_replica(next_primary)
534+
535+
await bft_network.wait_for_fast_path_to_be_prevalent(
536+
run_ops=lambda: skvbc.run_concurrent_ops(num_ops=20, write_weight=1), threshold=20)
537+
538+
495539
@with_trio
496540
@with_bft_network(start_replica_cmd, selected_configs=lambda n, f, c: c == 0, rotate_keys=True)
497541
@verify_linearizability()

0 commit comments

Comments
 (0)