Skip to content

Commit 3017ce5

Browse files
author
Tytus Bierwiaczonek
authored
Merge pull request #2787 from vmware/stop_new_primary_during_view_change
stop new primary during view change testcase
2 parents 4c44668 + 4fe1b5e commit 3017ce5

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/apollo/test_skvbc_restart_recovery.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,59 @@ 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+
expected_final_view = expected_final_view + 1
533+
await skvbc.run_concurrent_ops(10)
534+
await bft_network.wait_for_view(
535+
replica_id=random.choice(bft_network.all_replicas(without={primary, next_primary})),
536+
expected=lambda v: v == expected_final_view,
537+
err_msg="Make sure view change has been triggered."
538+
)
539+
bft_network.start_replica(primary)
540+
bft_network.start_replica(next_primary)
541+
542+
await trio.sleep(seconds=10)
543+
544+
await bft_network.wait_for_fast_path_to_be_prevalent(
545+
run_ops=lambda: skvbc.run_concurrent_ops(num_ops=20, write_weight=1), threshold=20)
546+
547+
495548
@with_trio
496549
@with_bft_network(start_replica_cmd, selected_configs=lambda n, f, c: c == 0, rotate_keys=True)
497550
@verify_linearizability()

0 commit comments

Comments
 (0)