Skip to content

Commit f903463

Browse files
committed
Retry grep
1 parent d5bfb7d commit f903463

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tests/integration/test_tls.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest as pytest
88
from pytest_operator.plugin import OpsTest
9-
from tenacity import Retrying, stop_after_attempt, stop_after_delay, wait_exponential
9+
from tenacity import Retrying, stop_after_attempt, stop_after_delay, wait_exponential, wait_fixed
1010

1111
from . import architecture
1212
from .ha_tests.helpers import (
@@ -164,17 +164,21 @@ async def test_tls_enabled(ops_test: OpsTest) -> None:
164164
assert await primary_changed(ops_test, primary), "primary not changed"
165165
change_primary_start_timeout(ops_test, primary, 300)
166166

167-
async with ops_test.fast_forward():
168167
# Check the logs to ensure TLS is being used by pg_rewind.
169168
primary = await get_primary(ops_test, primary)
170-
await run_command_on_unit(
171-
ops_test,
172-
primary,
173-
"grep 'connection authorized: user=rewind database=postgres SSL enabled' /var/snap/charmed-postgresql/common/var/log/postgresql/postgresql-*.log",
174-
)
169+
for attempt in Retrying(
170+
stop=stop_after_attempt(10), wait=wait_fixed(5)
171+
):
172+
with attempt:
173+
await run_command_on_unit(
174+
ops_test,
175+
primary,
176+
"grep 'connection authorized: user=rewind database=postgres SSL enabled' /var/snap/charmed-postgresql/common/var/log/postgresql/postgresql-*.log",
177+
)
175178

176179
await change_patroni_setting(ops_test, "pause", False, use_random_unit=True, tls=True)
177180

181+
async with ops_test.fast_forward():
178182
# Remove the relation.
179183
await ops_test.model.applications[DATABASE_APP_NAME].remove_relation(
180184
f"{DATABASE_APP_NAME}:certificates", f"{tls_certificates_app_name}:certificates"

0 commit comments

Comments
 (0)