From 82ce70c54a5fd35a01840a037a76205fc20cc6c2 Mon Sep 17 00:00:00 2001 From: Daniela Plascencia Date: Mon, 15 Apr 2024 10:24:55 +0200 Subject: [PATCH] tests: pin deployed charms to a latest and stable version This commit pins all charms that get deployed from Charmhub to a latest/edge or suggested versions. This commit also refactors the test file so it takes all versions and other constants from a constants.py file Part of canonical/bundle-kubeflow#863 --- tests/integration/test_charms.py | 18 ++++++++++++++---- tests/integration/test_katib_experiments.py | 12 +++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/integration/test_charms.py b/tests/integration/test_charms.py index 349a08c0..882362aa 100644 --- a/tests/integration/test_charms.py +++ b/tests/integration/test_charms.py @@ -20,6 +20,14 @@ UI_APP_NAME = UI_METADATA["name"] DB_APP_NAME = DB_METADATA["name"] +MYSQL_K8S = "mysql-k8s" +MYSQL_K8S_CHANNEL = "8.0/edge" +MYSQL_K8S_TRUST = True + +KUBEFLOW_PROFILES = "kubeflow-profiles" +KUBEFLOW_PROFILES_CHANNEL = "latest/edge" +KUBEFLOW_PROFILES_TRUST = True + logger = logging.getLogger(__name__) @@ -49,9 +57,11 @@ async def test_deploy_katib_charms(ops_test: OpsTest): # Deploy katib-db await ops_test.model.deploy( - "charmed-osm-mariadb-k8s", + MYSQL_K8S, + channel=MYSQL_K8S_CHANNEL, application_name="katib-db", config={"database": "katib"}, + trust=MYSQL_K8S_TRUST, ) # Relate to katib-db @@ -65,9 +75,9 @@ async def test_deploy_katib_charms(ops_test: OpsTest): # Deploy charms responsible for CRDs creation await ops_test.model.deploy( - entity_url="kubeflow-profiles", - channel="latest/edge", - trust=True, + entity_url=KUBEFLOW_PROFILES, + channel=KUBEFLOW_PROFILES_CHANNEL, + trust=KUBEFLOW_PROFILES_TRUST, ) # Wait for everything to deploy diff --git a/tests/integration/test_katib_experiments.py b/tests/integration/test_katib_experiments.py index 05e5200e..935bed32 100644 --- a/tests/integration/test_katib_experiments.py +++ b/tests/integration/test_katib_experiments.py @@ -27,7 +27,9 @@ kind="Profile", plural="profiles", ) -TRAINING_CHARM = "training-operator" +TRAINING_OPERATOR = "training-operator" +TRAINING_OPERATOR_CHANNEL = "latest/edge" +TRAINING_OPERATOR_TRUST = True @pytest.fixture(scope="module") @@ -42,12 +44,12 @@ def lightkube_client() -> lightkube.Client: async def training_operator(ops_test: OpsTest): """Deploy training-operator charm, and wait until it's active.""" await ops_test.model.deploy( - entity_url=TRAINING_CHARM, - channel="latest/edge", - trust=True, + entity_url=TRAINING_OPERATOR, + channel=TRAINING_OPERATOR_CHANNEL, + trust=TRAINING_OPERATOR_TRUST, ) await ops_test.model.wait_for_idle( - apps=[TRAINING_CHARM], status="active", raise_on_blocked=False, timeout=60 * 5 + apps=[TRAINING_OPERATOR], status="active", raise_on_blocked=False, timeout=60 * 5 )