|
11 | 11 | from integration.ha.ha_helpers import (
|
12 | 12 | add_k8s_hosts,
|
13 | 13 | assert_continuous_writes_consistency,
|
| 14 | + delete_pod, |
14 | 15 | get_topic_description,
|
15 | 16 | get_topic_offsets,
|
16 | 17 | modify_pebble_restart_delay,
|
@@ -335,3 +336,41 @@ async def test_full_cluster_restart(
|
335 | 336 |
|
336 | 337 | result = c_writes.stop()
|
337 | 338 | assert_continuous_writes_consistency(result=result)
|
| 339 | + |
| 340 | + |
| 341 | +async def test_pod_reschedule( |
| 342 | + ops_test: OpsTest, |
| 343 | + c_writes: ContinuousWrites, |
| 344 | + c_writes_runner: ContinuousWrites, |
| 345 | +): |
| 346 | + # Let some time pass to create messages |
| 347 | + await asyncio.sleep(5) |
| 348 | + topic_description = get_topic_description(ops_test=ops_test, topic=ContinuousWrites.TOPIC_NAME) |
| 349 | + initial_leader_num = topic_description.leader |
| 350 | + |
| 351 | + logger.info( |
| 352 | + f"Killing pod of leader for topic '{ContinuousWrites.TOPIC_NAME}': {initial_leader_num}" |
| 353 | + ) |
| 354 | + delete_pod(ops_test, unit_name=f"{APP_NAME}/{initial_leader_num}") |
| 355 | + |
| 356 | + # let pod reschedule process be noticed up by juju |
| 357 | + await ops_test.model.wait_for_idle( |
| 358 | + apps=[APP_NAME], idle_period=30, status="active", timeout=1000 |
| 359 | + ) |
| 360 | + |
| 361 | + # refresh hosts with the new ip |
| 362 | + remove_k8s_hosts(ops_test=ops_test) |
| 363 | + add_k8s_hosts(ops_test=ops_test) |
| 364 | + |
| 365 | + # Check offsets after killing leader |
| 366 | + initial_offsets = get_topic_offsets(ops_test=ops_test, topic=ContinuousWrites.TOPIC_NAME) |
| 367 | + await asyncio.sleep(CLIENT_TIMEOUT * 2) |
| 368 | + next_offsets = get_topic_offsets(ops_test=ops_test, topic=ContinuousWrites.TOPIC_NAME) |
| 369 | + assert int(next_offsets[-1]) > int(initial_offsets[-1]) |
| 370 | + |
| 371 | + topic_description = get_topic_description(ops_test=ops_test, topic=ContinuousWrites.TOPIC_NAME) |
| 372 | + assert initial_leader_num != topic_description.leader |
| 373 | + assert topic_description.in_sync_replicas == {0, 1, 2} |
| 374 | + |
| 375 | + result = c_writes.stop() |
| 376 | + assert_continuous_writes_consistency(result=result) |
0 commit comments