From ab67b26fd7a4a1a10cd78df1cfa280a682a28247 Mon Sep 17 00:00:00 2001 From: Noha Ihab <49988746+NohaIhab@users.noreply.github.com> Date: Tue, 22 Sep 2026 17:50:47 +0300 Subject: [PATCH] ci(fix): update outdated minio client image in tests (#309) (cherry picked from commit 383d893fd455f66632ace7041fdba866088bd3a3) --- tests/integration/test_charm.py | 71 ++++++++++++++----------- tests/integration/test_charm_ambient.py | 71 ++++++++++++++----------- 2 files changed, 78 insertions(+), 64 deletions(-) diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 4f65948..6dc02b2 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -31,6 +31,35 @@ "access-key": "minio", "secret-key": "minio-secret-key", } +MINIO_CLIENT_IMAGE = "quay.io/minio/mc" + + +async def run_probe_pod(ops_test: OpsTest, pod_name: str, image: str, command: tuple): + """Run a one-off probe Pod via kubectl, always deleting it afterwards.""" + kubectl_cmd = ( + "kubectl", + "run", + "-i", + "--restart=Never", + "--command", + f"--namespace={ops_test.model_name}", + pod_name, + f"--image={image}", + "--", + *command, + ) + try: + return await ops_test.run(*kubectl_cmd) + finally: + await ops_test.run( + "kubectl", + "delete", + "pod", + pod_name, + f"--namespace={ops_test.model_name}", + "--ignore-not-found", + "--now", + ) @pytest.fixture(scope="session") @@ -127,24 +156,13 @@ async def connect_client_to_server( f"&& mc rb {alias}/{bucket}" ) - kubectl_cmd = ( - "kubectl", - "run", - "--rm", - "-i", - "--restart=Never", - "--command", - f"--namespace={ops_test.model_name}", - "minio-deployment-test", - "--image=minio/mc", - "--", - "sh", - "-c", - minio_cmd, + ret_code, stdout, stderr = await run_probe_pod( + ops_test, + pod_name="minio-client-test", + image=MINIO_CLIENT_IMAGE, + command=("sh", "-c", minio_cmd), ) - ret_code, stdout, stderr = await ops_test.run(*kubectl_cmd) - if ret_code != 0: raise ConnectionError( f"Connection to Minio returned code {ret_code} with stdout:\n{stdout}\n" @@ -192,24 +210,13 @@ async def test_connect_to_console(ops_test: OpsTest): url = f"http://{service_name}.{model_name}.svc.cluster.local:{port}" - kubectl_cmd = ( - "kubectl", - "run", - "--rm", - "-i", - "--restart=Never", - "--command", - f"--namespace={ops_test.model_name}", - "minio-deployment-test", - "--image=curlimages/curl", - "--", - "curl", - "-I", - url, + ret_code, stdout, stderr = await run_probe_pod( + ops_test, + pod_name="minio-console-test", + image="curlimages/curl", + command=("curl", "-I", url), ) - ret_code, stdout, stderr = await ops_test.run(*kubectl_cmd) - assert ( ret_code == 0 ), f"Test returned code {ret_code} with stdout:\n{stdout}\nstderr:\n{stderr}" diff --git a/tests/integration/test_charm_ambient.py b/tests/integration/test_charm_ambient.py index 29f1f03..360a2ea 100644 --- a/tests/integration/test_charm_ambient.py +++ b/tests/integration/test_charm_ambient.py @@ -32,6 +32,35 @@ "access-key": "minio", "secret-key": "minio-secret-key", } +MINIO_CLIENT_IMAGE = "quay.io/minio/mc" + + +async def run_probe_pod(ops_test: OpsTest, pod_name: str, image: str, command: tuple): + """Run a one-off probe Pod via kubectl, always deleting it afterwards.""" + kubectl_cmd = ( + "kubectl", + "run", + "-i", + "--restart=Never", + "--command", + f"--namespace={ops_test.model_name}", + pod_name, + f"--image={image}", + "--", + *command, + ) + try: + return await ops_test.run(*kubectl_cmd) + finally: + await ops_test.run( + "kubectl", + "delete", + "pod", + pod_name, + f"--namespace={ops_test.model_name}", + "--ignore-not-found", + "--now", + ) @pytest.fixture(scope="session") @@ -135,24 +164,13 @@ async def connect_client_to_server( f"&& mc rb {alias}/{bucket}" ) - kubectl_cmd = ( - "kubectl", - "run", - "--rm", - "-i", - "--restart=Never", - "--command", - f"--namespace={ops_test.model_name}", - "minio-deployment-test", - "--image=minio/mc", - "--", - "sh", - "-c", - minio_cmd, + ret_code, stdout, stderr = await run_probe_pod( + ops_test, + pod_name="minio-client-test", + image=MINIO_CLIENT_IMAGE, + command=("sh", "-c", minio_cmd), ) - ret_code, stdout, stderr = await ops_test.run(*kubectl_cmd) - if ret_code != 0: raise ConnectionError( f"Connection to Minio returned code {ret_code} with stdout:\n{stdout}\n" @@ -200,24 +218,13 @@ async def test_connect_to_console(ops_test: OpsTest): url = f"http://{service_name}.{model_name}.svc.cluster.local:{port}" - kubectl_cmd = ( - "kubectl", - "run", - "--rm", - "-i", - "--restart=Never", - "--command", - f"--namespace={ops_test.model_name}", - "minio-deployment-test", - "--image=curlimages/curl", - "--", - "curl", - "-I", - url, + ret_code, stdout, stderr = await run_probe_pod( + ops_test, + pod_name="minio-console-test", + image="curlimages/curl", + command=("curl", "-I", url), ) - ret_code, stdout, stderr = await ops_test.run(*kubectl_cmd) - assert ( ret_code == 0 ), f"Test returned code {ret_code} with stdout:\n{stdout}\nstderr:\n{stderr}"