From 9ac5b4fe3b2f0030752f285acbc445e715314729 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Fri, 13 Sep 2024 09:09:16 +0200 Subject: [PATCH 1/2] Fix python testing for whole supported imagestreams Signed-off-by: Petr "Stone" Hracek --- .../src/templates/buildconfig.yaml | 10 ++--- .../src/values.schema.json | 2 +- tests/test_python_django_app.py | 38 ++++++++++++++++--- tests/test_python_django_psql_persistent.py | 38 ++++++++++++++++--- 4 files changed, 70 insertions(+), 18 deletions(-) diff --git a/charts/redhat/python-django-application/src/templates/buildconfig.yaml b/charts/redhat/python-django-application/src/templates/buildconfig.yaml index 8ce3946..7c27281 100644 --- a/charts/redhat/python-django-application/src/templates/buildconfig.yaml +++ b/charts/redhat/python-django-application/src/templates/buildconfig.yaml @@ -12,23 +12,23 @@ spec: output: to: kind: ImageStreamTag - name: {{ .Values.name }}:latest + name: "{{ .Values.name }}:latest" postCommit: script: ./manage.py test source: contextDir: {{ .Values.context_dir }} git: - ref: {{ .Values.source_repository_ref }} - uri: {{ .Values.source_repository_url }} + ref: "{{ .Values.source_repository_ref }}" + uri: "{{ .Values.source_repository_url }}" type: Git strategy: sourceStrategy: env: - name: PIP_INDEX_URL - value: {{ .Values.pip_index_url }} + value: "{{ .Values.pip_index_url }}" from: kind: ImageStreamTag - name: python:{{ .Values.python_version }} + name: "python:{{ .Values.python_version }}" namespace: {{ .Values.namespace }} type: Source triggers: diff --git a/charts/redhat/python-django-application/src/values.schema.json b/charts/redhat/python-django-application/src/values.schema.json index b06ac07..70efa61 100644 --- a/charts/redhat/python-django-application/src/values.schema.json +++ b/charts/redhat/python-django-application/src/values.schema.json @@ -21,7 +21,7 @@ "python_version": { "type": "string", "description": "Specify Python imagestream tag", - "enum": [ "latest", "2.7-ubi8", "3.6-ubi8", "3.8-ubi8", "3.8-ubi7", "3.9-ubi8", "3.9-ubi9", "3.11-ubi8", "3.11-ubi9" ] + "enum": [ "latest", "3.6-ubi8", "3.9-ubi8", "3.11-ubi8", "3.12-ubi8" ,"3.9-ubi9", "3.11-ubi9", "3.12-ubi9" ] }, "application_domain": { "type": "string", diff --git a/tests/test_python_django_app.py b/tests/test_python_django_app.py index 6c2e18a..b3e4efd 100644 --- a/tests/test_python_django_app.py +++ b/tests/test_python_django_app.py @@ -18,7 +18,19 @@ def setup_method(self): def teardown_method(self): self.hc_api.delete_project() - def test_django_application_curl_output(self): + @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" @@ -28,8 +40,9 @@ def test_django_application_curl_output(self): self.hc_api.helm_package() assert self.hc_api.helm_installation( values={ - "python_version": "3.11-ubi8", - "namespace": self.hc_api.namespace + "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") @@ -38,7 +51,19 @@ def test_django_application_curl_output(self): expected_str="Welcome to your Django application" ) - def test_django_application_helm_test(self): + @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" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() @@ -46,8 +71,9 @@ def test_django_application_helm_test(self): assert self.hc_api.helm_package() assert self.hc_api.helm_installation( values={ - "python_version": "3.11-ubi8", - "namespace": self.hc_api.namespace + "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") diff --git a/tests/test_python_django_psql_persistent.py b/tests/test_python_django_psql_persistent.py index ffb905d..626e5ff 100644 --- a/tests/test_python_django_psql_persistent.py +++ b/tests/test_python_django_psql_persistent.py @@ -18,7 +18,19 @@ def setup_method(self): def teardown_method(self): self.hc_api.delete_project() - def test_django_psql_curl_output(self): + @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" @@ -31,8 +43,9 @@ def test_django_psql_curl_output(self): assert self.hc_api.helm_package() assert self.hc_api.helm_installation( values={ - "python_version": "3.11-ubi8", - "namespace": self.hc_api.namespace + "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") @@ -41,7 +54,19 @@ def test_django_psql_curl_output(self): expected_str="Welcome to your Django application" ) - def test_django_psql_helm_test(self): + @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" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() @@ -52,8 +77,9 @@ def test_django_psql_helm_test(self): assert self.hc_api.helm_package() assert self.hc_api.helm_installation( values={ - "python_version": "3.11-ubi8", - "namespace": self.hc_api.namespace + "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") From 0ec1358dfdca7e8b8c012175988c546e38221fd2 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Fri, 13 Sep 2024 11:12:34 +0200 Subject: [PATCH 2/2] Fix DJango psql-persisten helm chart Signed-off-by: Petr "Stone" Hracek --- charts/redhat/django-psql-persistent/src/values.schema.json | 2 +- charts/redhat/python-django-application/src/values.schema.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/redhat/django-psql-persistent/src/values.schema.json b/charts/redhat/django-psql-persistent/src/values.schema.json index c80e5b8..5b8dc6e 100644 --- a/charts/redhat/django-psql-persistent/src/values.schema.json +++ b/charts/redhat/django-psql-persistent/src/values.schema.json @@ -21,7 +21,7 @@ "python_version": { "type": "string", "description": "Specify Python imagestream tag", - "enum": [ "latest", "2.7-ubi8", "3.6-ubi8", "3.8-ubi8", "3.8-ubi7", "3.9-ubi8", "3.9-ubi9", "3.11-ubi8", "3.11-ubi9" ] + "enum": [ "latest", "3.6-ubi8", "3.9-ubi8", "3.11-ubi8", "3.12-ubi8", "3.9-ubi9", "3.11-ubi9", "3.12-ubi9" ] }, "application_domain": { "type": "string", diff --git a/charts/redhat/python-django-application/src/values.schema.json b/charts/redhat/python-django-application/src/values.schema.json index 70efa61..04bc540 100644 --- a/charts/redhat/python-django-application/src/values.schema.json +++ b/charts/redhat/python-django-application/src/values.schema.json @@ -21,7 +21,7 @@ "python_version": { "type": "string", "description": "Specify Python imagestream tag", - "enum": [ "latest", "3.6-ubi8", "3.9-ubi8", "3.11-ubi8", "3.12-ubi8" ,"3.9-ubi9", "3.11-ubi9", "3.12-ubi9" ] + "enum": [ "latest", "3.6-ubi8", "3.9-ubi8", "3.11-ubi8", "3.12-ubi8", "3.9-ubi9", "3.11-ubi9", "3.12-ubi9" ] }, "application_domain": { "type": "string",