From fe88fb9714cbfa9718e9c4c55215ce4ae99f4add Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Fri, 15 Mar 2024 11:09:36 +0100 Subject: [PATCH 1/2] Add nginx-ex tests executed on OpenShift 4 Signed-off-by: Petr "Stone" Hracek --- Makefile | 3 +++ tests/test_nginx.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Makefile create mode 100644 tests/test_nginx.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_nginx.py b/tests/test_nginx.py new file mode 100644 index 00000000..e12f8a36 --- /dev/null +++ b/tests/test_nginx.py @@ -0,0 +1,50 @@ +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="1.20-ubi8" + +class TestNginxExTemplate: + + def setup_method(self): + self.oc_api = OpenShiftAPI(pod_name_prefix="nginx-example") + json_raw_file = self.oc_api.get_raw_url_for_json( + container="nginx-container", dir="imagestreams", filename="nginx-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="nginx") + + def teardown_method(self): + self.oc_api.delete_project() + + def test_template_inside_cluster(self): + template_json = self.oc_api.get_raw_url_for_json( + container="nginx-ex", dir="openshift/templates", filename="nginx.json" + ) + assert self.oc_api.deploy_template( + template=template_json, name_in_template="nginx-example", expected_output="Welcome to your static nginx application", + openshift_args=["SOURCE_REPOSITORY_REF=master", f"NGINX_VERSION={VERSION}", "NAME=nginx-example"] + ) + assert self.oc_api.template_deployed(name_in_template="nginx-example") + assert self.oc_api.check_response_inside_cluster( + name_in_template="nginx-example", expected_output="Welcome to your static nginx application" + ) + + def test_template_by_request(self): + template_json = self.oc_api.get_raw_url_for_json( + container="nginx-ex", dir="openshift/templates", filename="nginx.json" + ) + assert self.oc_api.deploy_template( + template=template_json, name_in_template="nginx-example", expected_output="Welcome to your static nginx application", + openshift_args=["SOURCE_REPOSITORY_REF=master", f"NGINX_VERSION={VERSION}", "NAME=nginx-example"] + ) + assert self.oc_api.template_deployed(name_in_template="nginx-example") + assert self.oc_api.check_response_outside_cluster( + name_in_template="nginx-example", expected_output="Welcome to your static nginx application" + ) From f0aee90c3560e4f33969c0a233471f3558e81a91 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 18 Mar 2024 13:35:59 +0100 Subject: [PATCH 2/2] Nginx 1.20-ubi8 is not supported. It reached EOL. Signed-off-by: Petr "Stone" Hracek --- .github/workflows/openshift-tests.yml | 2 +- tests/test_nginx.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml index a0ca62e7..dc444d7a 100644 --- a/.github/workflows/openshift-tests.yml +++ b/.github/workflows/openshift-tests.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - version: [ "1.20-ubi7", "1.20-ubi8", "1.22-ubi8", "1.20-ubi9", "1.22-ubi9" ] + version: [ "1.20-ubi7", "1.22-ubi8", "1.20-ubi9", "1.22-ubi9" ] if: | github.event.issue.pull_request diff --git a/tests/test_nginx.py b/tests/test_nginx.py index e12f8a36..3f49df93 100644 --- a/tests/test_nginx.py +++ b/tests/test_nginx.py @@ -9,7 +9,7 @@ VERSION=os.getenv("SINGLE_VERSION") if not VERSION: - VERSION="1.20-ubi8" + VERSION="1.22-ubi8" class TestNginxExTemplate: