From fe178bb901b48f4408befb5837379dd9b47b8484 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 17 Sep 2024 12:33:47 +0200 Subject: [PATCH] Remove `run-openshift` that are deprecated. Adds helm charts tests Signed-off-by: Petr "Stone" Hracek --- 1.20/test/run-openshift | 1 - 1.20/test/test_helm_nginx_imagestreams.py | 1 + 1.20/test/test_helm_nginx_template.py | 1 + 1.22/test/run-openshift | 1 - 1.22/test/test_helm_nginx_imagestreams.py | 1 + 1.22/test/test_helm_nginx_template.py | 1 + 1.24/test/test_helm_nginx_imagestreams.py | 1 + 1.24/test/test_helm_nginx_template.py | 1 + 1.26/test/run-openshift | 1 - test/test_helm_nginx_imagestreams.py | 46 +++++++++++++ test/test_helm_nginx_template.py | 84 +++++++++++++++++++++++ 11 files changed, 136 insertions(+), 3 deletions(-) delete mode 120000 1.20/test/run-openshift create mode 120000 1.20/test/test_helm_nginx_imagestreams.py create mode 120000 1.20/test/test_helm_nginx_template.py delete mode 120000 1.22/test/run-openshift create mode 120000 1.22/test/test_helm_nginx_imagestreams.py create mode 120000 1.22/test/test_helm_nginx_template.py create mode 120000 1.24/test/test_helm_nginx_imagestreams.py create mode 120000 1.24/test/test_helm_nginx_template.py delete mode 120000 1.26/test/run-openshift create mode 100644 test/test_helm_nginx_imagestreams.py create mode 100644 test/test_helm_nginx_template.py diff --git a/1.20/test/run-openshift b/1.20/test/run-openshift deleted file mode 120000 index ec13e4a1..00000000 --- a/1.20/test/run-openshift +++ /dev/null @@ -1 +0,0 @@ -../../test/run-openshift \ No newline at end of file diff --git a/1.20/test/test_helm_nginx_imagestreams.py b/1.20/test/test_helm_nginx_imagestreams.py new file mode 120000 index 00000000..fb7229fb --- /dev/null +++ b/1.20/test/test_helm_nginx_imagestreams.py @@ -0,0 +1 @@ +../../test/test_helm_nginx_imagestreams.py \ No newline at end of file diff --git a/1.20/test/test_helm_nginx_template.py b/1.20/test/test_helm_nginx_template.py new file mode 120000 index 00000000..fef05bfc --- /dev/null +++ b/1.20/test/test_helm_nginx_template.py @@ -0,0 +1 @@ +../../test/test_helm_nginx_template.py \ No newline at end of file diff --git a/1.22/test/run-openshift b/1.22/test/run-openshift deleted file mode 120000 index ec13e4a1..00000000 --- a/1.22/test/run-openshift +++ /dev/null @@ -1 +0,0 @@ -../../test/run-openshift \ No newline at end of file diff --git a/1.22/test/test_helm_nginx_imagestreams.py b/1.22/test/test_helm_nginx_imagestreams.py new file mode 120000 index 00000000..fb7229fb --- /dev/null +++ b/1.22/test/test_helm_nginx_imagestreams.py @@ -0,0 +1 @@ +../../test/test_helm_nginx_imagestreams.py \ No newline at end of file diff --git a/1.22/test/test_helm_nginx_template.py b/1.22/test/test_helm_nginx_template.py new file mode 120000 index 00000000..fef05bfc --- /dev/null +++ b/1.22/test/test_helm_nginx_template.py @@ -0,0 +1 @@ +../../test/test_helm_nginx_template.py \ No newline at end of file diff --git a/1.24/test/test_helm_nginx_imagestreams.py b/1.24/test/test_helm_nginx_imagestreams.py new file mode 120000 index 00000000..fb7229fb --- /dev/null +++ b/1.24/test/test_helm_nginx_imagestreams.py @@ -0,0 +1 @@ +../../test/test_helm_nginx_imagestreams.py \ No newline at end of file diff --git a/1.24/test/test_helm_nginx_template.py b/1.24/test/test_helm_nginx_template.py new file mode 120000 index 00000000..fef05bfc --- /dev/null +++ b/1.24/test/test_helm_nginx_template.py @@ -0,0 +1 @@ +../../test/test_helm_nginx_template.py \ No newline at end of file diff --git a/1.26/test/run-openshift b/1.26/test/run-openshift deleted file mode 120000 index ec13e4a1..00000000 --- a/1.26/test/run-openshift +++ /dev/null @@ -1 +0,0 @@ -../../test/run-openshift \ No newline at end of file diff --git a/test/test_helm_nginx_imagestreams.py b/test/test_helm_nginx_imagestreams.py new file mode 100644 index 00000000..f1e0a662 --- /dev/null +++ b/test/test_helm_nginx_imagestreams.py @@ -0,0 +1,46 @@ +import os +import sys + +import pytest + +from pathlib import Path + +from container_ci_suite.helm import HelmChartsAPI +from container_ci_suite.utils import check_variables + +if not check_variables(): + print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") + sys.exit(1) + +test_dir = Path(os.path.abspath(os.path.dirname(__file__))) + + +class TestHelmRHELNginxImageStreams: + + def setup_method(self): + package_name = "nginx-imagestreams" + path = test_dir + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True) + self.hc_api.clone_helm_chart_repo( + repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", + subdir="charts/redhat" + ) + + def teardown_method(self): + self.hc_api.delete_project() + + @pytest.mark.parametrize( + "version,registry", + [ + ("1.24-ubi9", "registry.redhat.io/ubi9/nginx-124:latest"), + ("1.24-ubi8", "registry.redhat.io/ubi8/nginx-124:latest"), + ("1.22-ubi9", "registry.redhat.io/ubi9/nginx-122:latest"), + ("1.22-ubi8", "registry.redhat.io/ubi8/nginx-122:latest"), + ("1.20-ubi9", "registry.redhat.io/ubi9/nginx-120:latest"), + ("1.20-ubi8", "registry.redhat.io/ubi8/nginx-120:latest"), + ], + ) + def test_package_imagestream(self, version, registry): + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation() + assert self.hc_api.check_imagestreams(version=version, registry=registry) diff --git a/test/test_helm_nginx_template.py b/test/test_helm_nginx_template.py new file mode 100644 index 00000000..80d132ea --- /dev/null +++ b/test/test_helm_nginx_template.py @@ -0,0 +1,84 @@ +import os +import sys + +import pytest + +from pathlib import Path + +from container_ci_suite.helm import HelmChartsAPI +from container_ci_suite.utils import check_variables + +if not check_variables(): + print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") + sys.exit(1) + +test_dir = Path(os.path.abspath(os.path.dirname(__file__))) + + +VERSION = os.getenv("VERSION") +IMAGE_NAME = os.getenv("IMAGE_NAME") +OS = os.getenv("TARGET") + +TAGS = { + "rhel8": "-ubi8", + "rhel9": "-ubi9" +} +TAG = TAGS.get(OS, None) + + +class TestHelmNginxTemplate: + + def setup_method(self): + package_name = "nginx-template" + path = test_dir + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True) + self.hc_api.clone_helm_chart_repo( + repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", + subdir="charts/redhat" + ) + + def teardown_method(self): + self.hc_api.delete_project() + + def test_curl_connection(self): + if self.hc_api.oc_api.shared_cluster: + pytest.skip("Do NOT test on shared cluster") + new_version = VERSION + if "micro" in VERSION: + new_version = VERSION.replace("-micro", "") + self.hc_api.package_name = "nginx-imagestreams" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation() + self.hc_api.package_name = "nginx-template" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation( + values={ + "nginx_version": f"{new_version}{TAG}", + "namespace": self.hc_api.namespace + } + ) + expected_str = "Welcome to your static nginx application on OpenShift" + assert self.hc_api.is_s2i_pod_running(pod_name_prefix="nginx-example") + assert self.hc_api.test_helm_curl_output( + route_name="nginx-example", + expected_str=expected_str + ) + + def test_helm_connection(self): + self.hc_api.package_name = "nginx-imagestreams" + new_version = VERSION + if "micro" in VERSION: + new_version = VERSION.replace("-micro", "") + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation() + self.hc_api.package_name = "nginx-template" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation( + values={ + "nginx_version": f"{new_version}{TAG}", + "namespace": self.hc_api.namespace + } + ) + expected_str = "Welcome to your static nginx application on OpenShift" + assert self.hc_api.is_s2i_pod_running(pod_name_prefix="nginx-example") + assert self.hc_api.test_helm_chart(expected_str=[expected_str])