From a8366da6b5f603f21e6ae5da2cc0a7fb95279bb9 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 7 Oct 2025 10:44:57 +0200 Subject: [PATCH 1/2] Fix calling OpenShift 4 PyTest suite. The test suite was renamed from `test_httpd_*.py` to `test_ocp_*.py`. Signed-off-by: Petr "Stone" Hracek --- test/run-openshift-pytest | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/run-openshift-pytest b/test/run-openshift-pytest index 3074b5d5..6a607db8 100755 --- a/test/run-openshift-pytest +++ b/test/run-openshift-pytest @@ -7,5 +7,9 @@ # THISDIR=$(dirname ${BASH_SOURCE[0]}) +PYTHON_VERSION="3.12" +if [[ ! -f "/usr/bin/python$PYTHON_VERSION" ]]; then + PYTHON_VERSION="3.13" +fi -cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_httpd*.py +cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_ocp_*.py From 211499bcadbfb8d46f27194ed3644dfcd93ebf24 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 7 Oct 2025 14:07:46 +0200 Subject: [PATCH 2/2] Fix PyTest container test suite. expected_code is by default 200, so remove duplicate information. Also start url with http:// Signed-off-by: Petr "Stone" Hracek --- test/test_container_httpd.py | 11 +++++++---- test/test_container_httpd_s2i.py | 8 +++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/test/test_container_httpd.py b/test/test_container_httpd.py index 0811e6e4..1b64e203 100644 --- a/test/test_container_httpd.py +++ b/test/test_container_httpd.py @@ -50,7 +50,10 @@ def test_dockerfiles(self, dockerfile): assert self.app.test_app_dockerfile() cip = self.app.get_cip() assert cip - assert self.app.test_response(url=cip, expected_code=200, expected_output="Welcome to your static httpd application on OpenShift") + assert self.app.test_response( + url=f"http://{cip}", + expected_output="Welcome to your static httpd application on OpenShift" + ) @pytest.mark.parametrize( "mpm_config", @@ -67,7 +70,7 @@ def test_mpm_config(self, mpm_config): # Let's check that server really response HTTP-403 # See function here: in test/run `_run_mpm_config_test` # https://github.com/sclorg/httpd-container/blob/master/test/run#L97 - assert self.app.test_response(url=cip, port=8080, expected_code=403) + assert self.app.test_response(url=f"http://{cip}", expected_code=403) logs = self.app.get_logs(cid_file_name=cid_name) assert re.search(f"mpm_{mpm_config}:notice.*resuming normal operations", logs) @@ -86,7 +89,7 @@ def test_log_to_data_volume(self): container_args=f"-e HTTPD_LOG_TO_VOLUME=1 --user 0 -v {data_dir}:/var/log/httpd" ) cip = self.app.get_cip(cid_file_name="test_log_dir") - assert self.app.test_response(url=cip, port=8080, expected_code=403) + assert self.app.test_response(url=f"http://{cip}", expected_code=403) assert ContainerTestLibUtils.check_files_are_present( dir_name=data_dir, file_name_to_check=[ "access_log", @@ -113,4 +116,4 @@ def test_data_volume(self): ) cip = self.app.get_cip(cid_file_name="doc_root") assert cip - assert self.app.test_response(url=cip, port=8080, expected_code=200, expected_output="hello") + assert self.app.test_response(url=f"http://{cip}", expected_output="hello") diff --git a/test/test_container_httpd_s2i.py b/test/test_container_httpd_s2i.py index d29b1b4c..38d819db 100644 --- a/test/test_container_httpd_s2i.py +++ b/test/test_container_httpd_s2i.py @@ -39,8 +39,7 @@ def test_run_pre_init_test(self): cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) assert cip assert self.s2i_app.test_response( - url=cip, - expected_code=200, + url=f"http://{cip}", expected_output="This content was replaced by pre-init script." ) @@ -59,8 +58,7 @@ def test_sample_app(self): assert cip response = "This is a sample s2i application with static content." assert self.s2i_app.test_response( - url=cip, - expected_code=200, + url=f"http://{cip}", expected_output=response ) assert self.s2i_app.test_response( @@ -135,7 +133,7 @@ def test_self_cert_test(self): assert self.s2i_app.create_container(cid_file_name=self.s2i_app.app_name, container_args="--user 1000") cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) assert cip - assert self.s2i_app.test_response(url=cip, expected_code=200, expected_output="SSL test works") + assert self.s2i_app.test_response(url=f"http://{cip}", expected_output="SSL test works") assert self.s2i_app.test_response(url=f"https://{cip}", port=8443, expected_output="SSL test works") server_cmd = f"openssl s_client -showcerts -servername {cip} -connect {cip}:8443 2>/dev/null" server_output = ContainerTestLibUtils.run_command(cmd=server_cmd)