Skip to content

Commit 9bafcf6

Browse files
committed
Test fixes
1 parent d0d956a commit 9bafcf6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

tests/integration/ha_tests/test_async_replication.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ async def test_data_integrator_creds_keep_on_working(
308308
database = data_integrator_credentials["postgresql"]["database"]
309309

310310
any_unit = second_model.applications[DATABASE_APP_NAME].units[0].name
311-
primary = await get_primary(ops_test, any_unit)
312-
address = get_unit_address(ops_test, primary)
311+
primary = await get_primary(ops_test, any_unit, second_model)
312+
address = second_model.units.get(primary).public_address
313313

314314
connstr = f"dbname='{database}' user='{user}' host='{address}' port='5432' password='{password}' connect_timeout=1"
315315
try:
@@ -319,12 +319,13 @@ async def test_data_integrator_creds_keep_on_working(
319319
connection.close()
320320

321321
logger.info("Re-enable oversee users")
322-
action = await primary.run_action(action_name="reenable-oversee-users")
322+
leader_unit = await get_leader_unit(ops_test, DATABASE_APP_NAME, model=second_model)
323+
action = await leader_unit.run_action(action_name="reenable-oversee-users")
323324
await action.wait()
324325

325326
async with ops_test.fast_forward():
326327
await sleep(20)
327-
second_model.wait_for_idle(
328+
await second_model.wait_for_idle(
328329
apps=[DATABASE_APP_NAME],
329330
status="active",
330331
timeout=TIMEOUT,

tests/integration/helpers.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -621,17 +621,20 @@ async def get_password(ops_test: OpsTest, unit_name: str, username: str = "opera
621621
stop=stop_after_attempt(10),
622622
wait=wait_exponential(multiplier=1, min=2, max=30),
623623
)
624-
async def get_primary(ops_test: OpsTest, unit_name: str) -> str:
624+
async def get_primary(ops_test: OpsTest, unit_name: str, model=None) -> str:
625625
"""Get the primary unit.
626626
627627
Args:
628628
ops_test: ops_test instance.
629629
unit_name: the name of the unit.
630+
model: Model to use.
630631
631632
Returns:
632633
the current primary unit.
633634
"""
634-
action = await ops_test.model.units.get(unit_name).run_action("get-primary")
635+
if not model:
636+
model = ops_test.model
637+
action = await model.units.get(unit_name).run_action("get-primary")
635638
action = await action.wait()
636639
return action.results["primary"]
637640

0 commit comments

Comments
 (0)