Skip to content

Commit 006b62b

Browse files
committed
Try to retry and wait for message
1 parent 82a4928 commit 006b62b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/integration/spaces/test_spaced_database.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import jubilant
99
import pytest
10+
from tenacity import Retrying, stop_after_attempt, wait_fixed
1011

1112
PG_NAME = "postgresql"
1213
APP_NAME = "postgresql-test-app"
@@ -88,8 +89,11 @@ def test_integrate_with_isolated_space(juju: jubilant.Juju):
8889
juju.integrate(PG_NAME, f"{ISOLATED_APP_NAME}:database")
8990
sleep(SLEEP_TIME)
9091
# Wait for the relation to be established
92+
msg = "received database credentials of the first database"
9193
juju.wait(
92-
lambda status: jubilant.all_active(status, PG_NAME, ISOLATED_APP_NAME), delay=SLEEP_TIME
94+
lambda status: jubilant.all_active(status, PG_NAME, ISOLATED_APP_NAME)
95+
and status.apps[ISOLATED_APP_NAME].app_status.message == msg,
96+
delay=SLEEP_TIME,
9397
)
9498

9599
status = juju.status()
@@ -98,5 +102,6 @@ def test_integrate_with_isolated_space(juju: jubilant.Juju):
98102
logger.info("Flush default routes on client")
99103
juju.exec("sudo ip route flush default", unit=unit)
100104

101-
with pytest.raises(jubilant.TaskError):
102-
juju.run(unit, "start-continuous-writes")
105+
for attempt in Retrying(stop=stop_after_attempt(3), wait=wait_fixed(5)):
106+
with attempt, pytest.raises(jubilant.TaskError):
107+
juju.run(unit, "start-continuous-writes")

0 commit comments

Comments
 (0)