From 586e1343fd25ff3cdb4d8a98a075e2f31540811e Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 23 Jun 2025 10:16:29 +0200 Subject: [PATCH 1/3] Fix test suite and move ruby version to 3.3-ubi9 Signed-off-by: Petr "Stone" Hracek --- .github/workflows/openshift-tests.yml | 2 +- .../rails-postgresql-persistent.json | 4 +-- openshift/templates/rails-postgresql.json | 4 +-- openshift/templates/rails.json | 4 +-- tests/test_rails.py | 8 ++--- tests/test_rails_postgresql.py | 33 ++++++++++++------- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml index a18cdfe3..f97f17ce 100644 --- a/.github/workflows/openshift-tests.yml +++ b/.github/workflows/openshift-tests.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - version: [ "2.5-ubi8", "3.0-ubi9", "3.3-ubi8", "3.3-ubi9" ] + version: [ "2.5-ubi8", "3.0-ubi9", "3.3-ubi8", "3.3-ubi9", "3.3-ubi10" ] if: | github.event.issue.pull_request diff --git a/openshift/templates/rails-postgresql-persistent.json b/openshift/templates/rails-postgresql-persistent.json index 5631cfa2..8789b7fa 100644 --- a/openshift/templates/rails-postgresql-persistent.json +++ b/openshift/templates/rails-postgresql-persistent.json @@ -528,9 +528,9 @@ { "name": "RUBY_VERSION", "displayName": "Ruby Version", - "description": "Version of Ruby image to be used (3.3-ubi8 by default).", + "description": "Version of Ruby image to be used (3.3-ubi9 by default).", "required": true, - "value": "3.3-ubi8" + "value": "3.3-ubi9" }, { "name": "POSTGRESQL_VERSION", diff --git a/openshift/templates/rails-postgresql.json b/openshift/templates/rails-postgresql.json index 32b9a78c..a10ae60e 100644 --- a/openshift/templates/rails-postgresql.json +++ b/openshift/templates/rails-postgresql.json @@ -503,9 +503,9 @@ { "name": "RUBY_VERSION", "displayName": "Ruby Version", - "description": "Version of Ruby image to be used (3.3-ubi8 by default).", + "description": "Version of Ruby image to be used (3.3-ubi9 by default).", "required": true, - "value": "3.3-ubi8" + "value": "3.3-ubi9" }, { "name": "POSTGRESQL_VERSION", diff --git a/openshift/templates/rails.json b/openshift/templates/rails.json index 29dab79b..a050e4f4 100644 --- a/openshift/templates/rails.json +++ b/openshift/templates/rails.json @@ -214,9 +214,9 @@ { "name": "RUBY_VERSION", "displayName": "Ruby Version", - "description": "Version of Ruby image to be used (3.3-ubi8 by default).", + "description": "Version of Ruby image to be used (3.3-ubi9 by default).", "required": true, - "value": "3.3-ubi8" + "value": "3.3-ubi9" }, { "name": "MEMORY_LIMIT", diff --git a/tests/test_rails.py b/tests/test_rails.py index b0f5c646..6c5fde6d 100644 --- a/tests/test_rails.py +++ b/tests/test_rails.py @@ -9,12 +9,12 @@ VERSION=os.getenv("SINGLE_VERSION") if not VERSION: - VERSION="3.1-ubi8" + VERSION="3.3-ubi9" class TestRailsAppExTemplate: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="rails-example") + self.oc_api = OpenShiftAPI(pod_name_prefix="rails-example", shared_cluster=True) json_raw_file = self.oc_api.get_raw_url_for_json( container="s2i-ruby-container", dir="imagestreams", filename="ruby-rhel.json" ) @@ -36,7 +36,7 @@ def test_template_inside_cluster(self): template=template_json, name_in_template="rails-example", expected_output=expected_output, openshift_args=[f"SOURCE_REPOSITORY_REF={branch_to_test}", f"RUBY_VERSION={VERSION}", "NAME=rails-example"] ) - assert self.oc_api.template_deployed(name_in_template="rails-example") + assert self.oc_api.is_template_deployed(name_in_template="rails-example") assert self.oc_api.check_response_inside_cluster( name_in_template="rails-example", expected_output=expected_output ) @@ -54,7 +54,7 @@ def test_template_by_request(self): template=template_json, name_in_template="rails-example", expected_output=expected_output, openshift_args=[f"SOURCE_REPOSITORY_REF={branch_to_test}", f"RUBY_VERSION={VERSION}", "NAME=rails-example"] ) - assert self.oc_api.template_deployed(name_in_template="rails-example") + assert self.oc_api.is_template_deployed(name_in_template="rails-example") assert self.oc_api.check_response_outside_cluster( name_in_template="rails-example", expected_output=expected_output ) diff --git a/tests/test_rails_postgresql.py b/tests/test_rails_postgresql.py index 528d3194..fca83701 100644 --- a/tests/test_rails_postgresql.py +++ b/tests/test_rails_postgresql.py @@ -9,20 +9,12 @@ VERSION=os.getenv("SINGLE_VERSION") if not VERSION: - VERSION="3.1-ubi8" + VERSION="3.3-ubi9" class TestRailsAppWithPostgreSQLExTemplate: def setup_method(self): - self.oc_api = OpenShiftAPI(pod_name_prefix="rails-example") - json_raw_file = self.oc_api.get_raw_url_for_json( - container="s2i-ruby-container", dir="imagestreams", filename="ruby-rhel.json" - ) - self.oc_api.import_is(path=json_raw_file, name="ruby") - json_raw_file = self.oc_api.get_raw_url_for_json( - container="postgresql-container", dir="imagestreams", filename="postgresql-rhel.json" - ) - self.oc_api.import_is(path=json_raw_file, name="postgresql") + self.oc_api = OpenShiftAPI(pod_name_prefix="rails-example", shared_cluster=True) def teardown_method(self): self.oc_api.delete_project() @@ -32,6 +24,14 @@ def test_template_inside_cluster(self): branch_to_test = "3.3" else: branch_to_test = "master" + json_raw_file = self.oc_api.get_raw_url_for_json( + container="s2i-ruby-container", dir="imagestreams", filename="ruby-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="ruby") + json_raw_file = self.oc_api.get_raw_url_for_json( + container="postgresql-container", dir="imagestreams", filename="postgresql-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="postgresql") expected_output = "Welcome to your Rails application" template_json = self.oc_api.get_raw_url_for_json( container="rails-ex", branch=branch_to_test, dir="openshift/templates", filename="rails-postgresql-persistent.json" @@ -45,7 +45,7 @@ def test_template_inside_cluster(self): "POSTGRESQL_VERSION=12-el8" ] ) - assert self.oc_api.template_deployed(name_in_template="rails-example") + assert self.oc_api.is_template_deployed(name_in_template="rails-example") assert self.oc_api.check_response_inside_cluster( name_in_template="rails-example", expected_output=expected_output ) @@ -55,6 +55,15 @@ def test_template_by_request(self): branch_to_test = "3.3" else: branch_to_test = "master" + json_raw_file = self.oc_api.get_raw_url_for_json( + container="s2i-ruby-container", dir="imagestreams", filename="ruby-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="ruby") + json_raw_file = self.oc_api.get_raw_url_for_json( + container="postgresql-container", dir="imagestreams", filename="postgresql-rhel.json" + ) + self.oc_api.import_is(path=json_raw_file, name="postgresql") + expected_output = "Welcome to your Rails application" template_json = self.oc_api.get_raw_url_for_json( container="rails-ex", branch=branch_to_test, dir="openshift/templates", filename="rails-postgresql-persistent.json" @@ -68,7 +77,7 @@ def test_template_by_request(self): "POSTGRESQL_VERSION=12-el8" ] ) - assert self.oc_api.template_deployed(name_in_template="rails-example") + assert self.oc_api.is_template_deployed(name_in_template="rails-example") assert self.oc_api.check_response_outside_cluster( name_in_template="rails-example", expected_output=expected_output ) From b328b88d9fa95214c1ee1c3a987c595874123a72 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 24 Jun 2025 10:58:56 +0200 Subject: [PATCH 2/3] Increase timeout. Ruby installation took a bit more time Signed-off-by: Petr "Stone" Hracek --- tests/test_rails.py | 4 ++-- tests/test_rails_postgresql.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_rails.py b/tests/test_rails.py index 6c5fde6d..e4bcf5d3 100644 --- a/tests/test_rails.py +++ b/tests/test_rails.py @@ -36,7 +36,7 @@ def test_template_inside_cluster(self): template=template_json, name_in_template="rails-example", expected_output=expected_output, openshift_args=[f"SOURCE_REPOSITORY_REF={branch_to_test}", f"RUBY_VERSION={VERSION}", "NAME=rails-example"] ) - assert self.oc_api.is_template_deployed(name_in_template="rails-example") + assert self.oc_api.is_template_deployed(name_in_template="rails-example", timeout=600) assert self.oc_api.check_response_inside_cluster( name_in_template="rails-example", expected_output=expected_output ) @@ -54,7 +54,7 @@ def test_template_by_request(self): template=template_json, name_in_template="rails-example", expected_output=expected_output, openshift_args=[f"SOURCE_REPOSITORY_REF={branch_to_test}", f"RUBY_VERSION={VERSION}", "NAME=rails-example"] ) - assert self.oc_api.is_template_deployed(name_in_template="rails-example") + assert self.oc_api.is_template_deployed(name_in_template="rails-example", timeout=600) assert self.oc_api.check_response_outside_cluster( name_in_template="rails-example", expected_output=expected_output ) diff --git a/tests/test_rails_postgresql.py b/tests/test_rails_postgresql.py index fca83701..ca0b2af2 100644 --- a/tests/test_rails_postgresql.py +++ b/tests/test_rails_postgresql.py @@ -45,7 +45,7 @@ def test_template_inside_cluster(self): "POSTGRESQL_VERSION=12-el8" ] ) - assert self.oc_api.is_template_deployed(name_in_template="rails-example") + assert self.oc_api.is_template_deployed(name_in_template="rails-example", timeout=600) assert self.oc_api.check_response_inside_cluster( name_in_template="rails-example", expected_output=expected_output ) @@ -77,7 +77,7 @@ def test_template_by_request(self): "POSTGRESQL_VERSION=12-el8" ] ) - assert self.oc_api.is_template_deployed(name_in_template="rails-example") + assert self.oc_api.is_template_deployed(name_in_template="rails-example", timeout=600) assert self.oc_api.check_response_outside_cluster( name_in_template="rails-example", expected_output=expected_output ) From 9e03a0bbd9587996bf9142762323c13b7e6ec874 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 24 Jun 2025 11:11:04 +0200 Subject: [PATCH 3/3] Do not check outside of cluster. It does not make sense for now. Signed-off-by: Petr "Stone" Hracek --- tests/test_rails.py | 18 ----------------- tests/test_rails_postgresql.py | 36 ++-------------------------------- 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/tests/test_rails.py b/tests/test_rails.py index e4bcf5d3..bbd96762 100644 --- a/tests/test_rails.py +++ b/tests/test_rails.py @@ -40,21 +40,3 @@ def test_template_inside_cluster(self): assert self.oc_api.check_response_inside_cluster( name_in_template="rails-example", expected_output=expected_output ) - - def test_template_by_request(self): - if VERSION.startswith("3.3"): - branch_to_test = "3.3" - else: - branch_to_test = "master" - expected_output = "Welcome to your Rails application" - template_json = self.oc_api.get_raw_url_for_json( - container="rails-ex", branch=branch_to_test, dir="openshift/templates", filename="rails.json" - ) - assert self.oc_api.deploy_template( - template=template_json, name_in_template="rails-example", expected_output=expected_output, - openshift_args=[f"SOURCE_REPOSITORY_REF={branch_to_test}", f"RUBY_VERSION={VERSION}", "NAME=rails-example"] - ) - assert self.oc_api.is_template_deployed(name_in_template="rails-example", timeout=600) - assert self.oc_api.check_response_outside_cluster( - name_in_template="rails-example", expected_output=expected_output - ) diff --git a/tests/test_rails_postgresql.py b/tests/test_rails_postgresql.py index ca0b2af2..cb835304 100644 --- a/tests/test_rails_postgresql.py +++ b/tests/test_rails_postgresql.py @@ -27,11 +27,11 @@ def test_template_inside_cluster(self): json_raw_file = self.oc_api.get_raw_url_for_json( container="s2i-ruby-container", dir="imagestreams", filename="ruby-rhel.json" ) - self.oc_api.import_is(path=json_raw_file, name="ruby") + self.oc_api.import_is(path=json_raw_file, name="ruby", skip_check=True) json_raw_file = self.oc_api.get_raw_url_for_json( container="postgresql-container", dir="imagestreams", filename="postgresql-rhel.json" ) - self.oc_api.import_is(path=json_raw_file, name="postgresql") + self.oc_api.import_is(path=json_raw_file, name="postgresql", skip_check=True) expected_output = "Welcome to your Rails application" template_json = self.oc_api.get_raw_url_for_json( container="rails-ex", branch=branch_to_test, dir="openshift/templates", filename="rails-postgresql-persistent.json" @@ -49,35 +49,3 @@ def test_template_inside_cluster(self): assert self.oc_api.check_response_inside_cluster( name_in_template="rails-example", expected_output=expected_output ) - - def test_template_by_request(self): - if VERSION.startswith("3.3"): - branch_to_test = "3.3" - else: - branch_to_test = "master" - json_raw_file = self.oc_api.get_raw_url_for_json( - container="s2i-ruby-container", dir="imagestreams", filename="ruby-rhel.json" - ) - self.oc_api.import_is(path=json_raw_file, name="ruby") - json_raw_file = self.oc_api.get_raw_url_for_json( - container="postgresql-container", dir="imagestreams", filename="postgresql-rhel.json" - ) - self.oc_api.import_is(path=json_raw_file, name="postgresql") - - expected_output = "Welcome to your Rails application" - template_json = self.oc_api.get_raw_url_for_json( - container="rails-ex", branch=branch_to_test, dir="openshift/templates", filename="rails-postgresql-persistent.json" - ) - assert self.oc_api.deploy_template( - template=template_json, name_in_template="rails-example", expected_output=expected_output, - openshift_args=[ - f"SOURCE_REPOSITORY_REF={branch_to_test}", - f"RUBY_VERSION={VERSION}", - "NAME=rails-example", - "POSTGRESQL_VERSION=12-el8" - ] - ) - assert self.oc_api.is_template_deployed(name_in_template="rails-example", timeout=600) - assert self.oc_api.check_response_outside_cluster( - name_in_template="rails-example", expected_output=expected_output - )