From c5309bab19a35cdd83366ac85a89bc570bd32396 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Thu, 6 Mar 2025 10:48:38 +0100 Subject: [PATCH 1/3] Fixing OpenShift Pytest test suite Signed-off-by: Petr "Stone" Hracek --- test/test_dancer_ex_standalone.py | 4 ++-- test/test_dancer_ex_templates.py | 10 ++++++++-- test/test_deploy_templates.py | 8 +++++++- test/test_helm_dancer_app.py | 2 +- test/test_helm_dancer_mysql_template.py | 6 +++--- test/test_imagestreams_quickstart.py | 15 +++++++++------ 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/test/test_dancer_ex_standalone.py b/test/test_dancer_ex_standalone.py index 2e7379a..578f79a 100644 --- a/test/test_dancer_ex_standalone.py +++ b/test/test_dancer_ex_standalone.py @@ -20,7 +20,7 @@ class TestPerlDancerExTemplate: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION) + self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION, shared_cluster=True) def teardown_method(self): self.oc_api.delete_project() @@ -32,7 +32,7 @@ def test_dancer_ex_template_inside_cluster(self): context=".", service_name=service_name ) - assert self.oc_api.template_deployed(name_in_template=service_name) + assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Welcome to your Dancer application on OpenShift" ) diff --git a/test/test_dancer_ex_templates.py b/test/test_dancer_ex_templates.py index 41d2b55..e94da7b 100644 --- a/test/test_dancer_ex_templates.py +++ b/test/test_dancer_ex_templates.py @@ -14,6 +14,12 @@ IMAGE_NAME = os.getenv("IMAGE_NAME") OS = os.getenv("TARGET") +if VERSION == "5.30-mod_fcgid": + VERSION = "5.30" + +if VERSION == "5.26-mod_fcgid": + VERSION = "5.26" + DEPLOYED_MYSQL_IMAGE = "quay.io/sclorg/mysql-80-c9s:c9s" MYSQL_TAGS = { @@ -49,7 +55,7 @@ def test_perl_template_inside_cluster(self): "SOURCE_REPOSITORY_REF=master" ] ) - assert self.oc_api.template_deployed(name_in_template=service_name) + assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Welcome to your Dancer application on OpenShift" ) @@ -82,7 +88,7 @@ def test_perl_template_inside_cluster(self): ] ) - assert self.oc_api.template_deployed(name_in_template=service_name) + assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Welcome to your Dancer application on OpenShift" ) diff --git a/test/test_deploy_templates.py b/test/test_deploy_templates.py index cf984fe..bccbe53 100644 --- a/test/test_deploy_templates.py +++ b/test/test_deploy_templates.py @@ -13,6 +13,12 @@ IMAGE_NAME = os.getenv("IMAGE_NAME") OS = os.getenv("TARGET") +if VERSION == "5.30-mod_fcgid": + VERSION = "5.30" + +if VERSION == "5.26-mod_fcgid": + VERSION = "5.26" + class TestDeployTemplate: @@ -35,7 +41,7 @@ def test_perl_template_inside_cluster(self): f"NAME={service_name}" ] ) - assert self.oc_api.template_deployed(name_in_template=service_name) + assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Everything is OK" ) diff --git a/test/test_helm_dancer_app.py b/test/test_helm_dancer_app.py index 62451bb..cab1034 100644 --- a/test/test_helm_dancer_app.py +++ b/test/test_helm_dancer_app.py @@ -36,7 +36,7 @@ class TestHelmPerlDancerAppTemplate: def setup_method(self): package_name = "redhat-perl-dancer-application" path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" diff --git a/test/test_helm_dancer_mysql_template.py b/test/test_helm_dancer_mysql_template.py index 331ad4b..8df76f3 100644 --- a/test/test_helm_dancer_mysql_template.py +++ b/test/test_helm_dancer_mysql_template.py @@ -35,7 +35,7 @@ class TestHelmPerlDancerMysqlAppTemplate: def setup_method(self): package_name = "redhat-perl-dancer-application" path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" @@ -58,7 +58,7 @@ def test_dancer_application(self): "namespace": self.hc_api.namespace } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix="dancer-example", timeout=400) + assert self.hc_api.is_s2i_pod_running(pod_name_prefix="dancer-example", timeout=480) assert self.hc_api.oc_api.check_response_inside_cluster( name_in_template="dancer-example", expected_output="Welcome to your Dancer application" @@ -77,5 +77,5 @@ def test_dancer_application_helm_test(self): "namespace": self.hc_api.namespace } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix="dancer-example", timeout=400) + assert self.hc_api.is_s2i_pod_running(pod_name_prefix="dancer-example", timeout=480) assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Dancer application"]) diff --git a/test/test_imagestreams_quickstart.py b/test/test_imagestreams_quickstart.py index 11571ef..5d03938 100644 --- a/test/test_imagestreams_quickstart.py +++ b/test/test_imagestreams_quickstart.py @@ -24,20 +24,23 @@ TAG = TAGS.get(OS, None) +if VERSION == "5.30-mod_fcgid": + VERSION = "5.30" + +if VERSION == "5.26-mod_fcgid": + VERSION = "5.26" + # Replacement with 'test_python_s2i_templates' class TestImagestreamsQuickstart: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION) + self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION, shared_cluster=True) def teardown_method(self): self.oc_api.delete_project() def test_perl_template_inside_cluster(self): - new_version = VERSION - if VERSION == "5.26-mod_fcgid": - new_version = "5.26" service_name = "perl-testing" assert self.oc_api.imagestream_quickstart( imagestream_file="imagestreams/perl-rhel.json", @@ -46,11 +49,11 @@ def test_perl_template_inside_cluster(self): name_in_template="perl", openshift_args=[ f"SOURCE_REPOSITORY_REF=master", - f"VERSION={new_version}{TAG}", + f"VERSION={VERSION}{TAG}", f"NAME={service_name}" ] ) - assert self.oc_api.template_deployed(name_in_template=service_name) + assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Everything is OK" ) From 4c382ab3b916d8c6f97eaf357fd24c9509da33fe Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Thu, 6 Mar 2025 13:31:40 +0100 Subject: [PATCH 2/3] Add missing tags for RHEL10 Signed-off-by: Petr "Stone" Hracek --- test/test_dancer_ex_templates.py | 3 ++- test/test_helm_dancer_app.py | 3 ++- test/test_helm_dancer_mysql_template.py | 3 ++- test/test_imagestreams_quickstart.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/test_dancer_ex_templates.py b/test/test_dancer_ex_templates.py index e94da7b..daee699 100644 --- a/test/test_dancer_ex_templates.py +++ b/test/test_dancer_ex_templates.py @@ -24,7 +24,8 @@ MYSQL_TAGS = { "rhel8": "-el8", - "rhel9": "-el9" + "rhel9": "-el9", + "rhel10": "-el10", } MYSQL_TAG = MYSQL_TAGS.get(OS, None) IMAGE_TAG = f"mysql:8.0{MYSQL_TAG}" diff --git a/test/test_helm_dancer_app.py b/test/test_helm_dancer_app.py index cab1034..daebbe8 100644 --- a/test/test_helm_dancer_app.py +++ b/test/test_helm_dancer_app.py @@ -26,7 +26,8 @@ TAGS = { "rhel8": "-ubi8", - "rhel9": "-ubi9" + "rhel9": "-ubi9", + "rhel10": "-ubi10", } TAG = TAGS.get(OS, None) diff --git a/test/test_helm_dancer_mysql_template.py b/test/test_helm_dancer_mysql_template.py index 8df76f3..35fb2dd 100644 --- a/test/test_helm_dancer_mysql_template.py +++ b/test/test_helm_dancer_mysql_template.py @@ -26,7 +26,8 @@ TAGS = { "rhel8": "-ubi8", - "rhel9": "-ubi9" + "rhel9": "-ubi9", + "rhel10": "-ubi10", } TAG = TAGS.get(OS, None) diff --git a/test/test_imagestreams_quickstart.py b/test/test_imagestreams_quickstart.py index 5d03938..e31f2c9 100644 --- a/test/test_imagestreams_quickstart.py +++ b/test/test_imagestreams_quickstart.py @@ -17,9 +17,9 @@ OS = os.getenv("OS") TAGS = { - "rhel7": "-ubi7", "rhel8": "-ubi8", - "rhel9": "-ubi9" + "rhel9": "-ubi9", + "rhel10": "-ubi10" } TAG = TAGS.get(OS, None) From 4a763d0aa92661262da6cee72841241c7bb365cb Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 25 Mar 2025 13:33:13 +0100 Subject: [PATCH 3/3] Do not test imagestreams yet for RHEL10. They are not prepared yet. Signed-off-by: Petr "Stone" Hracek --- test/run-openshift-remote-cluster | 2 +- test/test-lib-perl.sh | 4 ++++ test/test_dancer_ex_standalone.py | 12 +++++++++--- test/test_dancer_ex_templates.py | 21 +++++++++++++-------- test/test_deploy_templates.py | 6 +++++- test/test_helm_dancer_app.py | 6 +++++- test/test_helm_dancer_mysql_template.py | 6 +++++- test/test_helm_perl_imagestreams.py | 2 +- test/test_imagestreams_quickstart.py | 6 ++++-- 9 files changed, 47 insertions(+), 18 deletions(-) diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster index 82252c5..c375934 100755 --- a/test/run-openshift-remote-cluster +++ b/test/run-openshift-remote-cluster @@ -32,7 +32,7 @@ ct_os_check_login || exit $OC_ERR ct_os_tag_image_for_cvp "perl" -set -u +set -ux # For testing on OpenShift 4 we use internal registry export CT_OCP4_TEST=true diff --git a/test/test-lib-perl.sh b/test/test-lib-perl.sh index a5ec00a..66acb4a 100644 --- a/test/test-lib-perl.sh +++ b/test/test-lib-perl.sh @@ -19,6 +19,10 @@ function test_perl_imagestream() { if [ "${VERSION}" == "5.26-mod_fcgid" ]; then VERSION="5.26" fi + if [ "${OS}" == "rhel10" ]; then + echo "Skip testing imagestreams on RHEL10 till they are not available." + return + fi echo "Testing perl imagestream application" ct_os_test_image_stream_quickstart "${THISDIR}/imagestreams/perl-${OS%[0-9]*}.json" \ "${THISDIR}/sample-test-app.json" \ diff --git a/test/test_dancer_ex_standalone.py b/test/test_dancer_ex_standalone.py index 578f79a..267e18b 100644 --- a/test/test_dancer_ex_standalone.py +++ b/test/test_dancer_ex_standalone.py @@ -15,24 +15,30 @@ IMAGE_NAME = os.getenv("IMAGE_NAME") OS = os.getenv("TARGET") +if VERSION == "5.30-mod_fcgid": + VERSION = "5.30" + +if VERSION == "5.26-mod_fcgid": + VERSION = "5.26" # Replacement with 'test_python_s2i_app_ex' class TestPerlDancerExTemplate: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION, shared_cluster=True) + self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION) def teardown_method(self): self.oc_api.delete_project() def test_dancer_ex_template_inside_cluster(self): - service_name = "perl-testing" + new_version = VERSION.replace(".", "") + service_name = f"perl-{new_version}-testing" assert self.oc_api.deploy_s2i_app( image_name=IMAGE_NAME, app="https://github.com/sclorg/dancer-ex.git", context=".", service_name=service_name ) - assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) + assert self.oc_api.is_s2i_pod_running(pod_name_prefix=service_name, cycle_count=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Welcome to your Dancer application on OpenShift" ) diff --git a/test/test_dancer_ex_templates.py b/test/test_dancer_ex_templates.py index daee699..ae71e3e 100644 --- a/test/test_dancer_ex_templates.py +++ b/test/test_dancer_ex_templates.py @@ -30,19 +30,21 @@ MYSQL_TAG = MYSQL_TAGS.get(OS, None) IMAGE_TAG = f"mysql:8.0{MYSQL_TAG}" MYSQL_VERSION = f"8.0{MYSQL_TAG}" - +TEMPLATE_VERSION = VERSION.replace(".", "") class TestDeployDancerExTemplateWithoutMySQL: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION) - self.oc_api.import_is("imagestreams/perl-rhel.json", "", skip_check=True) + self.oc_api = OpenShiftAPI(pod_name_prefix=f"perl-{TEMPLATE_VERSION}-testing", version=VERSION) def teardown_method(self): self.oc_api.delete_project() def test_perl_template_inside_cluster(self): - service_name = "perl-testing" + if OS == "rhel10": + pytest.skip("Do NOT test on RHEL10 yet.") + self.oc_api.import_is("imagestreams/perl-rhel.json", "", skip_check=True) + service_name = f"perl-{TEMPLATE_VERSION}-testing" template_url = self.oc_api.get_raw_url_for_json( container="dancer-ex", dir="openshift/templates", filename="dancer.json", branch="master" ) @@ -56,7 +58,7 @@ def test_perl_template_inside_cluster(self): "SOURCE_REPOSITORY_REF=master" ] ) - assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) + assert self.oc_api.is_template_deployed(name_in_template=service_name, timeout=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Welcome to your Dancer application on OpenShift" ) @@ -65,7 +67,8 @@ def test_perl_template_inside_cluster(self): class TestDeployDancerExTemplateWithMySQL: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION) + + self.oc_api = OpenShiftAPI(pod_name_prefix=f"perl-{TEMPLATE_VERSION}-testing", version=VERSION) self.oc_api.import_is("imagestreams/perl-rhel.json", "", skip_check=True) assert self.oc_api.upload_image(DEPLOYED_MYSQL_IMAGE, f"{IMAGE_TAG}") @@ -73,7 +76,9 @@ def teardown_method(self): self.oc_api.delete_project() def test_perl_template_inside_cluster(self): - service_name = "perl-testing" + if OS == "rhel10": + pytest.skip("Do NOT test on RHEL10 yet.") + service_name = f"perl-{TEMPLATE_VERSION}-testing" template_url = self.oc_api.get_raw_url_for_json( container="dancer-ex", dir="openshift/templates", filename="dancer-mysql-persistent.json", branch="master" ) @@ -89,7 +94,7 @@ def test_perl_template_inside_cluster(self): ] ) - assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) + assert self.oc_api.is_template_deployed(name_in_template=service_name, timeout=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Welcome to your Dancer application on OpenShift" ) diff --git a/test/test_deploy_templates.py b/test/test_deploy_templates.py index bccbe53..349e56f 100644 --- a/test/test_deploy_templates.py +++ b/test/test_deploy_templates.py @@ -1,6 +1,8 @@ import os import sys +import pytest + from container_ci_suite.openshift import OpenShiftAPI from container_ci_suite.utils import check_variables @@ -30,6 +32,8 @@ def teardown_method(self): self.oc_api.delete_project() def test_perl_template_inside_cluster(self): + if OS == "rhel10": + pytest.skip("Do NOT test on RHEL10 yet.") service_name = "perl-testing" assert self.oc_api.deploy_template_with_image( image_name=IMAGE_NAME, @@ -41,7 +45,7 @@ def test_perl_template_inside_cluster(self): f"NAME={service_name}" ] ) - assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) + assert self.oc_api.is_template_deployed(name_in_template=service_name, timeout=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Everything is OK" ) diff --git a/test/test_helm_dancer_app.py b/test/test_helm_dancer_app.py index daebbe8..1fa98da 100644 --- a/test/test_helm_dancer_app.py +++ b/test/test_helm_dancer_app.py @@ -37,7 +37,7 @@ class TestHelmPerlDancerAppTemplate: def setup_method(self): package_name = "redhat-perl-dancer-application" path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" @@ -49,6 +49,8 @@ def teardown_method(self): def test_dancer_application_curl_output(self): if self.hc_api.oc_api.shared_cluster: pytest.skip("Do NOT test on shared cluster") + if OS == "rhel10": + pytest.skip("Do NOT test on RHEL10 yet.") self.hc_api.package_name = "redhat-perl-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() @@ -67,6 +69,8 @@ def test_dancer_application_curl_output(self): ) def test_dancer_application_helm_test(self): + if OS == "rhel10": + pytest.skip("Do NOT test on RHEL10 yet.") self.hc_api.package_name = "redhat-perl-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() diff --git a/test/test_helm_dancer_mysql_template.py b/test/test_helm_dancer_mysql_template.py index 35fb2dd..ff0870f 100644 --- a/test/test_helm_dancer_mysql_template.py +++ b/test/test_helm_dancer_mysql_template.py @@ -36,7 +36,7 @@ class TestHelmPerlDancerMysqlAppTemplate: def setup_method(self): package_name = "redhat-perl-dancer-application" path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" @@ -48,6 +48,8 @@ def teardown_method(self): def test_dancer_application(self): if self.hc_api.oc_api.shared_cluster: pytest.skip("Do NOT test on shared cluster") + if OS == "rhel10": + pytest.skip("Do NOT test on RHEL10 yet.") self.hc_api.package_name = "redhat-perl-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() @@ -67,6 +69,8 @@ def test_dancer_application(self): def test_dancer_application_helm_test(self): + if OS == "rhel10": + pytest.skip("Do NOT test on RHEL10 yet.") self.hc_api.package_name = "redhat-perl-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() diff --git a/test/test_helm_perl_imagestreams.py b/test/test_helm_perl_imagestreams.py index 36787fc..364b2ce 100644 --- a/test/test_helm_perl_imagestreams.py +++ b/test/test_helm_perl_imagestreams.py @@ -20,7 +20,7 @@ class TestHelmRHELPerlImageStreams: def setup_method(self): package_name = "redhat-perl-imagestreams" path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" diff --git a/test/test_imagestreams_quickstart.py b/test/test_imagestreams_quickstart.py index e31f2c9..2945995 100644 --- a/test/test_imagestreams_quickstart.py +++ b/test/test_imagestreams_quickstart.py @@ -35,12 +35,14 @@ class TestImagestreamsQuickstart: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION, shared_cluster=True) + self.oc_api = OpenShiftAPI(pod_name_prefix="perl-testing", version=VERSION) def teardown_method(self): self.oc_api.delete_project() def test_perl_template_inside_cluster(self): + if OS == "rhel10": + pytest.skip("Do NOT test on RHEL10 yet.") service_name = "perl-testing" assert self.oc_api.imagestream_quickstart( imagestream_file="imagestreams/perl-rhel.json", @@ -53,7 +55,7 @@ def test_perl_template_inside_cluster(self): f"NAME={service_name}" ] ) - assert self.oc_api.template_deployed(name_in_template=service_name, timeout=480) + assert self.oc_api.is_template_deployed(name_in_template=service_name, timeout=480) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Everything is OK" )