diff --git a/tests/integration/charm/helpers.py b/tests/integration/charm/helpers.py index cfe9e097..dd89bb05 100644 --- a/tests/integration/charm/helpers.py +++ b/tests/integration/charm/helpers.py @@ -6,13 +6,16 @@ import json import logging import random +import subprocess import tempfile +import time import tomllib import zipfile from datetime import datetime from enum import Enum import jubilant +import psycopg2 import requests import yaml from lightkube import Client @@ -30,6 +33,7 @@ from tests.integration.helpers.juju import ( get_app_leader, get_app_units, + get_credentials, get_secret_by_label, get_unit_address, wait_for_apps_status, @@ -37,8 +41,12 @@ from tests.integration.helpers.postgresql import db_connect, execute_query from tests.integration.types import Substrate +logger = logging.getLogger(__name__) + DATA_INTEGRATOR_APP_NAME = "data-integrator" +RELATION_ENDPOINT = "postgresql" + MINUTE_SECS = 60 # The resume-refresh action is a one-shot charm_refresh state-machine probe: it fails while @@ -57,6 +65,40 @@ class RoleAttributeValue(Enum): ALL_DATABASES = 3 +def consumer_alias_exists(juju: jubilant.Juju, app_name: str, label: str) -> bool: + """Whether *app*'s leader holds a consumer-side alias for *label*. + + A consumed-secret alias is not listed by ``secret-ids`` (which returns only + owned secrets), so ``get_async_secret_labels`` can't see it. Probe it directly: + ``secret-get --label`` returns content when the alias exists and errors with + ``consumer label "