From 68ae52d2a277795dfab0522b6e3f9065b970c69b Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Fri, 16 May 2025 10:11:40 +0200 Subject: [PATCH 1/3] Add PyTest testing files into all version Signed-off-by: Petr "Stone" Hracek --- manifest-minimal.yml | 30 ++++++++++++++++++++++++++++++ manifest.yml | 6 ++++++ test/__init__.py | 0 test/constants.py | 7 +++++++ 4 files changed, 43 insertions(+) create mode 100644 test/__init__.py create mode 100644 test/constants.py diff --git a/manifest-minimal.yml b/manifest-minimal.yml index 4e00d316..50b37578 100644 --- a/manifest-minimal.yml +++ b/manifest-minimal.yml @@ -183,6 +183,36 @@ SYMLINK_RULES: - src: ../../test/run-openshift-remote-cluster dest: test/run-openshift-remote-cluster + - src: ../../test/run-openshift-pytest + dest: test/run-openshift-pytest + + - src: ../../test/test_deploy_templates.py + dest: test/test_deploy_templates.py + + - src: ../../test/test_imagestreams_quickstart.py + dest: test/test_imagestreams_quickstart.py + + - src: ../../test/test_python_ex_standalone.py + dest: test/test_python_ex_standalone.py + + - src: ../../test/test_python_ex_template.py + dest: test/test_python_ex_template.py + + - src: ../../test/test_helm_python_django_app.py + dest: test/test_helm_python_django_app.py + + - src: ../../test/test_helm_python_django_psql_persistent.py + dest: test/test_helm_python_django_psql_persistent.py + + - src: ../../test/test_helm_python_imagestreams.py + dest: test/test_helm_python_imagestreams.py + + - src: ../../test/constants.py + dest: test/constants.py + + - src: ../../test/__init__.py + dest: test/__init__.py + - src: ../../common/test-lib.sh dest: test/test-lib.sh diff --git a/manifest.yml b/manifest.yml index 3be3ef67..f3680f39 100644 --- a/manifest.yml +++ b/manifest.yml @@ -206,6 +206,12 @@ SYMLINK_RULES: - src: ../../test/test_helm_python_imagestreams.py dest: test/test_helm_python_imagestreams.py + - src: ../../test/constants.py + dest: test/constants.py + + - src: ../../test/__init__.py + dest: test/__init__.py + - src: ../../common/test-lib.sh dest: test/test-lib.sh diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/constants.py b/test/constants.py new file mode 100644 index 00000000..d500364a --- /dev/null +++ b/test/constants.py @@ -0,0 +1,7 @@ +TAGS = { + "rhel8": "-ubi8", + "rhel9": "-ubi9", + "rhel10": "-ubi10", +} + +BRANCH_TO_TEST = "master" From 2d8fe12fc6742e976d91eb33c93a218b54d3abc8 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Fri, 16 May 2025 10:13:30 +0200 Subject: [PATCH 2/3] Add dist-gen generated files Signed-off-by: Petr "Stone" Hracek --- 3.11-minimal/test/__init__.py | 1 + 3.11-minimal/test/constants.py | 1 + 3.11-minimal/test/run-openshift-pytest | 1 + 3.11-minimal/test/test_deploy_templates.py | 1 + 3.11-minimal/test/test_helm_python_django_app.py | 1 + 3.11-minimal/test/test_helm_python_django_psql_persistent.py | 1 + 3.11-minimal/test/test_helm_python_imagestreams.py | 1 + 3.11-minimal/test/test_imagestreams_quickstart.py | 1 + 3.11-minimal/test/test_python_ex_standalone.py | 1 + 3.11-minimal/test/test_python_ex_template.py | 1 + 3.11/test/__init__.py | 1 + 3.11/test/constants.py | 1 + 3.12-minimal/test/__init__.py | 1 + 3.12-minimal/test/constants.py | 1 + 3.12-minimal/test/run-openshift-pytest | 1 + 3.12-minimal/test/test_deploy_templates.py | 1 + 3.12-minimal/test/test_helm_python_django_app.py | 1 + 3.12-minimal/test/test_helm_python_django_psql_persistent.py | 1 + 3.12-minimal/test/test_helm_python_imagestreams.py | 1 + 3.12-minimal/test/test_imagestreams_quickstart.py | 1 + 3.12-minimal/test/test_python_ex_standalone.py | 1 + 3.12-minimal/test/test_python_ex_template.py | 1 + 3.12/test/__init__.py | 1 + 3.12/test/constants.py | 1 + 3.13/test/__init__.py | 1 + 3.13/test/constants.py | 1 + 3.6/test/__init__.py | 1 + 3.6/test/constants.py | 1 + 3.9-minimal/test/__init__.py | 1 + 3.9-minimal/test/constants.py | 1 + 3.9-minimal/test/run-openshift-pytest | 1 + 3.9-minimal/test/test_deploy_templates.py | 1 + 3.9-minimal/test/test_helm_python_django_app.py | 1 + 3.9-minimal/test/test_helm_python_django_psql_persistent.py | 1 + 3.9-minimal/test/test_helm_python_imagestreams.py | 1 + 3.9-minimal/test/test_imagestreams_quickstart.py | 1 + 3.9-minimal/test/test_python_ex_standalone.py | 1 + 3.9-minimal/test/test_python_ex_template.py | 1 + 3.9/test/__init__.py | 1 + 3.9/test/constants.py | 1 + 40 files changed, 40 insertions(+) create mode 120000 3.11-minimal/test/__init__.py create mode 120000 3.11-minimal/test/constants.py create mode 120000 3.11-minimal/test/run-openshift-pytest create mode 120000 3.11-minimal/test/test_deploy_templates.py create mode 120000 3.11-minimal/test/test_helm_python_django_app.py create mode 120000 3.11-minimal/test/test_helm_python_django_psql_persistent.py create mode 120000 3.11-minimal/test/test_helm_python_imagestreams.py create mode 120000 3.11-minimal/test/test_imagestreams_quickstart.py create mode 120000 3.11-minimal/test/test_python_ex_standalone.py create mode 120000 3.11-minimal/test/test_python_ex_template.py create mode 120000 3.11/test/__init__.py create mode 120000 3.11/test/constants.py create mode 120000 3.12-minimal/test/__init__.py create mode 120000 3.12-minimal/test/constants.py create mode 120000 3.12-minimal/test/run-openshift-pytest create mode 120000 3.12-minimal/test/test_deploy_templates.py create mode 120000 3.12-minimal/test/test_helm_python_django_app.py create mode 120000 3.12-minimal/test/test_helm_python_django_psql_persistent.py create mode 120000 3.12-minimal/test/test_helm_python_imagestreams.py create mode 120000 3.12-minimal/test/test_imagestreams_quickstart.py create mode 120000 3.12-minimal/test/test_python_ex_standalone.py create mode 120000 3.12-minimal/test/test_python_ex_template.py create mode 120000 3.12/test/__init__.py create mode 120000 3.12/test/constants.py create mode 120000 3.13/test/__init__.py create mode 120000 3.13/test/constants.py create mode 120000 3.6/test/__init__.py create mode 120000 3.6/test/constants.py create mode 120000 3.9-minimal/test/__init__.py create mode 120000 3.9-minimal/test/constants.py create mode 120000 3.9-minimal/test/run-openshift-pytest create mode 120000 3.9-minimal/test/test_deploy_templates.py create mode 120000 3.9-minimal/test/test_helm_python_django_app.py create mode 120000 3.9-minimal/test/test_helm_python_django_psql_persistent.py create mode 120000 3.9-minimal/test/test_helm_python_imagestreams.py create mode 120000 3.9-minimal/test/test_imagestreams_quickstart.py create mode 120000 3.9-minimal/test/test_python_ex_standalone.py create mode 120000 3.9-minimal/test/test_python_ex_template.py create mode 120000 3.9/test/__init__.py create mode 120000 3.9/test/constants.py diff --git a/3.11-minimal/test/__init__.py b/3.11-minimal/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/3.11-minimal/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/3.11-minimal/test/constants.py b/3.11-minimal/test/constants.py new file mode 120000 index 00000000..360f725b --- /dev/null +++ b/3.11-minimal/test/constants.py @@ -0,0 +1 @@ +../../test/constants.py \ No newline at end of file diff --git a/3.11-minimal/test/run-openshift-pytest b/3.11-minimal/test/run-openshift-pytest new file mode 120000 index 00000000..5063ae30 --- /dev/null +++ b/3.11-minimal/test/run-openshift-pytest @@ -0,0 +1 @@ +../../test/run-openshift-pytest \ No newline at end of file diff --git a/3.11-minimal/test/test_deploy_templates.py b/3.11-minimal/test/test_deploy_templates.py new file mode 120000 index 00000000..2b15b63f --- /dev/null +++ b/3.11-minimal/test/test_deploy_templates.py @@ -0,0 +1 @@ +../../test/test_deploy_templates.py \ No newline at end of file diff --git a/3.11-minimal/test/test_helm_python_django_app.py b/3.11-minimal/test/test_helm_python_django_app.py new file mode 120000 index 00000000..46a601b1 --- /dev/null +++ b/3.11-minimal/test/test_helm_python_django_app.py @@ -0,0 +1 @@ +../../test/test_helm_python_django_app.py \ No newline at end of file diff --git a/3.11-minimal/test/test_helm_python_django_psql_persistent.py b/3.11-minimal/test/test_helm_python_django_psql_persistent.py new file mode 120000 index 00000000..0667c2f3 --- /dev/null +++ b/3.11-minimal/test/test_helm_python_django_psql_persistent.py @@ -0,0 +1 @@ +../../test/test_helm_python_django_psql_persistent.py \ No newline at end of file diff --git a/3.11-minimal/test/test_helm_python_imagestreams.py b/3.11-minimal/test/test_helm_python_imagestreams.py new file mode 120000 index 00000000..7be14462 --- /dev/null +++ b/3.11-minimal/test/test_helm_python_imagestreams.py @@ -0,0 +1 @@ +../../test/test_helm_python_imagestreams.py \ No newline at end of file diff --git a/3.11-minimal/test/test_imagestreams_quickstart.py b/3.11-minimal/test/test_imagestreams_quickstart.py new file mode 120000 index 00000000..c238e8c7 --- /dev/null +++ b/3.11-minimal/test/test_imagestreams_quickstart.py @@ -0,0 +1 @@ +../../test/test_imagestreams_quickstart.py \ No newline at end of file diff --git a/3.11-minimal/test/test_python_ex_standalone.py b/3.11-minimal/test/test_python_ex_standalone.py new file mode 120000 index 00000000..504a43a3 --- /dev/null +++ b/3.11-minimal/test/test_python_ex_standalone.py @@ -0,0 +1 @@ +../../test/test_python_ex_standalone.py \ No newline at end of file diff --git a/3.11-minimal/test/test_python_ex_template.py b/3.11-minimal/test/test_python_ex_template.py new file mode 120000 index 00000000..14f15e03 --- /dev/null +++ b/3.11-minimal/test/test_python_ex_template.py @@ -0,0 +1 @@ +../../test/test_python_ex_template.py \ No newline at end of file diff --git a/3.11/test/__init__.py b/3.11/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/3.11/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/3.11/test/constants.py b/3.11/test/constants.py new file mode 120000 index 00000000..360f725b --- /dev/null +++ b/3.11/test/constants.py @@ -0,0 +1 @@ +../../test/constants.py \ No newline at end of file diff --git a/3.12-minimal/test/__init__.py b/3.12-minimal/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/3.12-minimal/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/3.12-minimal/test/constants.py b/3.12-minimal/test/constants.py new file mode 120000 index 00000000..360f725b --- /dev/null +++ b/3.12-minimal/test/constants.py @@ -0,0 +1 @@ +../../test/constants.py \ No newline at end of file diff --git a/3.12-minimal/test/run-openshift-pytest b/3.12-minimal/test/run-openshift-pytest new file mode 120000 index 00000000..5063ae30 --- /dev/null +++ b/3.12-minimal/test/run-openshift-pytest @@ -0,0 +1 @@ +../../test/run-openshift-pytest \ No newline at end of file diff --git a/3.12-minimal/test/test_deploy_templates.py b/3.12-minimal/test/test_deploy_templates.py new file mode 120000 index 00000000..2b15b63f --- /dev/null +++ b/3.12-minimal/test/test_deploy_templates.py @@ -0,0 +1 @@ +../../test/test_deploy_templates.py \ No newline at end of file diff --git a/3.12-minimal/test/test_helm_python_django_app.py b/3.12-minimal/test/test_helm_python_django_app.py new file mode 120000 index 00000000..46a601b1 --- /dev/null +++ b/3.12-minimal/test/test_helm_python_django_app.py @@ -0,0 +1 @@ +../../test/test_helm_python_django_app.py \ No newline at end of file diff --git a/3.12-minimal/test/test_helm_python_django_psql_persistent.py b/3.12-minimal/test/test_helm_python_django_psql_persistent.py new file mode 120000 index 00000000..0667c2f3 --- /dev/null +++ b/3.12-minimal/test/test_helm_python_django_psql_persistent.py @@ -0,0 +1 @@ +../../test/test_helm_python_django_psql_persistent.py \ No newline at end of file diff --git a/3.12-minimal/test/test_helm_python_imagestreams.py b/3.12-minimal/test/test_helm_python_imagestreams.py new file mode 120000 index 00000000..7be14462 --- /dev/null +++ b/3.12-minimal/test/test_helm_python_imagestreams.py @@ -0,0 +1 @@ +../../test/test_helm_python_imagestreams.py \ No newline at end of file diff --git a/3.12-minimal/test/test_imagestreams_quickstart.py b/3.12-minimal/test/test_imagestreams_quickstart.py new file mode 120000 index 00000000..c238e8c7 --- /dev/null +++ b/3.12-minimal/test/test_imagestreams_quickstart.py @@ -0,0 +1 @@ +../../test/test_imagestreams_quickstart.py \ No newline at end of file diff --git a/3.12-minimal/test/test_python_ex_standalone.py b/3.12-minimal/test/test_python_ex_standalone.py new file mode 120000 index 00000000..504a43a3 --- /dev/null +++ b/3.12-minimal/test/test_python_ex_standalone.py @@ -0,0 +1 @@ +../../test/test_python_ex_standalone.py \ No newline at end of file diff --git a/3.12-minimal/test/test_python_ex_template.py b/3.12-minimal/test/test_python_ex_template.py new file mode 120000 index 00000000..14f15e03 --- /dev/null +++ b/3.12-minimal/test/test_python_ex_template.py @@ -0,0 +1 @@ +../../test/test_python_ex_template.py \ No newline at end of file diff --git a/3.12/test/__init__.py b/3.12/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/3.12/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/3.12/test/constants.py b/3.12/test/constants.py new file mode 120000 index 00000000..360f725b --- /dev/null +++ b/3.12/test/constants.py @@ -0,0 +1 @@ +../../test/constants.py \ No newline at end of file diff --git a/3.13/test/__init__.py b/3.13/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/3.13/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/3.13/test/constants.py b/3.13/test/constants.py new file mode 120000 index 00000000..360f725b --- /dev/null +++ b/3.13/test/constants.py @@ -0,0 +1 @@ +../../test/constants.py \ No newline at end of file diff --git a/3.6/test/__init__.py b/3.6/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/3.6/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/3.6/test/constants.py b/3.6/test/constants.py new file mode 120000 index 00000000..360f725b --- /dev/null +++ b/3.6/test/constants.py @@ -0,0 +1 @@ +../../test/constants.py \ No newline at end of file diff --git a/3.9-minimal/test/__init__.py b/3.9-minimal/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/3.9-minimal/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/3.9-minimal/test/constants.py b/3.9-minimal/test/constants.py new file mode 120000 index 00000000..360f725b --- /dev/null +++ b/3.9-minimal/test/constants.py @@ -0,0 +1 @@ +../../test/constants.py \ No newline at end of file diff --git a/3.9-minimal/test/run-openshift-pytest b/3.9-minimal/test/run-openshift-pytest new file mode 120000 index 00000000..5063ae30 --- /dev/null +++ b/3.9-minimal/test/run-openshift-pytest @@ -0,0 +1 @@ +../../test/run-openshift-pytest \ No newline at end of file diff --git a/3.9-minimal/test/test_deploy_templates.py b/3.9-minimal/test/test_deploy_templates.py new file mode 120000 index 00000000..2b15b63f --- /dev/null +++ b/3.9-minimal/test/test_deploy_templates.py @@ -0,0 +1 @@ +../../test/test_deploy_templates.py \ No newline at end of file diff --git a/3.9-minimal/test/test_helm_python_django_app.py b/3.9-minimal/test/test_helm_python_django_app.py new file mode 120000 index 00000000..46a601b1 --- /dev/null +++ b/3.9-minimal/test/test_helm_python_django_app.py @@ -0,0 +1 @@ +../../test/test_helm_python_django_app.py \ No newline at end of file diff --git a/3.9-minimal/test/test_helm_python_django_psql_persistent.py b/3.9-minimal/test/test_helm_python_django_psql_persistent.py new file mode 120000 index 00000000..0667c2f3 --- /dev/null +++ b/3.9-minimal/test/test_helm_python_django_psql_persistent.py @@ -0,0 +1 @@ +../../test/test_helm_python_django_psql_persistent.py \ No newline at end of file diff --git a/3.9-minimal/test/test_helm_python_imagestreams.py b/3.9-minimal/test/test_helm_python_imagestreams.py new file mode 120000 index 00000000..7be14462 --- /dev/null +++ b/3.9-minimal/test/test_helm_python_imagestreams.py @@ -0,0 +1 @@ +../../test/test_helm_python_imagestreams.py \ No newline at end of file diff --git a/3.9-minimal/test/test_imagestreams_quickstart.py b/3.9-minimal/test/test_imagestreams_quickstart.py new file mode 120000 index 00000000..c238e8c7 --- /dev/null +++ b/3.9-minimal/test/test_imagestreams_quickstart.py @@ -0,0 +1 @@ +../../test/test_imagestreams_quickstart.py \ No newline at end of file diff --git a/3.9-minimal/test/test_python_ex_standalone.py b/3.9-minimal/test/test_python_ex_standalone.py new file mode 120000 index 00000000..504a43a3 --- /dev/null +++ b/3.9-minimal/test/test_python_ex_standalone.py @@ -0,0 +1 @@ +../../test/test_python_ex_standalone.py \ No newline at end of file diff --git a/3.9-minimal/test/test_python_ex_template.py b/3.9-minimal/test/test_python_ex_template.py new file mode 120000 index 00000000..14f15e03 --- /dev/null +++ b/3.9-minimal/test/test_python_ex_template.py @@ -0,0 +1 @@ +../../test/test_python_ex_template.py \ No newline at end of file diff --git a/3.9/test/__init__.py b/3.9/test/__init__.py new file mode 120000 index 00000000..d0f4746a --- /dev/null +++ b/3.9/test/__init__.py @@ -0,0 +1 @@ +../../test/__init__.py \ No newline at end of file diff --git a/3.9/test/constants.py b/3.9/test/constants.py new file mode 120000 index 00000000..360f725b --- /dev/null +++ b/3.9/test/constants.py @@ -0,0 +1 @@ +../../test/constants.py \ No newline at end of file From cd486ad192fb9fe4ac1bfa44cea3a85a4dbc13c9 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Fri, 16 May 2025 10:14:06 +0200 Subject: [PATCH 3/3] Allow testing Python container on Shared Cluster. Replace function `template_deployed` -> `is_template_deployed` Do not use 'curl' test for HelmCharts. It does not make sense Remove deduplicate function into alone python file Signed-off-by: Petr "Stone" Hracek --- test/test_deploy_templates.py | 13 +-- test/test_helm_python_django_app.py | 79 +++++++------------ ...test_helm_python_django_psql_persistent.py | 79 ++++++------------- test/test_helm_python_imagestreams.py | 4 +- test/test_imagestreams_quickstart.py | 25 +++--- test/test_python_ex_standalone.py | 9 ++- test/test_python_ex_template.py | 15 ++-- 7 files changed, 86 insertions(+), 138 deletions(-) diff --git a/test/test_deploy_templates.py b/test/test_deploy_templates.py index 7c01018a..6fdf643a 100644 --- a/test/test_deploy_templates.py +++ b/test/test_deploy_templates.py @@ -14,7 +14,7 @@ VERSION = os.getenv("VERSION") IMAGE_NAME = os.getenv("IMAGE_NAME") -OS = os.getenv("TARGET") +OS = os.getenv("TARGET").lower() BRANCH_TO_TEST = "2.2.x" @@ -27,14 +27,14 @@ DEPLOYED_PSQL_IMAGE = "quay.io/sclorg/postgresql-12-c8s" IMAGE_TAG = "postgresql:12" PSQL_VERSION = "12" +SHORT_VERSION = VERSION.replace(".", "") # Replacement with 'test_python_s2i_templates' class TestDeployTemplate: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="python-testing", version=VERSION) - assert self.oc_api.upload_image(DEPLOYED_PSQL_IMAGE, IMAGE_TAG) + self.oc_api = OpenShiftAPI(pod_name_prefix=f"python-{SHORT_VERSION}-test", version=VERSION, shared_cluster=True) def teardown_method(self): self.oc_api.delete_project() @@ -47,7 +47,10 @@ def teardown_method(self): ] ) def test_python_template_inside_cluster(self, template): - service_name = "python-testing" + if OS == "rhel10": + pytest.skip("Do NOT test on rhel10. It is not released yet.") + assert self.oc_api.upload_image(DEPLOYED_PSQL_IMAGE, IMAGE_TAG) + service_name = f"python-{SHORT_VERSION}-test" template_url = self.oc_api.get_raw_url_for_json( container="django-ex", dir="openshift/templates", filename=template, branch=BRANCH_TO_TEST ) @@ -62,7 +65,7 @@ def test_python_template_inside_cluster(self, template): f"POSTGRESQL_VERSION={PSQL_VERSION}" ] ) - assert self.oc_api.template_deployed(name_in_template=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="Welcome to your Django application on OpenShift" ) diff --git a/test/test_helm_python_django_app.py b/test/test_helm_python_django_app.py index 87ab1ac4..09bba4bc 100644 --- a/test/test_helm_python_django_app.py +++ b/test/test_helm_python_django_app.py @@ -5,15 +5,30 @@ from container_ci_suite.helm import HelmChartsAPI +from constants import TAGS, BRANCH_TO_TEST test_dir = Path(os.path.abspath(os.path.dirname(__file__))) +VERSION = os.getenv("VERSION") +IMAGE_NAME = os.getenv("IMAGE_NAME") +OS = os.getenv("TARGET").lower() + +TAG = TAGS.get(OS) +DEPLOYED_PSQL_IMAGE = "quay.io/centos7/postgresql-10-centos7:centos7" +IMAGE_TAG = "postgresql:10" +PSQL_VERSION = "10" + +if VERSION == "3.11" or VERSION == "3.12": + DEPLOYED_PSQL_IMAGE = "quay.io/sclorg/postgresql-12-c8s" + IMAGE_TAG = "postgresql:12" + PSQL_VERSION = "12" + BRANCH_TO_TEST = "4.2.x" class TestHelmPythonDjangoAppTemplate: def setup_method(self): - package_name = "python-django-application" + package_name = "redhat-python-django-application" path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True) + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" @@ -22,62 +37,22 @@ def setup_method(self): def teardown_method(self): self.hc_api.delete_project() - @pytest.mark.parametrize( - "version,branch", - [ - ("3.12-ubi9", "4.2.x"), - ("3.12-ubi8", "4.2.x"), - ("3.11-ubi9", "4.2.x"), - ("3.11-ubi8", "4.2.x"), - ("3.9-ubi9", "master"), - ("3.9-ubi8", "master"), - ("3.6-ubi8", "master"), - ], - ) - def test_django_application_curl_output(self, version, branch): - if self.hc_api.oc_api.shared_cluster: - pytest.skip("Do NOT test on shared cluster") - self.hc_api.package_name = "python-imagestreams" - assert self.hc_api.helm_package() - assert self.hc_api.helm_installation() - self.hc_api.package_name = "python-django-application" - self.hc_api.helm_package() - assert self.hc_api.helm_installation( - values={ - "python_version": version, - "namespace": self.hc_api.namespace, - "source_repository_ref": branch, - } - ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-example") - assert self.hc_api.test_helm_curl_output( - route_name="django-example", - expected_str="Welcome to your Django application" - ) - - @pytest.mark.parametrize( - "version,branch", - [ - ("3.12-ubi9", "4.2.x"), - ("3.12-ubi8", "4.2.x"), - ("3.11-ubi9", "4.2.x"), - ("3.11-ubi8", "4.2.x"), - ("3.9-ubi9", "master"), - ("3.9-ubi8", "master"), - ("3.6-ubi8", "master"), - ], - ) - def test_django_application_helm_test(self, version, branch): - self.hc_api.package_name = "python-imagestreams" + def test_django_application_helm_test(self): + if OS == "rhel10": + pytest.skip("Do NOT test on rhel10. It is not released yet.") + new_version = VERSION + if "minimal" in VERSION: + new_version = VERSION.replace("-minimal", "") + self.hc_api.package_name = "redhat-python-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() - self.hc_api.package_name = "python-django-application" + self.hc_api.package_name = "redhat-python-django-application" assert self.hc_api.helm_package() assert self.hc_api.helm_installation( values={ - "python_version": version, + "python_version": f"{new_version}{TAG}", "namespace": self.hc_api.namespace, - "source_repository_ref": branch, + "source_repository_ref": BRANCH_TO_TEST, } ) assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-example") diff --git a/test/test_helm_python_django_psql_persistent.py b/test/test_helm_python_django_psql_persistent.py index 93814fc6..2f717a32 100644 --- a/test/test_helm_python_django_psql_persistent.py +++ b/test/test_helm_python_django_psql_persistent.py @@ -5,15 +5,25 @@ from container_ci_suite.helm import HelmChartsAPI +from constants import TAGS, BRANCH_TO_TEST + test_dir = Path(os.path.abspath(os.path.dirname(__file__))) +VERSION = os.getenv("VERSION") +IMAGE_NAME = os.getenv("IMAGE_NAME") +OS = os.getenv("TARGET").lower() + +TAG = TAGS.get(OS) +if VERSION == "3.11" or VERSION == "3.12": + BRANCH_TO_TEST = "4.2.x" + class TestHelmPythonDjangoPsqlTemplate: def setup_method(self): - package_name = "django-psql-persistent" + package_name = "redhat-django-psql-persistent" path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True) + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" @@ -22,68 +32,25 @@ def setup_method(self): def teardown_method(self): self.hc_api.delete_project() - @pytest.mark.parametrize( - "version,branch", - [ - ("3.12-ubi9", "4.2.x"), - ("3.12-ubi8", "4.2.x"), - ("3.11-ubi9", "4.2.x"), - ("3.11-ubi8", "4.2.x"), - ("3.9-ubi9", "master"), - ("3.9-ubi8", "master"), - ("3.6-ubi8", "master"), - ], - ) - def test_django_psql_curl_output(self, version, branch): - if self.hc_api.oc_api.shared_cluster: - pytest.skip("Do NOT test on shared cluster") - self.hc_api.package_name = "postgresql-imagestreams" - assert self.hc_api.helm_package() - assert self.hc_api.helm_installation() - self.hc_api.package_name = "python-imagestreams" - assert self.hc_api.helm_package() - assert self.hc_api.helm_installation() - self.hc_api.package_name = "django-psql-persistent" - assert self.hc_api.helm_package() - assert self.hc_api.helm_installation( - values={ - "python_version": version, - "namespace": self.hc_api.namespace, - "source_repository_ref": branch, - } - ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-psql") - assert self.hc_api.test_helm_curl_output( - route_name="django-psql", - expected_str="Welcome to your Django application" - ) - - @pytest.mark.parametrize( - "version,branch", - [ - ("3.12-ubi9", "4.2.x"), - ("3.12-ubi8", "4.2.x"), - ("3.11-ubi9", "4.2.x"), - ("3.11-ubi8", "4.2.x"), - ("3.9-ubi9", "master"), - ("3.9-ubi8", "master"), - ("3.6-ubi8", "master"), - ], - ) - def test_django_psql_helm_test(self, version, branch): - self.hc_api.package_name = "postgresql-imagestreams" + def test_django_psql_helm_test(self): + if OS == "rhel10": + pytest.skip("Do NOT test on rhel10. It is not released yet.") + new_version = VERSION + if "minimal" in VERSION: + new_version = VERSION.replace("-minimal", "") + self.hc_api.package_name = "redhat-postgresql-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() - self.hc_api.package_name = "python-imagestreams" + self.hc_api.package_name = "redhat-python-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() - self.hc_api.package_name = "django-psql-persistent" + self.hc_api.package_name = "redhat-django-psql-persistent" assert self.hc_api.helm_package() assert self.hc_api.helm_installation( values={ - "python_version": version, + "python_version": f"{new_version}{TAG}", "namespace": self.hc_api.namespace, - "source_repository_ref": branch, + "source_repository_ref": BRANCH_TO_TEST, } ) assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-psql") diff --git a/test/test_helm_python_imagestreams.py b/test/test_helm_python_imagestreams.py index b1358c41..05e34be4 100644 --- a/test/test_helm_python_imagestreams.py +++ b/test/test_helm_python_imagestreams.py @@ -11,9 +11,9 @@ class TestHelmRHELPythonImageStreams: def setup_method(self): - package_name = "python-imagestreams" + package_name = "redhat-python-imagestreams" path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True) + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" diff --git a/test/test_imagestreams_quickstart.py b/test/test_imagestreams_quickstart.py index 079b46c3..3a89ba98 100644 --- a/test/test_imagestreams_quickstart.py +++ b/test/test_imagestreams_quickstart.py @@ -7,6 +7,7 @@ from container_ci_suite.openshift import OpenShiftAPI from container_ci_suite.utils import check_variables +from constants import TAGS, BRANCH_TO_TEST if not check_variables(): print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") @@ -15,9 +16,8 @@ VERSION = os.getenv("VERSION") IMAGE_NAME = os.getenv("IMAGE_NAME") -OS = os.getenv("OS") +OS = os.getenv("TARGET").lower() -BRANCH_TO_TEST = "master" DEPLOYED_PSQL_IMAGE = "quay.io/centos7/postgresql-10-centos7:centos7" IMAGE_TAG = "postgresql:10" PSQL_VERSION = "10" @@ -28,21 +28,16 @@ IMAGE_TAG = "postgresql:12" PSQL_VERSION = "12" - -TAGS = { - "rhel8": "-ubi8", - "rhel9": "-ubi9" -} - TAG = TAGS.get(OS, None) +SHORT_VERSION = VERSION.replace(".", "") + # Replacement with 'test_python_s2i_templates' class TestImagestreamsQuickstart: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="python-testing", version=VERSION) - assert self.oc_api.upload_image(DEPLOYED_PSQL_IMAGE, IMAGE_TAG) + self.oc_api = OpenShiftAPI(pod_name_prefix=f"python-{SHORT_VERSION}-test", version=VERSION, shared_cluster=True) def teardown_method(self): self.oc_api.delete_project() @@ -55,7 +50,13 @@ def teardown_method(self): ] ) def test_python_template_inside_cluster(self, template): - service_name = "python-testing" + if OS == "rhel10": + pytest.skip("Do not test on RHEL10. Imagestreams are not ready yet.") + if self.oc_api.shared_cluster: + assert self.oc_api.upload_image_to_external_registry(DEPLOYED_PSQL_IMAGE, IMAGE_TAG) + else: + assert self.oc_api.upload_image(DEPLOYED_PSQL_IMAGE, IMAGE_TAG) + service_name = f"python-{SHORT_VERSION}-test" template_url = self.oc_api.get_raw_url_for_json( container="django-ex", dir="openshift/templates", filename=template, branch=BRANCH_TO_TEST ) @@ -80,7 +81,7 @@ def test_python_template_inside_cluster(self, template): name_in_template="python", openshift_args=openshift_args ) - assert self.oc_api.template_deployed(name_in_template=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="Welcome to your Django application on OpenShift" ) diff --git a/test/test_python_ex_standalone.py b/test/test_python_ex_standalone.py index c21f5d51..5b90c9fb 100644 --- a/test/test_python_ex_standalone.py +++ b/test/test_python_ex_standalone.py @@ -12,26 +12,27 @@ VERSION = os.getenv("VERSION") IMAGE_NAME = os.getenv("IMAGE_NAME") -OS = os.getenv("TARGET") +OS = os.getenv("TARGET").lower() +SHORT_VERSION = VERSION.replace(".", "") # Replacement with 'test_python_s2i_app_ex_standalone' class TestPythonExTemplate: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="python-testing", version=VERSION) + self.oc_api = OpenShiftAPI(pod_name_prefix=f"python-{SHORT_VERSION}-test", version=VERSION, shared_cluster=True) def teardown_method(self): self.oc_api.delete_project() def test_python_ex_template_inside_cluster(self): - service_name = "python-testing" + service_name = f"python-{SHORT_VERSION}-test" assert self.oc_api.deploy_s2i_app( image_name=IMAGE_NAME, app="https://github.com/sclorg/s2i-python-container.git", context="examples/standalone-test-app", service_name=service_name ) - assert self.oc_api.template_deployed(name_in_template=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="Hello World from standalone WSGI application!" ) diff --git a/test/test_python_ex_template.py b/test/test_python_ex_template.py index 68652d24..fd1bf8ab 100644 --- a/test/test_python_ex_template.py +++ b/test/test_python_ex_template.py @@ -14,31 +14,32 @@ VERSION = os.getenv("VERSION") IMAGE_NAME = os.getenv("IMAGE_NAME") -OS = os.getenv("TARGET") +OS = os.getenv("TARGET").lower() +BRANCH_TO_TEST = "2.2.x" if Version(VERSION) >= Version("3.11"): BRANCH_TO_TEST = "4.2.x" -else: - BRANCH_TO_TEST = "2.2.x" - +SHORT_VERSION = VERSION.replace(".", "") # Replacement with 'test_python_s2i_app_ex' class TestPythonExTemplate: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="python-testing", version=VERSION) + self.oc_api = OpenShiftAPI(pod_name_prefix=f"python-{SHORT_VERSION}-test", version=VERSION, shared_cluster=True) def teardown_method(self): self.oc_api.delete_project() def test_python_ex_template_inside_cluster(self): - service_name = "python-testing" + if OS == "rhel10": + pytest.skip("Do NOT test on rhel10. It is not released yet.") + service_name = f"python-{SHORT_VERSION}-test" assert self.oc_api.deploy_s2i_app( image_name=IMAGE_NAME, app=f"https://github.com/sclorg/django-ex.git#{BRANCH_TO_TEST}", context=".", service_name=service_name ) - assert self.oc_api.template_deployed(name_in_template=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="Welcome to your Django application on OpenShift" )