From 8129c72ae65e39ccd1654c7333b4fbe47c611ef2 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 19 May 2025 13:43:31 +0200 Subject: [PATCH 1/3] Add tests for RHEL10 and fix Python calling so we detect what versions are supported in test directly Signed-off-by: Petr "Stone" Hracek --- tests/__init__.py | 0 tests/constants.py | 16 +++++++++++++ tests/test_dancer.py | 54 ++++++++++++++++++++++++++++++++------------ 3 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/constants.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/constants.py b/tests/constants.py new file mode 100644 index 0000000..1f69056 --- /dev/null +++ b/tests/constants.py @@ -0,0 +1,16 @@ +TAGS = { + "rhel8": "-ubi8", + "rhel9": "-ubi9", + "rhel10": "-ubi10", +} + +def is_test_allowed(os, version): + if os == "rhel8" and version == "5.26": + return True + if os == "rhel8" and version == "5.32": + return True + if os == "rhel9" and version == "5.32": + return True + if os == "rhel10" and version == "5.40": + return True + return False \ No newline at end of file diff --git a/tests/test_dancer.py b/tests/test_dancer.py index 6e2c75a..35b5faf 100644 --- a/tests/test_dancer.py +++ b/tests/test_dancer.py @@ -5,65 +5,91 @@ from container_ci_suite.openshift import OpenShiftAPI +from constants import TAGS, is_test_allowed test_dir = Path(os.path.abspath(os.path.dirname(__file__))) VERSION=os.getenv("SINGLE_VERSION") -if not VERSION: - VERSION="5.32-ubi8" +OS=os.getenv("OS") + +TAG = TAGS.get(OS) class TestDancerAppExTemplate: def setup_method(self): self.oc_api = OpenShiftAPI(pod_name_prefix="dancer-example") - json_raw_file = self.oc_api.get_raw_url_for_json( - container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json" - ) - self.oc_api.import_is(path=json_raw_file, name="perl") def teardown_method(self): self.oc_api.delete_project() def test_local_template_inside_cluster(self): + if not is_test_allowed(OS, VERSION): + pytest.skip(f"Local templates are not supported for {OS} and {VERSION}") + json_raw_file = self.oc_api.get_raw_url_for_json( + container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="perl") expected_output = "Welcome to your Dancer application" template_json = "../openshift/templates/dancer.json" assert self.oc_api.deploy_template( - template=template_json, name_in_template="dancer-example", expected_output=expected_output, + template=template_json, + name_in_template="dancer-example", + expected_output=expected_output, openshift_args=[ "SOURCE_REPOSITORY_REF=master", - f"PERL_VERSION={VERSION}", + f"PERL_VERSION={VERSION}{TAG}", "NAME=dancer-example" ] ) - assert self.oc_api.template_deployed(name_in_template="dancer-example") + assert self.oc_api.is_template_deployed(name_in_template="dancer-example") assert self.oc_api.check_response_inside_cluster( name_in_template="dancer-example", expected_output=expected_output ) def test_template_inside_cluster(self): + if not is_test_allowed(OS, VERSION): + pytest.skip(f"Local templates are not supported for {OS} and {VERSION}") + json_raw_file = self.oc_api.get_raw_url_for_json( + container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="perl") expected_output = "Welcome to your Dancer application" template_json = self.oc_api.get_raw_url_for_json( container="dancer-ex", dir="openshift/templates", filename="dancer.json" ) assert self.oc_api.deploy_template( template=template_json, name_in_template="dancer-example", expected_output=expected_output, - openshift_args=["SOURCE_REPOSITORY_REF=master", f"PERL_VERSION={VERSION}", "NAME=dancer-example"] + openshift_args=[ + "SOURCE_REPOSITORY_REF=master", + f"PERL_VERSION={VERSION}{TAG}", + "NAME=dancer-example"] ) - assert self.oc_api.template_deployed(name_in_template="dancer-example") + assert self.oc_api.is_template_deployed(name_in_template="dancer-example") assert self.oc_api.check_response_inside_cluster( name_in_template="dancer-example", expected_output=expected_output ) def test_template_by_request(self): + if not is_test_allowed(OS, VERSION): + pytest.skip(f"Local templates are not supported for {OS} and {VERSION}") + json_raw_file = self.oc_api.get_raw_url_for_json( + container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="perl") expected_output = "Welcome to your Dancer application" template_json = self.oc_api.get_raw_url_for_json( - container="dancer-ex", dir="openshift/templates", filename="dancer.json" + container="dancer-ex", + dir="openshift/templates", + filename="dancer.json" ) assert self.oc_api.deploy_template( template=template_json, name_in_template="dancer-example", expected_output=expected_output, - openshift_args=["SOURCE_REPOSITORY_REF=master", f"PERL_VERSION={VERSION}", "NAME=dancer-example"] + openshift_args=[ + "SOURCE_REPOSITORY_REF=master", + f"PERL_VERSION={VERSION}{TAG}", + "NAME=dancer-example"] ) - assert self.oc_api.template_deployed(name_in_template="dancer-example") + assert self.oc_api.is_template_deployed(name_in_template="dancer-example") assert self.oc_api.check_response_outside_cluster( name_in_template="dancer-example", expected_output=expected_output ) From 9a523b6c022b6e1a689e15cab4cb310269d66b03 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 19 May 2025 13:48:02 +0200 Subject: [PATCH 2/3] Add detection if test is runnable or not by the function. Change also some functions names based on the API container-ci-suite Signed-off-by: Petr "Stone" Hracek --- tests/test_dancer.py | 37 ++++------------------------------ tests/test_dancer_mysql.py | 41 +++++++++++++------------------------- 2 files changed, 18 insertions(+), 60 deletions(-) diff --git a/tests/test_dancer.py b/tests/test_dancer.py index 35b5faf..fe5cdbe 100644 --- a/tests/test_dancer.py +++ b/tests/test_dancer.py @@ -17,6 +17,10 @@ class TestDancerAppExTemplate: def setup_method(self): self.oc_api = OpenShiftAPI(pod_name_prefix="dancer-example") + json_raw_file = self.oc_api.get_raw_url_for_json( + container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="perl", skip_check=True) def teardown_method(self): self.oc_api.delete_project() @@ -25,10 +29,6 @@ def teardown_method(self): def test_local_template_inside_cluster(self): if not is_test_allowed(OS, VERSION): pytest.skip(f"Local templates are not supported for {OS} and {VERSION}") - json_raw_file = self.oc_api.get_raw_url_for_json( - container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json" - ) - self.oc_api.import_is(path=json_raw_file, name="perl") expected_output = "Welcome to your Dancer application" template_json = "../openshift/templates/dancer.json" assert self.oc_api.deploy_template( @@ -49,10 +49,6 @@ def test_local_template_inside_cluster(self): def test_template_inside_cluster(self): if not is_test_allowed(OS, VERSION): pytest.skip(f"Local templates are not supported for {OS} and {VERSION}") - json_raw_file = self.oc_api.get_raw_url_for_json( - container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json" - ) - self.oc_api.import_is(path=json_raw_file, name="perl") expected_output = "Welcome to your Dancer application" template_json = self.oc_api.get_raw_url_for_json( container="dancer-ex", dir="openshift/templates", filename="dancer.json" @@ -68,28 +64,3 @@ def test_template_inside_cluster(self): assert self.oc_api.check_response_inside_cluster( name_in_template="dancer-example", expected_output=expected_output ) - - def test_template_by_request(self): - if not is_test_allowed(OS, VERSION): - pytest.skip(f"Local templates are not supported for {OS} and {VERSION}") - json_raw_file = self.oc_api.get_raw_url_for_json( - container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json" - ) - self.oc_api.import_is(path=json_raw_file, name="perl") - expected_output = "Welcome to your Dancer application" - template_json = self.oc_api.get_raw_url_for_json( - container="dancer-ex", - dir="openshift/templates", - filename="dancer.json" - ) - assert self.oc_api.deploy_template( - template=template_json, name_in_template="dancer-example", expected_output=expected_output, - openshift_args=[ - "SOURCE_REPOSITORY_REF=master", - f"PERL_VERSION={VERSION}{TAG}", - "NAME=dancer-example"] - ) - assert self.oc_api.is_template_deployed(name_in_template="dancer-example") - assert self.oc_api.check_response_outside_cluster( - name_in_template="dancer-example", expected_output=expected_output - ) diff --git a/tests/test_dancer_mysql.py b/tests/test_dancer_mysql.py index ff4254b..c54a9f8 100644 --- a/tests/test_dancer_mysql.py +++ b/tests/test_dancer_mysql.py @@ -5,11 +5,13 @@ from container_ci_suite.openshift import OpenShiftAPI +from constants import TAGS, is_test_allowed test_dir = Path(os.path.abspath(os.path.dirname(__file__))) VERSION=os.getenv("SINGLE_VERSION") -if not VERSION: - VERSION="5.32-ubi8" +OS=os.getenv("OS") + +TAG = TAGS.get(OS) class TestDancerAppMySQLExTemplate: @@ -18,33 +20,37 @@ def setup_method(self): json_raw_file = self.oc_api.get_raw_url_for_json( container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json" ) - self.oc_api.import_is(path=json_raw_file, name="perl") + self.oc_api.import_is(path=json_raw_file, name="perl", skip_check=True) json_raw_file = self.oc_api.get_raw_url_for_json( container="mysql-container", dir="imagestreams", filename="mysql-rhel.json" ) - self.oc_api.import_is(path=json_raw_file, name="mysql") + self.oc_api.import_is(path=json_raw_file, name="mysql", skip_check=True) def teardown_method(self): self.oc_api.delete_project() def test_local_template_inside_cluster(self): + if not is_test_allowed(OS, VERSION): + pytest.skip(f"Local templates are not supported for {OS} and {VERSION}") expected_output = "Welcome to your Dancer application" template_json = "../openshift/templates/dancer-mysql-persistent.json" assert self.oc_api.deploy_template( template=template_json, name_in_template="dancer-example", expected_output=expected_output, openshift_args=[ "SOURCE_REPOSITORY_REF=master", - f"PERL_VERSION={VERSION}", + f"PERL_VERSION={VERSION}{TAG}", "NAME=dancer-example", "MYSQL_VERSION=8.0-el8" ] ) - assert self.oc_api.template_deployed(name_in_template="dancer-example") + assert self.oc_api.is_template_deployed(name_in_template="dancer-example") assert self.oc_api.check_response_inside_cluster( name_in_template="dancer-example", expected_output=expected_output ) def test_template_inside_cluster(self): + if not is_test_allowed(OS, VERSION): + pytest.skip(f"Local templates are not supported for {OS} and {VERSION}") expected_output = "Welcome to your Dancer application" template_json = self.oc_api.get_raw_url_for_json( container="dancer-ex", dir="openshift/templates", filename="dancer-mysql-persistent.json" @@ -53,31 +59,12 @@ def test_template_inside_cluster(self): template=template_json, name_in_template="dancer-example", expected_output=expected_output, openshift_args=[ "SOURCE_REPOSITORY_REF=master", - f"PERL_VERSION={VERSION}", + f"PERL_VERSION={VERSION}{TAG}", "NAME=dancer-example", "MYSQL_VERSION=8.0-el8" ] ) - assert self.oc_api.template_deployed(name_in_template="dancer-example") + assert self.oc_api.is_template_deployed(name_in_template="dancer-example") assert self.oc_api.check_response_inside_cluster( name_in_template="dancer-example", expected_output=expected_output ) - - def test_template_by_request(self): - expected_output = "Welcome to your Dancer application" - template_json = self.oc_api.get_raw_url_for_json( - container="dancer-ex", dir="openshift/templates", filename="dancer-mysql-persistent.json" - ) - assert self.oc_api.deploy_template( - template=template_json, name_in_template="dancer-example", expected_output=expected_output, - openshift_args=[ - "SOURCE_REPOSITORY_REF=master", - f"PERL_VERSION={VERSION}", - "NAME=dancer-example", - "MYSQL_VERSION=8.0-el8" - ] - ) - assert self.oc_api.template_deployed(name_in_template="dancer-example") - assert self.oc_api.check_response_outside_cluster( - name_in_template="dancer-example", expected_output=expected_output - ) From 2e755bedf4dee92b0b5276c623103b97bd655b7e Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 12 Aug 2025 13:33:24 +0200 Subject: [PATCH 3/3] Perl-532 for RHEL8 were deprecated in Apr 2025. Remove it. Signed-off-by: Petr "Stone" Hracek --- tests/constants.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/constants.py b/tests/constants.py index 1f69056..7b58890 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -7,8 +7,6 @@ def is_test_allowed(os, version): if os == "rhel8" and version == "5.26": return True - if os == "rhel8" and version == "5.32": - return True if os == "rhel9" and version == "5.32": return True if os == "rhel10" and version == "5.40":