From ea2dface84dc441008f12ca36dc6c95157cc7cfd Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 12 Mar 2024 16:40:51 +0100 Subject: [PATCH 1/2] Test suite for httpd-ex repository Signed-off-by: Petr "Stone" Hracek --- Makefile | 3 +++ tests/test_httpd_template.py | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 Makefile create mode 100644 tests/test_httpd_template.py diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..97a95a66 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +.PHONY: test-openshift-4 +test-openshift-4: + cd tests && PYTHONPATH=$(CURDIR) python3 -m pytest --verbose --color=yes --showlocals . \ No newline at end of file diff --git a/tests/test_httpd_template.py b/tests/test_httpd_template.py new file mode 100644 index 00000000..761cd757 --- /dev/null +++ b/tests/test_httpd_template.py @@ -0,0 +1,38 @@ +import os + +import pytest +from pathlib import Path + +from container_ci_suite.openshift import OpenShiftAPI + +test_dir = Path(os.path.abspath(os.path.dirname(__file__))) + +VERSION=os.getenv("SINGLE_VERSION") +if not VERSION: + VERSION="2.4-el8" + +@pytest.mark.parametrize('VERSION', ["2.4-el7", "2.4-el8", "2.4-ubi8", "2.4-ubi9"]) +class TestHTTPDExTemplate: + + def setup_method(self): + self.oc_api = OpenShiftAPI(pod_name_prefix="httpd-example") + json_raw_file = self.oc_api.get_raw_url_for_json( + container="httpd-container", dir="imagestreams", filename="httpd-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="httpd") + + def teardown_method(self): + self.oc_api.delete_project() + + def test_httpd_ex_template_by_request(self, VERSION): + template_json = self.oc_api.get_raw_url_for_json( + container="httpd-ex", dir="openshift/templates", filename="httpd.json" + ) + assert self.oc_api.deploy_template( + template=template_json, name_in_template="httpd-example", expected_output="Welcome to your static httpd", + openshift_args=["SOURCE_REPOSITORY_REF=master", f"HTTPD_VERSION={VERSION}", "NAME=httpd-example"] + ) + assert self.oc_api.template_deployed(name_in_template="httpd-example") + assert self.oc_api.check_response_outside_cluster( + name_in_template="httpd-example", port=8080, expected_output="Welcome to your static httpd" + ) From 7e97545d43c773a21d9d13be49ed0d751868720b Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Thu, 14 Mar 2024 15:38:55 +0100 Subject: [PATCH 2/2] Add support for testing httpd-ex repository also within OCP4 cluster Signed-off-by: Petr "Stone" Hracek --- tests/test_httpd_template.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/test_httpd_template.py b/tests/test_httpd_template.py index 761cd757..93d50338 100644 --- a/tests/test_httpd_template.py +++ b/tests/test_httpd_template.py @@ -11,7 +11,6 @@ if not VERSION: VERSION="2.4-el8" -@pytest.mark.parametrize('VERSION', ["2.4-el7", "2.4-el8", "2.4-ubi8", "2.4-ubi9"]) class TestHTTPDExTemplate: def setup_method(self): @@ -24,7 +23,20 @@ def setup_method(self): def teardown_method(self): self.oc_api.delete_project() - def test_httpd_ex_template_by_request(self, VERSION): + def test_httpd_ex_template_inside_cluster(self): + template_json = self.oc_api.get_raw_url_for_json( + container="httpd-ex", dir="openshift/templates", filename="httpd.json" + ) + assert self.oc_api.deploy_template( + template=template_json, name_in_template="httpd-example", expected_output="Welcome to your static httpd", + openshift_args=["SOURCE_REPOSITORY_REF=master", f"HTTPD_VERSION={VERSION}", "NAME=httpd-example"] + ) + assert self.oc_api.template_deployed(name_in_template="httpd-example") + assert self.oc_api.check_response_inside_cluster( + name_in_template="httpd-example", expected_output="Welcome to your static httpd" + ) + + def test_httpd_ex_template_by_request(self): template_json = self.oc_api.get_raw_url_for_json( container="httpd-ex", dir="openshift/templates", filename="httpd.json" ) @@ -34,5 +46,5 @@ def test_httpd_ex_template_by_request(self, VERSION): ) assert self.oc_api.template_deployed(name_in_template="httpd-example") assert self.oc_api.check_response_outside_cluster( - name_in_template="httpd-example", port=8080, expected_output="Welcome to your static httpd" + name_in_template="httpd-example", expected_output="Welcome to your static httpd" )