diff --git a/20-minimal/test/__init__.py b/20-minimal/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/20-minimal/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/20-minimal/test/conftest.py b/20-minimal/test/conftest.py new file mode 120000 index 00000000..3f2d7840 --- /dev/null +++ b/20-minimal/test/conftest.py @@ -0,0 +1 @@ +../../test/conftest.py \ No newline at end of file diff --git a/20-minimal/test/run-pytest b/20-minimal/test/run-pytest new file mode 120000 index 00000000..efe32b48 --- /dev/null +++ b/20-minimal/test/run-pytest @@ -0,0 +1 @@ +../../test/run-pytest \ No newline at end of file diff --git a/20-minimal/test/test-fips b/20-minimal/test/test-fips new file mode 120000 index 00000000..fbe9489f --- /dev/null +++ b/20-minimal/test/test-fips @@ -0,0 +1 @@ +../../test/test-fips \ No newline at end of file diff --git a/20-minimal/test/test_container_apps.py b/20-minimal/test/test_container_apps.py new file mode 120000 index 00000000..9870de8e --- /dev/null +++ b/20-minimal/test/test_container_apps.py @@ -0,0 +1 @@ +../../test/test_container_apps.py \ No newline at end of file diff --git a/20-minimal/test/test_container_basics.py b/20-minimal/test/test_container_basics.py new file mode 120000 index 00000000..b85dc139 --- /dev/null +++ b/20-minimal/test/test_container_basics.py @@ -0,0 +1 @@ +../../test/test_container_basics.py \ No newline at end of file diff --git a/22-minimal/test/__init__.py b/22-minimal/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/22-minimal/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/22-minimal/test/conftest.py b/22-minimal/test/conftest.py new file mode 120000 index 00000000..3f2d7840 --- /dev/null +++ b/22-minimal/test/conftest.py @@ -0,0 +1 @@ +../../test/conftest.py \ No newline at end of file diff --git a/22-minimal/test/run-pytest b/22-minimal/test/run-pytest new file mode 120000 index 00000000..efe32b48 --- /dev/null +++ b/22-minimal/test/run-pytest @@ -0,0 +1 @@ +../../test/run-pytest \ No newline at end of file diff --git a/22-minimal/test/test-fips b/22-minimal/test/test-fips new file mode 120000 index 00000000..fbe9489f --- /dev/null +++ b/22-minimal/test/test-fips @@ -0,0 +1 @@ +../../test/test-fips \ No newline at end of file diff --git a/22-minimal/test/test_container_apps.py b/22-minimal/test/test_container_apps.py new file mode 120000 index 00000000..9870de8e --- /dev/null +++ b/22-minimal/test/test_container_apps.py @@ -0,0 +1 @@ +../../test/test_container_apps.py \ No newline at end of file diff --git a/22-minimal/test/test_container_basics.py b/22-minimal/test/test_container_basics.py new file mode 120000 index 00000000..b85dc139 --- /dev/null +++ b/22-minimal/test/test_container_basics.py @@ -0,0 +1 @@ +../../test/test_container_basics.py \ No newline at end of file diff --git a/24-minimal/test/__init__.py b/24-minimal/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/24-minimal/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/24-minimal/test/conftest.py b/24-minimal/test/conftest.py new file mode 120000 index 00000000..3f2d7840 --- /dev/null +++ b/24-minimal/test/conftest.py @@ -0,0 +1 @@ +../../test/conftest.py \ No newline at end of file diff --git a/24-minimal/test/run-pytest b/24-minimal/test/run-pytest new file mode 120000 index 00000000..efe32b48 --- /dev/null +++ b/24-minimal/test/run-pytest @@ -0,0 +1 @@ +../../test/run-pytest \ No newline at end of file diff --git a/24-minimal/test/test-fips b/24-minimal/test/test-fips new file mode 120000 index 00000000..fbe9489f --- /dev/null +++ b/24-minimal/test/test-fips @@ -0,0 +1 @@ +../../test/test-fips \ No newline at end of file diff --git a/24-minimal/test/test_container_apps.py b/24-minimal/test/test_container_apps.py new file mode 120000 index 00000000..9870de8e --- /dev/null +++ b/24-minimal/test/test_container_apps.py @@ -0,0 +1 @@ +../../test/test_container_apps.py \ No newline at end of file diff --git a/24-minimal/test/test_container_basics.py b/24-minimal/test/test_container_basics.py new file mode 120000 index 00000000..b85dc139 --- /dev/null +++ b/24-minimal/test/test_container_basics.py @@ -0,0 +1 @@ +../../test/test_container_basics.py \ No newline at end of file diff --git a/test/conftest.py b/test/conftest.py new file mode 100644 index 00000000..db59a1cd --- /dev/null +++ b/test/conftest.py @@ -0,0 +1,66 @@ +import os +import sys + +from collections import namedtuple +from pathlib import Path +from pytest import skip + +from container_ci_suite.utils import check_variables + +if not check_variables(): + sys.exit(1) + +OS = os.getenv("TARGET").lower() +VERSION = os.getenv("VERSION") +IMAGE_TAG = "15-c9s" +PGSQL_IMAGE_TAG = f"postgresql:{IMAGE_TAG}" +DEPLOYED_PGSQL_IMAGE = f"quay.io/sclorg/postgresql-{IMAGE_TAG}" +TAGS = { + "rhel8": "-ubi8", + "rhel9": "-ubi9", + "rhel10": "-ubi10", +} +PSQL_TAGS = { + "rhel8": "-el8", + "rhel9": "-el9", + "rhel10": "-el10", +} + +Vars = namedtuple( + "Vars", + [ + "OS", + "VERSION", + "TAG", + "IMAGE_TAG", + "PSQL_TAGS", + "PGSQL_IMAGE_TAG", + "DEPLOYED_PGSQL_IMAGE", + "IMAGE_NAME", + "IS_MINIMAL", + "VERSION_NO_MINIMAL", + "SHORT_VERSION", + "TEST_DIR", + ], +) + + +VARS = Vars( + OS=OS, + VERSION=VERSION, + TAG=TAGS.get(OS), + IMAGE_TAG=IMAGE_TAG, + PSQL_TAGS=PSQL_TAGS.get(OS), + PGSQL_IMAGE_TAG=PGSQL_IMAGE_TAG, + DEPLOYED_PGSQL_IMAGE=DEPLOYED_PGSQL_IMAGE, + IMAGE_NAME=os.getenv("IMAGE_NAME"), + IS_MINIMAL="minimal" in VERSION, + VERSION_NO_MINIMAL=VERSION.replace("-minimal", ""), + SHORT_VERSION=VERSION.replace("-minimal", "").replace(".", ""), + TEST_DIR=Path(__file__).parent.absolute(), +) + + +def skip_for_minimal(): + if "minimal" in VARS.VERSION: + skip("This test is not available for NodeJS minimal container") diff --git a/test/constants.py b/test/constants.py deleted file mode 100644 index e0402ba6..00000000 --- a/test/constants.py +++ /dev/null @@ -1,5 +0,0 @@ -TAGS = { - "rhel8": "-ubi8", - "rhel9": "-ubi9", - "rhel10": "-ubi10", -} diff --git a/test/run-openshift-pytest b/test/run-openshift-pytest index 80885f16..fad21c89 100755 --- a/test/run-openshift-pytest +++ b/test/run-openshift-pytest @@ -8,4 +8,4 @@ THISDIR=$(dirname ${BASH_SOURCE[0]}) -cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_*.py +cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_ocp_*.py diff --git a/test/run-pytest b/test/run-pytest new file mode 100755 index 00000000..35fca679 --- /dev/null +++ b/test/run-pytest @@ -0,0 +1,15 @@ +#!/bin/bash +# +# IMAGE_NAME specifies a name of the candidate image used for testing. +# The image has to be available before this script is executed. +# SINGLE_VERSION specifies the major version of httpd +# OS specifies RHEL version (e.g. OS=rhel8) +# + +THISDIR=$(dirname ${BASH_SOURCE[0]}) + +PYTHON_VERSION="3.12" +if [[ ! -f "/usr/bin/python$PYTHON_VERSION" ]]; then + PYTHON_VERSION="3.13" +fi +cd "${THISDIR}" && "python${PYTHON_VERSION}" -m pytest -s -rA --showlocals -vv test_container_*.py diff --git a/test/test-fips/test.js b/test/test-fips/test.js new file mode 100644 index 00000000..f2ef5daa --- /dev/null +++ b/test/test-fips/test.js @@ -0,0 +1,3 @@ +const crypto = require('crypto'); + +process.exit(crypto.getFips()); diff --git a/test/test-lib-nodejs.sh b/test/test-lib-nodejs.sh index 91ac8408..c82ab9e6 100644 --- a/test/test-lib-nodejs.sh +++ b/test/test-lib-nodejs.sh @@ -495,12 +495,12 @@ function test_nodejs_fips_mode() { if [[ "$is_fips_enabled" == "0" ]]; then # FIPS disabled -- crypto.getFips() should return 0 echo "Fips should be disabled" - docker run --rm ${IMAGE_NAME}-testfips /bin/bash -c "node -e 'const crypto = require(\"crypto\"); process.exit(crypto.getFips());'" + docker run --rm ${IMAGE_NAME}-testfips /bin/bash -c "node test.js" ct_check_testcase_result "$?" else # FIPS enabled -- crypto.getFips() should return 1 echo "Fips should be enabled" - docker run --rm ${IMAGE_NAME}-testfips /bin/bash -c "! node -e 'const crypto = require(\"crypto\"); process.exit(crypto.getFips());'" + docker run --rm ${IMAGE_NAME}-testfips /bin/bash -c "! node test.js" ct_check_testcase_result "$?" fi } diff --git a/test/test_container_apps.py b/test/test_container_apps.py new file mode 100644 index 00000000..a2342dfe --- /dev/null +++ b/test/test_container_apps.py @@ -0,0 +1,492 @@ +import re + +from pathlib import Path + +import pytest +from container_ci_suite.container_lib import ContainerTestLib +from container_ci_suite.engines.podman_wrapper import PodmanCLIWrapper + +from conftest import VARS, skip_for_minimal + + +test_app = VARS.TEST_DIR / "test-app" +test_binary = VARS.TEST_DIR / "test-binary" +test_express_webapp = VARS.TEST_DIR / "test-express-webapp" +test_fips = VARS.TEST_DIR / "test-fips" +test_hw = VARS.TEST_DIR / "test-hw" +test_incremental = VARS.TEST_DIR / "test-incremental" + + +def build_s2i_app(app_path: Path, container_args: str = "") -> ContainerTestLib: + """ + Build a S2I application. + """ + container_lib = ContainerTestLib(VARS.IMAGE_NAME) + app_name = app_path.name + s2i_app = container_lib.build_as_df( + app_path=app_path, + s2i_args=f"--pull-policy=never {container_lib.build_s2i_npm_variables()} {container_args}", + src_image=VARS.IMAGE_NAME, + dst_image=f"{VARS.IMAGE_NAME}-{app_name}", + ) + return s2i_app + + +class TestNodeJSAppsContainer: + """ + Test NodeJS apps of a NodeJS application. + """ + + def setup_method(self): + """ + Setup the test environment. + """ + self.s2i_app = build_s2i_app(test_app) + + def teardown_method(self): + """ + Cleanup the test environment. + """ + self.s2i_app.cleanup() + + def test_run_app_application(self): + """ + Test run app application of a NodeJS application. + """ + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, container_args="--user 100001" + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + + def test_nodemon_removed(self): + """ + Test nodemon removed of a NodeJS application. + """ + return_value = PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd="! test -d ./node_modules/nodemon", + return_output=False, + ) + assert return_value == 0 + + def test_npm_cache_cleared(self): + """ + Test npm cache cleared of a NodeJS application. + """ + cache_loc = PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd="npm config get cache", + ).strip() + assert ( + PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd=f"! test -d {cache_loc}", + return_output=False, + ) + == 0 + ) + + def test_npm_tmp_cleared(self): + """ + Test npm tmp cleared of a NodeJS application. + """ + tmp_config = PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd="npm config get tmp", + ) + assert tmp_config.strip() == "undefined" + + @pytest.mark.parametrize( + "node_env,init_wrapper", + [ + ("development", "true"), + ("production", "true"), + ("development", "false"), + ], + ) + def test_node_cmd_development(self, node_env, init_wrapper): + """ + Test node command development of a NodeJS application. + """ + skip_for_minimal() + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, + container_args=f"--user 100001 '-e NODE_ENV={node_env} " + f"-e INIT_WRAPPER={init_wrapper} -e NODE_CMD=node server.js'", + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + logs = self.s2i_app.get_logs(self.s2i_app.app_name) + assert re.search(f"NODE_ENV={node_env}", logs) + assert re.search("DEBUG_PORT=5858", logs) + assert re.search(f"INIT_WRAPPER={init_wrapper}", logs) + assert re.search("NODE_CMD=node server.js", logs) + + @pytest.mark.parametrize( + "dev_mode,node_env", + [ + ("true", "development"), + ("false", "production"), + ], + ) + def test_dev_node(self, dev_mode, node_env): + """ + Test dev node of a NodeJS application. + """ + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, + container_args=f"--user 100001 '-e DEV_MODE={dev_mode}'", + ) + logs = self.s2i_app.get_logs(self.s2i_app.app_name) + print(f"AppsContainer '{logs}'.") + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + assert re.search(f"DEV_MODE={dev_mode}", logs) + assert re.search("DEBUG_PORT=5858", logs) + assert re.search(f"NODE_ENV={node_env}", logs) + + @pytest.mark.parametrize( + "node_env,init_wrapper", + [ + ("production", "false"), + ("development", "false"), + ("development", "true"), + ], + ) + def test_node_init_wrapper(self, node_env, init_wrapper): + """ + Test node init wrapper of a NodeJS application. + """ + skip_for_minimal() + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, + container_args=f"--user 100001 '-e NODE_ENV={node_env} " + f"-e INIT_WRAPPER={init_wrapper}'", + ) + logs = self.s2i_app.get_logs(self.s2i_app.app_name) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}", debug=True) + assert re.search(f"NODE_ENV={node_env}", logs) + assert re.search("DEBUG_PORT=5858", logs) + assert re.search(f"INIT_WRAPPER={init_wrapper}", logs) + + +class TestNodeJSAppsWithDevModeTrueContainer: + """ + Test NodeJS apps with DevMode true of a NodeJS application. + """ + + def setup_method(self): + """ + Setup the test environment. + """ + self.s2i_app = build_s2i_app(test_app, container_args="-e DEV_MODE=true") + + def teardown_method(self): + """ + Cleanup the test environment. + """ + self.s2i_app.cleanup() + + def test_run_app_application(self): + """ + Test run app application of a NodeJS application. + """ + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, container_args="--user 100001" + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + + def test_nodemon_present(self): + """ + Test nodemon present of a NodeJS application. + """ + return_value = PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd="test -d ./node_modules/nodemon", + return_output=False, + ) + assert return_value == 0 + + def test_npm_cache_exist(self): + """ + Test npm cache exist of a NodeJS application. + """ + cache_loc = PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd="npm config get cache", + ).strip() + assert ( + PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd=f"test -d {cache_loc}", + return_output=False, + ) + == 0 + ) + + @pytest.mark.parametrize( + "dev_mode,node_env", + [ + ("true", "development"), + ("false", "production"), + ], + ) + def test_dev_node(self, dev_mode, node_env): + """ + Test dev node of a NodeJS application. + """ + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, + container_args=f"--user 100001 '-e DEV_MODE={dev_mode}'", + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + logs = self.s2i_app.get_logs(self.s2i_app.app_name) + assert re.search(f"DEV_MODE={dev_mode}", logs) + assert re.search("DEBUG_PORT=5858", logs) + assert re.search(f"NODE_ENV={node_env}", logs) + + @pytest.mark.parametrize( + "node_env,init_wrapper", + [ + ("development", "true"), + ("production", "true"), + ("development", "false"), + ], + ) + def test_node_cmd_development(self, node_env, init_wrapper): + """ + Test node command development of a NodeJS application. + """ + skip_for_minimal() + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, + container_args=f"--user 100001 '-e NODE_ENV={node_env} " + f"-e INIT_WRAPPER={init_wrapper} -e NODE_CMD=node server.js'", + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + logs = self.s2i_app.get_logs(self.s2i_app.app_name) + assert re.search(f"NODE_ENV={node_env}", logs) + assert re.search("DEBUG_PORT=5858", logs) + assert re.search(f"INIT_WRAPPER={init_wrapper}", logs) + assert re.search("NODE_CMD=node server.js", logs) + + +class TestNodeJSAppsWithNodeEnvDevelopmentContainer: + """ + Test NodeJS apps with NodeEnv development of a NodeJS application. + """ + + def setup_method(self): + """ + Setup the test environment. + """ + self.s2i_app = build_s2i_app(test_app, container_args="-e NODE_ENV=development") + + def teardown_method(self): + """ + Cleanup the test environment. + """ + self.s2i_app.cleanup() + + def test_run_app_application(self): + """ + Test run app application of a NodeJS application. + """ + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, container_args="--user 100001" + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + + def test_nodemon_present(self): + """ + Test nodemon present of a NodeJS application. + """ + return_value = PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd="test -d ./node_modules/nodemon", + return_output=False, + ) + assert return_value == 0 + + def test_npm_cache_exist(self): + """ + Test npm cache exist of a NodeJS application. + """ + cache_loc = PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd="npm config get cache", + ).strip() + assert ( + PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_app.app_name}", + cmd=f"test -d {cache_loc}", + return_output=False, + ) + == 0 + ) + + @pytest.mark.parametrize( + "dev_mode,node_env", + [ + ("true", "development"), + ("false", "development"), + ], + ) + def test_dev_node(self, dev_mode, node_env): + """ + Test dev node of a NodeJS application. + """ + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, + container_args=f"--user 100001 '-e DEV_MODE={dev_mode}'", + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + logs = self.s2i_app.get_logs(self.s2i_app.app_name) + assert re.search(f"DEV_MODE={dev_mode}", logs) + assert re.search("DEBUG_PORT=5858", logs) + assert re.search(f"NODE_ENV={node_env}", logs) + + @pytest.mark.parametrize( + "node_env,init_wrapper", + [ + ("development", "true"), + ("production", "true"), + ("production", "false"), + ], + ) + def test_node_cmd_development(self, node_env, init_wrapper): + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, + container_args=f"--user 100001 '-e NODE_ENV={node_env} " + f"-e INIT_WRAPPER={init_wrapper} -e NODE_CMD=node server.js'", + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + logs = self.s2i_app.get_logs(self.s2i_app.app_name) + assert re.search(f"NODE_ENV={node_env}", logs) + assert re.search("DEBUG_PORT=5858", logs) + assert re.search(f"INIT_WRAPPER={init_wrapper}", logs) + assert re.search("NODE_CMD=node server.js", logs) + + +class TestNodeJSAppsHWContainer: + """ + Test HW of a NodeJS application. + """ + + def setup_method(self): + """ + Setup the test environment. + """ + http_proxy = "http://user.password@0.0.0.0:8080" + https_proxy = "https://user.password@0.0.0.0:8080" + self.s2i_app = build_s2i_app( + test_hw, + container_args=f"-e HTTP_PROXY={http_proxy} -e http_proxy={http_proxy} " + f"-e HTTPS_PROXY={https_proxy} -e https_proxy={https_proxy}", + ) + + def teardown_method(self): + """ + Cleanup the test environment. + """ + self.s2i_app.cleanup() + + def test_run_app_application(self): + """ + Test run app application of a NodeJS application. + """ + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, container_args="--user 100001" + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + + def test_node_init_wrapper(self): + """ + Test node init wrapper of a NodeJS application. + """ + skip_for_minimal() + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, + container_args="--user 100001 '-e NODE_ENV=development " + "-e INIT_WRAPPER=false'", + ) + logs = self.s2i_app.get_logs(self.s2i_app.app_name) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}", debug=True) + assert re.search("NODE_ENV=development", logs) + assert re.search("DEBUG_PORT=5858", logs) + assert re.search("INIT_WRAPPER=false", logs) + + def test_node_cmd_development(self): + """ + Test node command development of a NodeJS application. + """ + skip_for_minimal() + assert self.s2i_app.create_container( + cid_file_name=self.s2i_app.app_name, + container_args="--user 100001 '-e NODE_ENV=development " + "-e INIT_WRAPPER=true -e NODE_CMD=node server.js'", + ) + cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name) + assert cip + assert self.s2i_app.test_response(url=f"http://{cip}") + logs = self.s2i_app.get_logs(self.s2i_app.app_name) + assert re.search("NODE_ENV=development", logs) + assert re.search("DEBUG_PORT=5858", logs) + assert re.search("INIT_WRAPPER=true", logs) + assert re.search("NODE_CMD=node server.js", logs) + + def test_safe_logging(self): + podman_log_file = self.s2i_app.get_podman_build_log_file() + assert podman_log_file.count("redacted") == 4 + assert "redacted" in podman_log_file + + +class TestNodeJSIncrementalAppContainer: + """ + Test incremental build of a NodeJS application. + """ + + def setup_method(self): + """ + Setup the test environment. + """ + self.build1 = build_s2i_app(test_incremental) + self.build2 = build_s2i_app(test_incremental, container_args="--incremental") + + def teardown_method(self): + """ + Cleanup the test environment. + """ + self.build1.cleanup() + self.build2.cleanup() + + def test_incremental_build(self): + """ + Test incremental build of a NodeJS application. + """ + skip_for_minimal() + build_log1 = self.build1.get_podman_build_log_file() + build_log2 = self.build2.get_podman_build_log_file() + assert build_log1 != build_log2 diff --git a/test/test_container_basics.py b/test/test_container_basics.py new file mode 100644 index 00000000..a183c076 --- /dev/null +++ b/test/test_container_basics.py @@ -0,0 +1,148 @@ +import pytest + +from pathlib import Path + +from container_ci_suite.container_lib import ContainerTestLib, PodmanCLIWrapper +from container_ci_suite.utils import get_file_content + +from conftest import VARS, skip_for_minimal + + +test_fips = VARS.TEST_DIR / "test-fips" + + +def build_s2i_app(app_path: Path) -> ContainerTestLib: + """ + Build a S2I application. + """ + container_lib = ContainerTestLib(VARS.IMAGE_NAME) + app_name = app_path.name + s2i_app = container_lib.build_as_df( + app_path=app_path, + s2i_args=f"--pull-policy=never {container_lib.build_s2i_npm_variables()}", + src_image=VARS.IMAGE_NAME, + dst_image=f"{VARS.IMAGE_NAME}-{app_name}", + ) + return s2i_app + + +class TestNodeJSAppContainer: + """ + Test NodeJS app of a NodeJS application. + """ + + def setup_method(self): + """ + Setup the test environment. + """ + self.app = ContainerTestLib(image_name=VARS.IMAGE_NAME, s2i_image=True) + + def teardown_method(self): + """ + Cleanup the test environment. + """ + self.app.cleanup() + + def test_run_s2i_usage(self): + """ + Test if /usr/libexec/s2i/usage works properly + """ + output = self.app.s2i_usage() + assert output + + def test_docker_run_usage(self): + """ + Test if podman run works properly + """ + assert ( + PodmanCLIWrapper.call_podman_command( + cmd=f"run --rm {VARS.IMAGE_NAME} &>/dev/null", return_output=False + ) + == 0 + ) + + def test_scl_usage(self): + """ + Test if node --version works properly + """ + assert VARS.VERSION_NO_MINIMAL in PodmanCLIWrapper.podman_run_command( + f"--rm {VARS.IMAGE_NAME} /bin/bash -c 'node --version'" + ) + + @pytest.mark.parametrize("dockerfile", ["Dockerfile", "Dockerfile.s2i"]) + def test_dockerfiles(self, dockerfile): + """ + Test if we are able to build a container from + `examples/from-dockerfile//{Dockerfile,Dockerfile.s2i} + """ + assert self.app.build_test_container( + dockerfile=VARS.TEST_DIR / "examples/from-dockerfile" / dockerfile, + app_url="https://github.com/sclorg/nodejs-ex.git", + app_dir="app-src", + build_args="--ulimit nofile=4096:4096", + ) + assert self.app.test_app_dockerfile() + cip = self.app.get_cip() + assert cip + assert self.app.test_response( + url=cip, expected_output="Node.js Crud Application" + ) + + +class TestNodeJSFipsContainer: + """ + Test NodeJS FIPS mode of a NodeJS application. + """ + + def setup_method(self): + """ + Setup the test environment. + """ + self.s2i_fips = build_s2i_app(test_fips) + + def teardown_method(self): + """ + Cleanup the test environment. + """ + self.s2i_fips.cleanup() + + def test_nodejs_fips_mode(self): + """ + Test NodeJS FIPS mode of a NodeJS application. + """ + skip_for_minimal() + if VARS.OS == "rhel8": + pytest.skip("Do not execute on RHEL8") + is_fips_enabled = 0 + fips_enabled_file = Path("/proc/sys/crypto/fips_enabled") + if fips_enabled_file.exists(): + is_fips_enabled = int(get_file_content(fips_enabled_file)) + if is_fips_enabled == 1: + fips_result = PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_fips.app_name}", + cmd="node test.js", + return_output=False, + ) + assert fips_result == 1 + else: + fips_mode = PodmanCLIWrapper.podman_run_command_and_remove( + cid_file_name=f"{VARS.IMAGE_NAME}-{self.s2i_fips.app_name}", + cmd="node test.js", + return_output=False, + ) + assert fips_mode == 0 + + def test_run_fips_app_application(self): + """ + Test NodeJS FIPS mode of a NodeJS application. + """ + skip_for_minimal() + is_fips_enabled = 0 + fips_enabled_file = Path("/proc/sys/crypto/fips_enabled") + if fips_enabled_file.exists(): + is_fips_enabled = int(get_file_content(fips_enabled_file)) + if is_fips_enabled == 1: + assert self.s2i_fips.create_container( + cid_file_name=self.s2i_fips.app_name, container_args="--user 100001" + ) + assert self.s2i_fips.get_cid(cid_file_name=self.s2i_fips.app_name) diff --git a/test/test_nodejs_s2i_standalone.py b/test/test_nodejs_s2i_standalone.py deleted file mode 100644 index 136ea65b..00000000 --- a/test/test_nodejs_s2i_standalone.py +++ /dev/null @@ -1,36 +0,0 @@ -import os -import sys - -import pytest - -from container_ci_suite.utils import check_variables -from container_ci_suite.openshift import OpenShiftAPI - -if not check_variables(): - print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") - sys.exit(1) - - -VERSION = os.getenv("VERSION").replace("-minimal", "") -IMAGE_NAME = os.getenv("IMAGE_NAME") -OS = os.getenv("TARGET") - -class TestNodeJSExTemplate: - - def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix=f"nodejs-{VERSION}-testing", version=VERSION) - - def teardown_method(self): - self.oc_api.delete_project() - - def test_nodejs_ex_template_inside_cluster(self): - service_name = f"nodejs-{VERSION}-testing" - assert self.oc_api.deploy_s2i_app( - image_name=IMAGE_NAME, app=f"https://github.com/sclorg/s2i-nodejs-container.git", - context="test/test-app", - service_name=service_name - ) - assert self.oc_api.is_template_deployed(name_in_template=service_name) - assert self.oc_api.check_response_inside_cluster( - name_in_template=service_name, expected_output="This is a node.js echo service" - ) diff --git a/test/test_imagestreams_quickstart.py b/test/test_ocp_imagestreams_quickstart.py similarity index 56% rename from test/test_imagestreams_quickstart.py rename to test/test_ocp_imagestreams_quickstart.py index 84a3109e..8ca9c104 100644 --- a/test/test_imagestreams_quickstart.py +++ b/test/test_ocp_imagestreams_quickstart.py @@ -1,35 +1,18 @@ -import os -import sys - import pytest from container_ci_suite.openshift import OpenShiftAPI -from container_ci_suite.utils import check_variables - -from constants import TAGS - -if not check_variables(): - print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") - sys.exit(1) - - -VERSION = os.getenv("VERSION").replace("-minimal", "") -IMAGE_NAME = os.getenv("IMAGE_NAME") -OS = os.getenv("OS") - -DEPLOYED_PGSQL_IMAGE = "quay.io/sclorg/postgresql-15-c9s" - -TAG = TAGS.get(OS) -PGSQL_IMAGE_TAG = f"postgresql:15-c9s" -IMAGE_TAG = f"15-c9s" +from conftest import VARS # Replacement with 'test_python_s2i_templates' class TestImagestreamsQuickstart: - def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix=f"nodejs-{VERSION}-example", version=VERSION, shared_cluster=True) + self.oc_api = OpenShiftAPI( + pod_name_prefix=f"nodejs-{VARS.VERSION_NO_MINIMAL}-example", + version=VARS.VERSION_NO_MINIMAL, + shared_cluster=True, + ) def teardown_method(self): self.oc_api.delete_project() @@ -39,40 +22,42 @@ def teardown_method(self): [ "nodejs.json", "nodejs-postgresql-persistent.json", - ] + ], ) def test_nodejs_template_inside_cluster(self, template): - assert self.oc_api.upload_image(DEPLOYED_PGSQL_IMAGE, PGSQL_IMAGE_TAG) - service_name = f"nodejs-{VERSION}-example" + assert self.oc_api.upload_image(VARS.DEPLOYED_PGSQL_IMAGE, VARS.PGSQL_IMAGE_TAG) + service_name = f"nodejs-{VARS.VERSION}-example" template_url = self.oc_api.get_raw_url_for_json( - container="nodejs-ex", dir="openshift/templates", filename=template, branch="master" + container="nodejs-ex", + dir="openshift/templates", + filename=template, + branch="master", ) openshift_args = [ "SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git", "SOURCE_REPOSITORY_REF=master", - f"NODEJS_VERSION={VERSION}", - f"NAME={service_name}" + f"NODEJS_VERSION={VARS.VERSION_NO_MINIMAL}", + f"NAME={service_name}", ] if template != "nodejs.json": openshift_args = [ "SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git", "SOURCE_REPOSITORY_REF=master", - f"POSTGRESQL_VERSION={IMAGE_TAG}", - f"NODEJS_VERSION={VERSION}", + f"POSTGRESQL_VERSION={VARS.IMAGE_TAG}", + f"NODEJS_VERSION={VARS.VERSION_NO_MINIMAL}", f"NAME={service_name}", "DATABASE_USER=testu", "DATABASE_PASSWORD=testpwd", - "DATABASE_ADMIN_PASSWORD=testadminpwd" + "DATABASE_ADMIN_PASSWORD=testadminpwd", ] assert self.oc_api.imagestream_quickstart( imagestream_file="imagestreams/nodejs-rhel.json", template_file=template_url, - image_name=IMAGE_NAME, + image_name=VARS.IMAGE_NAME, name_in_template="nodejs", - openshift_args=openshift_args + openshift_args=openshift_args, ) assert self.oc_api.is_template_deployed(name_in_template=service_name) assert self.oc_api.check_response_inside_cluster( name_in_template=service_name, expected_output="Node.js Crud Application" ) - diff --git a/test/test_latest_imagestreams.py b/test/test_ocp_latest_imagestreams.py similarity index 100% rename from test/test_latest_imagestreams.py rename to test/test_ocp_latest_imagestreams.py diff --git a/test/test_nodejs_ex_standalone.py b/test/test_ocp_nodejs_ex_standalone.py similarity index 50% rename from test/test_nodejs_ex_standalone.py rename to test/test_ocp_nodejs_ex_standalone.py index b2c0145d..e8361e91 100644 --- a/test/test_nodejs_ex_standalone.py +++ b/test/test_ocp_nodejs_ex_standalone.py @@ -1,33 +1,24 @@ -import os -import sys - -import pytest - -from container_ci_suite.utils import check_variables from container_ci_suite.openshift import OpenShiftAPI -if not check_variables(): - print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") - sys.exit(1) - - -VERSION = os.getenv("VERSION").replace("-minimal", "") -IMAGE_NAME = os.getenv("IMAGE_NAME") -OS = os.getenv("TARGET") +from conftest import VARS class TestNodeJSExTemplate: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix=f"nodejs-{VERSION}-testing", version=VERSION, shared_cluster=True) + self.oc_api = OpenShiftAPI( + pod_name_prefix=f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing", + version=VARS.VERSION_NO_MINIMAL, + shared_cluster=True + ) def teardown_method(self): self.oc_api.delete_project() def test_nodejs_ex_template_inside_cluster(self): - service_name = f"nodejs-{VERSION}-testing" + service_name = f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing" assert self.oc_api.deploy_s2i_app( - image_name=IMAGE_NAME, app=f"https://github.com/sclorg/nodejs-ex.git", + image_name=VARS.IMAGE_NAME, app="https://github.com/sclorg/nodejs-ex.git", context=".", service_name=service_name ) diff --git a/test/test_nodejs_ex_templates.py b/test/test_ocp_nodejs_ex_templates.py similarity index 53% rename from test/test_nodejs_ex_templates.py rename to test/test_ocp_nodejs_ex_templates.py index 01822890..74a0a1f8 100644 --- a/test/test_nodejs_ex_templates.py +++ b/test/test_ocp_nodejs_ex_templates.py @@ -1,33 +1,18 @@ -import os -import sys - import pytest -from container_ci_suite.openshift import OpenShiftAPI -from container_ci_suite.utils import check_variables - -from constants import TAGS - -if not check_variables(): - print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") - sys.exit(1) - - -VERSION = os.getenv("VERSION").replace("-minimal", "") -IMAGE_NAME = os.getenv("IMAGE_NAME") -OS = os.getenv("TARGET") -DEPLOYED_PGSQL_IMAGE = "quay.io/sclorg/postgresql-15-c9s" +from container_ci_suite.openshift import OpenShiftAPI -NODEJS_TAG = TAGS.get(OS) -PGSQL_IMAGE_NAME = f"postgresql:15-c9s" -IMAGE_TAG = f"15-c9s" +from conftest import VARS class TestDeployNodeJSExTemplate: - def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix=f"nodejs-{VERSION}-testing", version=VERSION, shared_cluster=True) + self.oc_api = OpenShiftAPI( + pod_name_prefix=f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing", + version=VARS.VERSION_NO_MINIMAL, + shared_cluster=True, + ) def teardown_method(self): self.oc_api.delete_project() @@ -37,37 +22,39 @@ def teardown_method(self): [ "nodejs.json", "nodejs-postgresql-persistent.json", - ] + ], ) def test_nodejs_ex_template_inside_cluster(self, template): - assert self.oc_api.upload_image(DEPLOYED_PGSQL_IMAGE, PGSQL_IMAGE_NAME) + assert self.oc_api.upload_image(VARS.DEPLOYED_PGSQL_IMAGE, VARS.PGSQL_IMAGE_TAG) template_url = self.oc_api.get_raw_url_for_json( - container="nodejs-ex", dir="openshift/templates", filename=template, branch="master" + container="nodejs-ex", + dir="openshift/templates", + filename=template, + branch="master", ) - service_name = f"nodejs-{VERSION}-testing" + service_name = f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing" openshift_args = [ "SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git", "SOURCE_REPOSITORY_REF=master", - f"NODEJS_VERSION={VERSION}", - f"NAME={service_name}" + f"NODEJS_VERSION={VARS.VERSION_NO_MINIMAL}", + f"NAME={service_name}", ] if template != "nodejs.json": openshift_args = [ "SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git", "SOURCE_REPOSITORY_REF=master", - f"POSTGRESQL_VERSION={IMAGE_TAG}", - f"NODEJS_VERSION={VERSION}", + f"POSTGRESQL_VERSION={VARS.IMAGE_TAG}", + f"NODEJS_VERSION={VARS.VERSION_NO_MINIMAL}", f"NAME={service_name}", "DATABASE_USER=testu", "DATABASE_PASSWORD=testpwd", - "DATABASE_ADMIN_PASSWORD=testadminpwd" + "DATABASE_ADMIN_PASSWORD=testadminpwd", ] assert self.oc_api.deploy_template_with_image( - image_name=IMAGE_NAME, + image_name=VARS.IMAGE_NAME, template=template_url, name_in_template="nodejs", - openshift_args=openshift_args - + openshift_args=openshift_args, ) assert self.oc_api.is_template_deployed(name_in_template=service_name) assert self.oc_api.check_response_inside_cluster( diff --git a/test/test_ocp_nodejs_s2i_standalone.py b/test/test_ocp_nodejs_s2i_standalone.py new file mode 100644 index 00000000..af4c8cd1 --- /dev/null +++ b/test/test_ocp_nodejs_s2i_standalone.py @@ -0,0 +1,28 @@ +from container_ci_suite.openshift import OpenShiftAPI + +from conftest import VARS + + +class TestNodeJSExTemplate: + def setup_method(self): + self.oc_api = OpenShiftAPI( + pod_name_prefix=f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing", + version=VARS.VERSION_NO_MINIMAL, + ) + + def teardown_method(self): + self.oc_api.delete_project() + + def test_nodejs_ex_template_inside_cluster(self): + service_name = f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing" + assert self.oc_api.deploy_s2i_app( + image_name=VARS.IMAGE_NAME, + app="https://github.com/sclorg/s2i-nodejs-container.git", + context="test/test-app", + service_name=service_name, + ) + assert self.oc_api.is_template_deployed(name_in_template=service_name) + assert self.oc_api.check_response_inside_cluster( + name_in_template=service_name, + expected_output="This is a node.js echo service", + ) diff --git a/test/test_shared_helm_nodejs_application.py b/test/test_ocp_shared_helm_nodejs_application.py similarity index 51% rename from test/test_shared_helm_nodejs_application.py rename to test/test_ocp_shared_helm_nodejs_application.py index a9a98dbb..ae20f8a1 100644 --- a/test/test_shared_helm_nodejs_application.py +++ b/test/test_ocp_shared_helm_nodejs_application.py @@ -1,36 +1,18 @@ -import os -import sys - -import pytest -from pathlib import Path - from container_ci_suite.helm import HelmChartsAPI -from container_ci_suite.utils import check_variables - -from constants import TAGS - -if not check_variables(): - print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") - sys.exit(1) -test_dir = Path(os.path.abspath(os.path.dirname(__file__))) - -VERSION = os.getenv("VERSION") -IMAGE_NAME = os.getenv("IMAGE_NAME") -OS = os.getenv("TARGET") - -TAG = TAGS.get(OS) +from conftest import VARS class TestHelmNodeJSApplication: - def setup_method(self): package_name = "redhat-nodejs-application" - path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) + self.hc_api = HelmChartsAPI( + path=VARS.TEST_DIR, package_name=package_name, tarball_dir=VARS.TEST_DIR + ) self.hc_api.clone_helm_chart_repo( - repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", - subdir="charts/redhat" + repo_url="https://github.com/sclorg/helm-charts", + repo_name="helm-charts", + subdir="charts/redhat", ) def teardown_method(self): @@ -44,8 +26,8 @@ def test_by_helm_test(self): assert self.hc_api.helm_package() assert self.hc_api.helm_installation( values={ - "nodejs": f"{VERSION}{TAG}", - "namespace": self.hc_api.namespace + "nodejs": f"{VARS.VERSION}{VARS.TAG}", + "namespace": self.hc_api.namespace, } ) assert self.hc_api.is_s2i_pod_running(pod_name_prefix="nodejs-example") diff --git a/test/test_ocp_shared_helm_nodejs_imagestreams.py b/test/test_ocp_shared_helm_nodejs_imagestreams.py new file mode 100644 index 00000000..2e1e5411 --- /dev/null +++ b/test/test_ocp_shared_helm_nodejs_imagestreams.py @@ -0,0 +1,70 @@ +import pytest + +from container_ci_suite.helm import HelmChartsAPI + +from conftest import VARS + + +class TestHelmRHELNodeJSImageStreams: + def setup_method(self): + package_name = "redhat-nodejs-imagestreams" + self.hc_api = HelmChartsAPI( + path=VARS.TEST_DIR, package_name=package_name, tarball_dir=VARS.TEST_DIR + ) + self.hc_api.clone_helm_chart_repo( + repo_url="https://github.com/sclorg/helm-charts", + repo_name="helm-charts", + subdir="charts/redhat", + ) + + def teardown_method(self): + self.hc_api.delete_project() + + @pytest.mark.parametrize( + "version,registry,expected", + [ + ("22-ubi10", "registry.redhat.io/ubi10/nodejs-22:latest", True), + ( + "22-ubi10-minimal", + "registry.redhat.io/ubi10/nodejs-22-minimal:latest", + True, + ), + ("22-ubi9", "registry.redhat.io/ubi9/nodejs-22:latest", True), + ( + "22-ubi9-minimal", + "registry.redhat.io/ubi9/nodejs-22-minimal:latest", + True, + ), + ("20-ubi9", "registry.redhat.io/ubi9/nodejs-20:latest", True), + ( + "20-ubi9-minimal", + "registry.redhat.io/ubi9/nodejs-20-minimal:latest", + True, + ), + ("20-ubi8", "registry.redhat.io/ubi8/nodejs-20:latest", True), + ( + "20-ubi8-minimal", + "registry.redhat.io/ubi8/nodejs-20-minimal:latest", + True, + ), + ("18-ubi9", "registry.redhat.io/ubi9/nodejs-18:latest", False), + ( + "18-ubi9-minimal", + "registry.redhat.io/ubi9/nodejs-18-minimal:latest", + False, + ), + ("18-ubi8", "registry.redhat.io/ubi8/nodejs-18:latest", False), + ( + "18-ubi8-minimal", + "registry.redhat.io/ubi8/nodejs-18-minimal:latest", + False, + ), + ], + ) + def test_package_imagestream(self, version, registry, expected): + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation() + assert ( + self.hc_api.check_imagestreams(version=version, registry=registry) + == expected + ) diff --git a/test/test_shared_helm_nodejs_imagestreams.py b/test/test_shared_helm_nodejs_imagestreams.py deleted file mode 100644 index 1c531e39..00000000 --- a/test/test_shared_helm_nodejs_imagestreams.py +++ /dev/null @@ -1,51 +0,0 @@ -import os -import sys - -import pytest -from pathlib import Path - -from container_ci_suite.helm import HelmChartsAPI -from container_ci_suite.utils import check_variables - -if not check_variables(): - print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") - sys.exit(1) - -test_dir = Path(os.path.abspath(os.path.dirname(__file__))) - - -class TestHelmRHELNodeJSImageStreams: - - def setup_method(self): - package_name = "redhat-nodejs-imagestreams" - path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) - self.hc_api.clone_helm_chart_repo( - repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", - subdir="charts/redhat" - ) - - def teardown_method(self): - self.hc_api.delete_project() - - @pytest.mark.parametrize( - "version,registry,expected", - [ - ("22-ubi10", "registry.redhat.io/ubi10/nodejs-22:latest", True), - ("22-ubi10-minimal", "registry.redhat.io/ubi10/nodejs-22-minimal:latest", True), - ("22-ubi9", "registry.redhat.io/ubi9/nodejs-22:latest", True), - ("22-ubi9-minimal", "registry.redhat.io/ubi9/nodejs-22-minimal:latest", True), - ("20-ubi9", "registry.redhat.io/ubi9/nodejs-20:latest", True), - ("20-ubi9-minimal", "registry.redhat.io/ubi9/nodejs-20-minimal:latest", True), - ("20-ubi8", "registry.redhat.io/ubi8/nodejs-20:latest", True), - ("20-ubi8-minimal", "registry.redhat.io/ubi8/nodejs-20-minimal:latest", True), - ("18-ubi9", "registry.redhat.io/ubi9/nodejs-18:latest", False), - ("18-ubi9-minimal", "registry.redhat.io/ubi9/nodejs-18-minimal:latest", False), - ("18-ubi8", "registry.redhat.io/ubi8/nodejs-18:latest", False), - ("18-ubi8-minimal", "registry.redhat.io/ubi8/nodejs-18-minimal:latest", False), - ], - ) - def test_package_imagestream(self, version, registry, expected): - assert self.hc_api.helm_package() - assert self.hc_api.helm_installation() - assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected