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..7b58890 --- /dev/null +++ b/tests/constants.py @@ -0,0 +1,14 @@ +TAGS = { + "rhel8": "-ubi8", + "rhel9": "-ubi9", + "rhel10": "-ubi10", +} + +def is_test_allowed(os, version): + if os == "rhel8" and version == "5.26": + 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..fe5cdbe 100644 --- a/tests/test_dancer.py +++ b/tests/test_dancer.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 TestDancerAppExTemplate: @@ -18,52 +20,47 @@ 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) 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.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}") 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): - 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"] - ) - 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 - ) 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 - )