Skip to content

Commit

Permalink
update tests for pebble replan/restart
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Oct 7, 2024
1 parent baef204 commit 2642998
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions tests/integration/tls/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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."
Expand Down
1 change: 0 additions & 1 deletion tests/integration/tls/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
)
from ..client_relations.helpers import get_public_k8s_ip


MONGOS_SERVICE = "mongos.service"

MONGOS_SERVICE = "snap.charmed-mongodb.mongos.service"
Expand Down

0 comments on commit 2642998

Please sign in to comment.