From 2642998ea678624b386c270a1956323f42e5f9fd Mon Sep 17 00:00:00 2001 From: Mia Altieri Date: Mon, 7 Oct 2024 14:01:42 +0000 Subject: [PATCH] update tests for pebble replan/restart --- tests/integration/tls/helpers.py | 7 +++++-- tests/integration/tls/test_tls.py | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/integration/tls/helpers.py b/tests/integration/tls/helpers.py index 7ce738eb..5058c755 100644 --- a/tests/integration/tls/helpers.py +++ b/tests/integration/tls/helpers.py @@ -11,6 +11,7 @@ import json import ops import logging +import time from ops.model import Unit from ..client_relations.helpers import get_external_uri from ..helpers import get_mongos_uri @@ -30,6 +31,7 @@ SHARD_APP_NAME = "shard0" CLUSTER_COMPONENTS = [CONFIG_SERVER_APP_NAME, SHARD_APP_NAME] MONGOS_SERVICE = "mongos.service" +PEBBLE_TIME_UNIT = 60 class ProcessError(Exception): @@ -181,7 +183,7 @@ async def time_process_started( # find most recent start time. By parsing most recent logs (ie in reverse order) for log in reversed(logs.split("\n")): - if "Replan" in log: + if "Restart" in log: return process_pebble_time(log.split()[4]) raise Exception("Service was never started") @@ -364,6 +366,8 @@ async def rotate_and_verify_certs(ops_test: OpsTest, app: str, tmpdir: Path) -> ops_test, unit, app_name=app, tmpdir=tmpdir ) + time.sleep(PEBBLE_TIME_UNIT) + # set external and internal key using auto-generated key for each unit for unit in ops_test.model.applications[app].units: action = await unit.run_action(action_name="set-tls-private-key") @@ -414,7 +418,6 @@ async def rotate_and_verify_certs(ops_test: OpsTest, app: str, tmpdir: Path) -> # Once the certificate requests are processed and updated the .service file should be # restarted - assert ( new_mongos_service_time > original_tls_info[unit.name]["mongos_service"] ), f"mongos service for {unit.name} was not restarted." diff --git a/tests/integration/tls/test_tls.py b/tests/integration/tls/test_tls.py index 9771b58c..ab383f23 100644 --- a/tests/integration/tls/test_tls.py +++ b/tests/integration/tls/test_tls.py @@ -23,7 +23,6 @@ ) from ..client_relations.helpers import get_public_k8s_ip - MONGOS_SERVICE = "mongos.service" MONGOS_SERVICE = "snap.charmed-mongodb.mongos.service"