From 65d9cf536e2081342809eb9f918742ca38f8b5bd Mon Sep 17 00:00:00 2001 From: Orfeas Kourkakis Date: Fri, 9 Feb 2024 13:18:45 +0200 Subject: [PATCH] feat: Enable tests/integration to be able to run 1.7, 1.8 and latest (#803) * Parametrize tests/integration test_bundle_deployment.py in order to be able to run for 1.7, 1.8 and latest. * ci: Update deploy-eks.yaml tox command Closes #800 --- .github/workflows/deploy-eks.yaml | 2 +- tests/integration/test_bundle_deployment.py | 10 +++++++--- tox.ini | 12 +++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-eks.yaml b/.github/workflows/deploy-eks.yaml index cb378a91..91984c57 100644 --- a/.github/workflows/deploy-eks.yaml +++ b/.github/workflows/deploy-eks.yaml @@ -63,7 +63,7 @@ jobs: - name: Test bundle deployment run: | - tox -vve test_bundle_deployment -- --model kubeflow --keep-models -vv -s + tox -vve test_bundle_deployment-1.7 -- --model kubeflow --keep-models -vv -s # On failure, capture debugging resources - name: Get juju status diff --git a/tests/integration/test_bundle_deployment.py b/tests/integration/test_bundle_deployment.py index 982b1d6e..416e343f 100644 --- a/tests/integration/test_bundle_deployment.py +++ b/tests/integration/test_bundle_deployment.py @@ -1,5 +1,6 @@ import subprocess import json +import os import aiohttp import lightkube @@ -8,7 +9,6 @@ from pytest_operator.plugin import OpsTest from lightkube.resources.core_v1 import Service -BUNDLE_PATH = "./releases/1.7/edge/kubeflow/bundle.yaml" BUNDLE_NAME = "kubeflow" @pytest.fixture() @@ -16,10 +16,14 @@ def lightkube_client() -> lightkube.Client: client = lightkube.Client(field_manager=BUNDLE_NAME) return client +@pytest.fixture +def bundle_path() -> str: + return os.environ.get("BUNDLE_PATH").replace("\"", "") + class TestCharm: @pytest.mark.abort_on_fail - async def test_bundle_deployment_works(self, ops_test: OpsTest, lightkube_client): - subprocess.Popen(["juju", "deploy", f"{BUNDLE_PATH}", "--trust"]) + async def test_bundle_deployment_works(self, ops_test: OpsTest, lightkube_client, bundle_path): + subprocess.Popen(["juju", "deploy", bundle_path, "--trust"]) await ops_test.model.wait_for_idle( apps=["istio-ingressgateway"], diff --git a/tox.ini b/tox.ini index 0780a15c..9eb64633 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] skipsdist = True -envlist = upgrade +envlist = lint, fmt, tests, full_bundle_tests, test_bundle_1.7, test_selenium_1.7, {test_bundle_deployment}-{1.7,1.8,latest} [vars] releases_test_path = {toxinidir}/tests-bundle/ @@ -80,14 +80,20 @@ deps = -r {[vars]releases_test_path}/1.7/requirements.txt description = Test bundles -[testenv:test_bundle_deployment] +[testenv:test_bundle_deployment-{1.7,1.8,latest}] commands = pytest -v --tb native --asyncio-mode=auto {[vars]test_path}/integration/test_bundle_deployment.py --keep-models --log-cli-level=INFO -s {posargs} +setenv = + 1.7: BUNDLE_PATH = "./releases/1.7/stable/kubeflow/bundle.yaml" + 1.8: BUNDLE_PATH = "./releases/1.8/stable/kubeflow/bundle.yaml" + latest: BUNDLE_PATH = "./releases/latest/edge/bundle.yaml" deps = aiohttp lightkube pytest-operator tenacity ops>=2.3.0 - juju==2.9.43 + 1.7: juju<3.0.0 + 1.8: juju<4.0.0 + latest: juju<4.0.0 description = Test bundle deployment