Skip to content

Commit 63e12eb

Browse files
committed
handle error: storage belongs to different cluster
1 parent df4f486 commit 63e12eb

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

tests/integration/ha_tests/helpers.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ def storage_id(ops_test, unit_name):
807807
return line.split()[1]
808808

809809

810-
async def add_unit_with_storage(ops_test, app, storage):
810+
async def add_unit_with_storage(ops_test, app, storage, is_blocked: bool= False):
811811
"""Adds unit with storage.
812812
813813
Note: this function exists as a temporary solution until this issue is resolved:
@@ -820,7 +820,14 @@ async def add_unit_with_storage(ops_test, app, storage):
820820
return_code, _, _ = await ops_test.juju(*add_unit_cmd)
821821
assert return_code == 0, "Failed to add unit with storage"
822822
async with ops_test.fast_forward():
823-
await ops_test.model.wait_for_idle(apps=[app], status="active", timeout=2000)
823+
if is_blocked:
824+
application = ops_test.model.applications[app]
825+
await ops_test.model.block_until(
826+
lambda: "blocked" in {unit.workload_status for unit in application.units},
827+
timeout=1500,
828+
)
829+
else:
830+
await ops_test.model.wait_for_idle(apps=[app], status="active", timeout=1500)
824831
assert (
825832
len(ops_test.model.applications[app].units) == expected_units
826833
), "New unit not added to model"

tests/integration/ha_tests/test_self_healing.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,7 @@ async def test_deploy_zero_units(ops_test: OpsTest, charm):
619619

620620
logger.info("scaling database to tow unit using foreign cluster's storage")
621621
new_unit = await add_unit_with_storage(ops_test, app=app, storage=second_storage)
622-
application = ops_test.model.applications[app]
623-
await ops_test.model.block_until(
624-
lambda: "blocked" in {unit.workload_status for unit in application.units},
625-
timeout=1500,
626-
)
622+
627623
logger.info(f"remove unit {new_unit.name} with storage from application {SECOND_APPLICATION}")
628624
await ops_test.model.destroy_units(new_unit.name)
629625

0 commit comments

Comments
 (0)