From ba6f172ec8e1262dbf3d67470d4f52027d618d2e Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Thu, 5 Dec 2024 10:35:18 +0100 Subject: [PATCH 1/6] Add tests for ruby-ex repositories. Also OpenShift 4 updates are in this pull request as well. Signed-off-by: Petr "Stone" Hracek --- test/run | 30 ++++++- ...n.py => test_helm_rails_ex_application.py} | 4 +- test/test_helm_ruby_ex_application.py | 88 +++++++++++++++++++ test/test_helm_ruby_imagestreams.py | 27 +++--- test/test_rails_ex_standalone.py | 41 +++++++++ test/test_ruby_ex_standalone.py | 9 +- 6 files changed, 174 insertions(+), 25 deletions(-) rename test/{test_helm_ruby_rails_application.py => test_helm_rails_ex_application.py} (93%) create mode 100644 test/test_helm_ruby_ex_application.py create mode 100644 test/test_rails_ex_standalone.py diff --git a/test/run b/test/run index 64b9e3eb..87387e3b 100755 --- a/test/run +++ b/test/run @@ -134,7 +134,7 @@ function test_application() { function test_from_dockerfile() { dockerfile="Dockerfile${1:-}" TESTCASE_RESULT=0 - info "Check building using a $dockerfile" + info "Check building using a $dockerfile on rails-ex repository." # Ruby 3.3 introduced too many incompatibilities to be able # to use the same Gemfile for RHEL 7 and also newer RHELs. @@ -158,6 +158,27 @@ function test_from_dockerfile_s2i() { test_from_dockerfile ".s2i" } +function test_from_dockerfile_ruby_ex() { + dockerfile="Dockerfile${1:-}" + TESTCASE_RESULT=0 + info "Check building using a $dockerfile on ruby-ex repository." + + # Ruby 3.3 introduced too many incompatibilities to be able + # to use the same Gemfile for RHEL 7 and also newer RHELs. + # we can use the same Gemfile for RHEL 7 and newer + # as long as Ruby MAJOR.MINOR <= 3.1. Newer Ruby needs dependencies + # that are not compatible with RHEL 7. + + ruby_example_repo_url="https://github.com/sclorg/ruby-ex.git@master" + + ct_test_app_dockerfile $test_dir/examples/from-dockerfile/$dockerfile "$ruby_example_repo_url" 'Welcome to your Ruby application' app-src + ct_check_testcase_result $? +} + +function test_from_dockerfile_ruby_ex_s2i() { + test_from_dockerfile_ruby_ex ".s2i" +} + app_cleanup() { info "Cleaning up the test app folders" for server in ${WEB_SERVERS[*]}; do @@ -235,8 +256,11 @@ for server in ${WEB_SERVERS[@]}; do cleanup done -TEST_LIST="test_from_dockerfile test_from_dockerfile_s2i" -TEST_SET=${TESTS:-$TEST_LIST} ct_run_tests_from_testset "from_dockerfile" +TEST_RAILS_LIST="test_from_dockerfile test_from_dockerfile_s2i" +TEST_SET=${TESTS:-$TEST_RAILS_LIST} ct_run_tests_from_testset "from_dockerfile_rails_ex" + +TEST_RUBY_LIST="test_from_dockerfile_ruby_ex test_from_dockerfile_ruby_ex_s2i" +TEST_SET=${TESTS:-$TEST_RUBY_LIST} ct_run_tests_from_testset "from_dockerfile_ruby_ex" # Remove all test dependencies diff --git a/test/test_helm_ruby_rails_application.py b/test/test_helm_rails_ex_application.py similarity index 93% rename from test/test_helm_ruby_rails_application.py rename to test/test_helm_rails_ex_application.py index f45e899a..189b3687 100644 --- a/test/test_helm_ruby_rails_application.py +++ b/test/test_helm_rails_ex_application.py @@ -28,7 +28,7 @@ TAG = TAGS.get(OS, None) -class TestHelmCakePHPTemplate: +class TestHelmRailsExTemplate: def setup_method(self): package_name = "ruby-rails-application" @@ -58,6 +58,7 @@ def test_curl_connection(self): "ruby_version": f"{VERSION}{TAG}", "namespace": self.hc_api.namespace, "source_repository_ref": rails_ex_branch, + "source_repository_url": "https://github.com/sclorg/rails-ex.git", } ) assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example") @@ -80,6 +81,7 @@ def test_by_helm_test(self): "ruby_version": f"{VERSION}{TAG}", "namespace": self.hc_api.namespace, "source_repository_ref": rails_ex_branch, + "source_repository_url": "https://github.com/sclorg/rails-ex.git", } ) assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example") diff --git a/test/test_helm_ruby_ex_application.py b/test/test_helm_ruby_ex_application.py new file mode 100644 index 00000000..df291863 --- /dev/null +++ b/test/test_helm_ruby_ex_application.py @@ -0,0 +1,88 @@ +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__))) + + +VERSION = os.getenv("VERSION") +IMAGE_NAME = os.getenv("IMAGE_NAME") +OS = os.getenv("TARGET") + + +TAGS = { + "rhel8": "-ubi8", + "rhel9": "-ubi9" +} +TAG = TAGS.get(OS, None) + + +class TestHelmRubyExTemplate: + + def setup_method(self): + package_name = "ruby-rails-application" + path = test_dir + self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True) + 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() + + def test_curl_connection(self): + if self.hc_api.oc_api.shared_cluster: + pytest.skip("Do NOT test on shared cluster") + rails_ex_branch = "master" + if VERSION == "3.3": + rails_ex_branch = VERSION + self.hc_api.package_name = "ruby-imagestreams" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation() + self.hc_api.package_name = "ruby-rails-application" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation( + values={ + "ruby_version": f"{VERSION}{TAG}", + "namespace": self.hc_api.namespace, + "source_repository_ref": rails_ex_branch, + "source_repository_url": "https://github.com/sclorg/ruby-ex.git", + } + ) + assert self.hc_api.is_s2i_pod_running(pod_name_prefix="ruby-example") + assert self.hc_api.test_helm_curl_output( + route_name="ruby-example", + expected_str="Welcome to your Ruby application" + ) + + def test_by_helm_test(self): + rails_ex_branch = "master" + if VERSION == "3.3": + rails_ex_branch = VERSION + self.hc_api.package_name = "ruby-imagestreams" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation() + self.hc_api.package_name = "ruby-rails-application" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation( + values={ + "ruby_version": f"{VERSION}{TAG}", + "namespace": self.hc_api.namespace, + "source_repository_ref": rails_ex_branch, + "source_repository_url": "https://github.com/sclorg/ruby-ex.git", + } + ) + assert self.hc_api.is_s2i_pod_running(pod_name_prefix="ruby-example") + assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Ruby application"]) diff --git a/test/test_helm_ruby_imagestreams.py b/test/test_helm_ruby_imagestreams.py index 0feb2b06..1e131e47 100644 --- a/test/test_helm_ruby_imagestreams.py +++ b/test/test_helm_ruby_imagestreams.py @@ -21,19 +21,16 @@ OS = os.getenv("TARGET") -class TestHelmRHELRubyImageStreams: +@pytest.fixture(scope="module") +def helm_api(request): + helm_api = HelmChartsAPI(path=test_dir / "../charts/redhat", package_name="ruby-imagestreams", tarball_dir=test_dir) + # app_name = os.path.basename(request.param) + yield helm_api + pass + helm_api.delete_project() - def setup_method(self): - package_name = "ruby-imagestreams" - path = test_dir - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True) - 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() +class TestHelmRHELRubyImageStreams: @pytest.mark.parametrize( "version,registry,expected", @@ -47,7 +44,7 @@ def teardown_method(self): ("2.5-ubi8", "registry.redhat.io/ubi8/ruby-25:latest", True), ], ) - 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 + def test_package_imagestream(self, helm_api, version, registry, expected): + assert helm_api.helm_package() + assert helm_api.helm_installation() + assert helm_api.check_imagestreams(version=version, registry=registry) == expected diff --git a/test/test_rails_ex_standalone.py b/test/test_rails_ex_standalone.py new file mode 100644 index 00000000..fe7d4e51 --- /dev/null +++ b/test/test_rails_ex_standalone.py @@ -0,0 +1,41 @@ +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") +IMAGE_NAME = os.getenv("IMAGE_NAME") +OS = os.getenv("TARGET") + + +# Replacement with 'test_python_s2i_app_ex' +class TestS2IRailsExTemplate: + + def setup_method(self): + self.oc_api = OpenShiftAPI(pod_name_prefix="ruby-testing", version=VERSION) + + def teardown_method(self): + self.oc_api.delete_project() + + def test_dancer_ex_template_inside_cluster(self): + service_name = "ruby-testing" + rails_ex_branch = "master" + if VERSION == "3.3": + rails_ex_branch = VERSION + assert self.oc_api.deploy_s2i_app( + image_name=IMAGE_NAME, app=f"https://github.com/sclorg/rails-ex#{rails_ex_branch}", + context=".", + service_name=service_name + ) + assert self.oc_api.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 Rails application" + ) diff --git a/test/test_ruby_ex_standalone.py b/test/test_ruby_ex_standalone.py index fe7d4e51..113949e1 100644 --- a/test/test_ruby_ex_standalone.py +++ b/test/test_ruby_ex_standalone.py @@ -17,7 +17,7 @@ # Replacement with 'test_python_s2i_app_ex' -class TestS2IRailsExTemplate: +class TestS2IRubyExTemplate: def setup_method(self): self.oc_api = OpenShiftAPI(pod_name_prefix="ruby-testing", version=VERSION) @@ -27,15 +27,12 @@ def teardown_method(self): def test_dancer_ex_template_inside_cluster(self): service_name = "ruby-testing" - rails_ex_branch = "master" - if VERSION == "3.3": - rails_ex_branch = VERSION assert self.oc_api.deploy_s2i_app( - image_name=IMAGE_NAME, app=f"https://github.com/sclorg/rails-ex#{rails_ex_branch}", + image_name=IMAGE_NAME, app=f"https://github.com/sclorg/ruby-ex", context=".", service_name=service_name ) assert self.oc_api.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 Rails application" + name_in_template=service_name, expected_output="Welcome to your Ruby application" ) From d8e7390fe222a167bff05b190358917b39391944 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Thu, 5 Dec 2024 11:18:26 +0100 Subject: [PATCH 2/6] Remove comment that is not valid anymore. Signed-off-by: Petr "Stone" Hracek --- test/run | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/test/run b/test/run index 87387e3b..d0942136 100755 --- a/test/run +++ b/test/run @@ -136,12 +136,6 @@ function test_from_dockerfile() { TESTCASE_RESULT=0 info "Check building using a $dockerfile on rails-ex repository." - # Ruby 3.3 introduced too many incompatibilities to be able - # to use the same Gemfile for RHEL 7 and also newer RHELs. - # we can use the same Gemfile for RHEL 7 and newer - # as long as Ruby MAJOR.MINOR <= 3.1. Newer Ruby needs dependencies - # that are not compatible with RHEL 7. - # Latest stable rails_example_repo_branch="3.3" if { echo "$VERSION"; echo "3.1"; } | sort --version-sort --check=quiet; then @@ -163,12 +157,6 @@ function test_from_dockerfile_ruby_ex() { TESTCASE_RESULT=0 info "Check building using a $dockerfile on ruby-ex repository." - # Ruby 3.3 introduced too many incompatibilities to be able - # to use the same Gemfile for RHEL 7 and also newer RHELs. - # we can use the same Gemfile for RHEL 7 and newer - # as long as Ruby MAJOR.MINOR <= 3.1. Newer Ruby needs dependencies - # that are not compatible with RHEL 7. - ruby_example_repo_url="https://github.com/sclorg/ruby-ex.git@master" ct_test_app_dockerfile $test_dir/examples/from-dockerfile/$dockerfile "$ruby_example_repo_url" 'Welcome to your Ruby application' app-src From 0f9f0b3a3768114d2a7fc117265721bc3978e9a6 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Thu, 5 Dec 2024 11:19:41 +0100 Subject: [PATCH 3/6] Update symbolic links caused by renaming Signed-off-by: Petr "Stone" Hracek --- 2.5/test/test_helm_rails_ex_application.py | 1 + 2.5/test/test_helm_ruby_ex_application.py | 1 + 2.5/test/test_helm_ruby_rails_application.py | 1 - 3.0/test/test_helm_rails_ex_application.py | 1 + 3.0/test/test_helm_ruby_ex_application.py | 1 + 3.0/test/test_helm_ruby_rails_application.py | 1 - 3.1/test/test_helm_rails_ex_application.py | 1 + 3.1/test/test_helm_ruby_ex_application.py | 1 + 3.1/test/test_helm_ruby_rails_application.py | 1 - 3.3/test/test_helm_rails_ex_application.py | 1 + 3.3/test/test_helm_ruby_ex_application.py | 1 + 3.3/test/test_helm_ruby_rails_application.py | 1 - 12 files changed, 8 insertions(+), 4 deletions(-) create mode 120000 2.5/test/test_helm_rails_ex_application.py create mode 120000 2.5/test/test_helm_ruby_ex_application.py delete mode 120000 2.5/test/test_helm_ruby_rails_application.py create mode 120000 3.0/test/test_helm_rails_ex_application.py create mode 120000 3.0/test/test_helm_ruby_ex_application.py delete mode 120000 3.0/test/test_helm_ruby_rails_application.py create mode 120000 3.1/test/test_helm_rails_ex_application.py create mode 120000 3.1/test/test_helm_ruby_ex_application.py delete mode 120000 3.1/test/test_helm_ruby_rails_application.py create mode 120000 3.3/test/test_helm_rails_ex_application.py create mode 120000 3.3/test/test_helm_ruby_ex_application.py delete mode 120000 3.3/test/test_helm_ruby_rails_application.py diff --git a/2.5/test/test_helm_rails_ex_application.py b/2.5/test/test_helm_rails_ex_application.py new file mode 120000 index 00000000..3223e1f5 --- /dev/null +++ b/2.5/test/test_helm_rails_ex_application.py @@ -0,0 +1 @@ +../../test/test_helm_rails_ex_application.py \ No newline at end of file diff --git a/2.5/test/test_helm_ruby_ex_application.py b/2.5/test/test_helm_ruby_ex_application.py new file mode 120000 index 00000000..40c1f38a --- /dev/null +++ b/2.5/test/test_helm_ruby_ex_application.py @@ -0,0 +1 @@ +../../test/test_helm_ruby_ex_application.py \ No newline at end of file diff --git a/2.5/test/test_helm_ruby_rails_application.py b/2.5/test/test_helm_ruby_rails_application.py deleted file mode 120000 index 28f86c0a..00000000 --- a/2.5/test/test_helm_ruby_rails_application.py +++ /dev/null @@ -1 +0,0 @@ -../../test/test_helm_ruby_rails_application.py \ No newline at end of file diff --git a/3.0/test/test_helm_rails_ex_application.py b/3.0/test/test_helm_rails_ex_application.py new file mode 120000 index 00000000..3223e1f5 --- /dev/null +++ b/3.0/test/test_helm_rails_ex_application.py @@ -0,0 +1 @@ +../../test/test_helm_rails_ex_application.py \ No newline at end of file diff --git a/3.0/test/test_helm_ruby_ex_application.py b/3.0/test/test_helm_ruby_ex_application.py new file mode 120000 index 00000000..40c1f38a --- /dev/null +++ b/3.0/test/test_helm_ruby_ex_application.py @@ -0,0 +1 @@ +../../test/test_helm_ruby_ex_application.py \ No newline at end of file diff --git a/3.0/test/test_helm_ruby_rails_application.py b/3.0/test/test_helm_ruby_rails_application.py deleted file mode 120000 index 28f86c0a..00000000 --- a/3.0/test/test_helm_ruby_rails_application.py +++ /dev/null @@ -1 +0,0 @@ -../../test/test_helm_ruby_rails_application.py \ No newline at end of file diff --git a/3.1/test/test_helm_rails_ex_application.py b/3.1/test/test_helm_rails_ex_application.py new file mode 120000 index 00000000..3223e1f5 --- /dev/null +++ b/3.1/test/test_helm_rails_ex_application.py @@ -0,0 +1 @@ +../../test/test_helm_rails_ex_application.py \ No newline at end of file diff --git a/3.1/test/test_helm_ruby_ex_application.py b/3.1/test/test_helm_ruby_ex_application.py new file mode 120000 index 00000000..40c1f38a --- /dev/null +++ b/3.1/test/test_helm_ruby_ex_application.py @@ -0,0 +1 @@ +../../test/test_helm_ruby_ex_application.py \ No newline at end of file diff --git a/3.1/test/test_helm_ruby_rails_application.py b/3.1/test/test_helm_ruby_rails_application.py deleted file mode 120000 index 28f86c0a..00000000 --- a/3.1/test/test_helm_ruby_rails_application.py +++ /dev/null @@ -1 +0,0 @@ -../../test/test_helm_ruby_rails_application.py \ No newline at end of file diff --git a/3.3/test/test_helm_rails_ex_application.py b/3.3/test/test_helm_rails_ex_application.py new file mode 120000 index 00000000..3223e1f5 --- /dev/null +++ b/3.3/test/test_helm_rails_ex_application.py @@ -0,0 +1 @@ +../../test/test_helm_rails_ex_application.py \ No newline at end of file diff --git a/3.3/test/test_helm_ruby_ex_application.py b/3.3/test/test_helm_ruby_ex_application.py new file mode 120000 index 00000000..40c1f38a --- /dev/null +++ b/3.3/test/test_helm_ruby_ex_application.py @@ -0,0 +1 @@ +../../test/test_helm_ruby_ex_application.py \ No newline at end of file diff --git a/3.3/test/test_helm_ruby_rails_application.py b/3.3/test/test_helm_ruby_rails_application.py deleted file mode 120000 index 28f86c0a..00000000 --- a/3.3/test/test_helm_ruby_rails_application.py +++ /dev/null @@ -1 +0,0 @@ -../../test/test_helm_ruby_rails_application.py \ No newline at end of file From 0a5ad679f8873a60fa4226b0cc8699ac23cc9e38 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 9 Dec 2024 10:50:42 +0100 Subject: [PATCH 4/6] Rename Ruby Helm Charts tor RedHat Signed-off-by: Petr "Stone" Hracek --- test/test_helm_rails_ex_application.py | 20 ++++++++++++-------- test/test_helm_ruby_ex_application.py | 20 ++++++++++++-------- test/test_helm_ruby_imagestreams.py | 2 +- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/test/test_helm_rails_ex_application.py b/test/test_helm_rails_ex_application.py index 189b3687..da1889b1 100644 --- a/test/test_helm_rails_ex_application.py +++ b/test/test_helm_rails_ex_application.py @@ -31,7 +31,7 @@ class TestHelmRailsExTemplate: def setup_method(self): - package_name = "ruby-rails-application" + package_name = "redhat-ruby-rails-application" path = test_dir self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True) self.hc_api.clone_helm_chart_repo( @@ -48,22 +48,24 @@ def test_curl_connection(self): rails_ex_branch = "master" if VERSION == "3.3": rails_ex_branch = VERSION - self.hc_api.package_name = "ruby-imagestreams" + self.hc_api.package_name = "redhat-ruby-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() - self.hc_api.package_name = "ruby-rails-application" + self.hc_api.package_name = "redhat-ruby-rails-application" assert self.hc_api.helm_package() + pod_name = f"rails_{VERSION.replace(".", "")}" assert self.hc_api.helm_installation( values={ "ruby_version": f"{VERSION}{TAG}", "namespace": self.hc_api.namespace, "source_repository_ref": rails_ex_branch, "source_repository_url": "https://github.com/sclorg/rails-ex.git", + "name": pod_name, } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example") + assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name) assert self.hc_api.test_helm_curl_output( - route_name="rails-example", + route_name=pod_name, expected_str="Welcome to your Rails application" ) @@ -71,18 +73,20 @@ def test_by_helm_test(self): rails_ex_branch = "master" if VERSION == "3.3": rails_ex_branch = VERSION - self.hc_api.package_name = "ruby-imagestreams" + self.hc_api.package_name = "redhat-ruby-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() - self.hc_api.package_name = "ruby-rails-application" + self.hc_api.package_name = "redhat-ruby-rails-application" assert self.hc_api.helm_package() + pod_name = f"rails_{VERSION.replace(".", "")}" assert self.hc_api.helm_installation( values={ "ruby_version": f"{VERSION}{TAG}", "namespace": self.hc_api.namespace, "source_repository_ref": rails_ex_branch, "source_repository_url": "https://github.com/sclorg/rails-ex.git", + "name": pod_name } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example") + assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name) assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Rails application"]) diff --git a/test/test_helm_ruby_ex_application.py b/test/test_helm_ruby_ex_application.py index df291863..a1f5d737 100644 --- a/test/test_helm_ruby_ex_application.py +++ b/test/test_helm_ruby_ex_application.py @@ -31,7 +31,7 @@ class TestHelmRubyExTemplate: def setup_method(self): - package_name = "ruby-rails-application" + package_name = "redhat-ruby-rails-application" path = test_dir self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True) self.hc_api.clone_helm_chart_repo( @@ -48,22 +48,24 @@ def test_curl_connection(self): rails_ex_branch = "master" if VERSION == "3.3": rails_ex_branch = VERSION - self.hc_api.package_name = "ruby-imagestreams" + self.hc_api.package_name = "redhat-ruby-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() - self.hc_api.package_name = "ruby-rails-application" + self.hc_api.package_name = "redhat-ruby-rails-application" assert self.hc_api.helm_package() + pod_name = f"rails_{VERSION.replace(".", "")}" assert self.hc_api.helm_installation( values={ "ruby_version": f"{VERSION}{TAG}", "namespace": self.hc_api.namespace, "source_repository_ref": rails_ex_branch, "source_repository_url": "https://github.com/sclorg/ruby-ex.git", + "name": pod_name, } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix="ruby-example") + assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=300) assert self.hc_api.test_helm_curl_output( - route_name="ruby-example", + route_name=pod_name, expected_str="Welcome to your Ruby application" ) @@ -71,18 +73,20 @@ def test_by_helm_test(self): rails_ex_branch = "master" if VERSION == "3.3": rails_ex_branch = VERSION - self.hc_api.package_name = "ruby-imagestreams" + self.hc_api.package_name = "redhat-ruby-imagestreams" assert self.hc_api.helm_package() assert self.hc_api.helm_installation() - self.hc_api.package_name = "ruby-rails-application" + self.hc_api.package_name = "redhat-ruby-rails-application" assert self.hc_api.helm_package() + pod_name = f"rails_{VERSION.replace(".", "")}" assert self.hc_api.helm_installation( values={ "ruby_version": f"{VERSION}{TAG}", "namespace": self.hc_api.namespace, "source_repository_ref": rails_ex_branch, "source_repository_url": "https://github.com/sclorg/ruby-ex.git", + "name": pod_name, } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix="ruby-example") + assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=300) assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Ruby application"]) diff --git a/test/test_helm_ruby_imagestreams.py b/test/test_helm_ruby_imagestreams.py index 1e131e47..4d6379ac 100644 --- a/test/test_helm_ruby_imagestreams.py +++ b/test/test_helm_ruby_imagestreams.py @@ -23,7 +23,7 @@ @pytest.fixture(scope="module") def helm_api(request): - helm_api = HelmChartsAPI(path=test_dir / "../charts/redhat", package_name="ruby-imagestreams", tarball_dir=test_dir) + helm_api = HelmChartsAPI(path=test_dir / "../charts/redhat", package_name="redhat-ruby-imagestreams", tarball_dir=test_dir) # app_name = os.path.basename(request.param) yield helm_api pass From 1c97cdedd31e68aada6079f178f414255b2fd52b Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 9 Dec 2024 12:24:59 +0100 Subject: [PATCH 5/6] Clone helm charts repo before testing. Otherwise we do not have sources Signed-off-by: Petr "Stone" Hracek --- test/test_helm_rails_ex_application.py | 4 ++-- test/test_helm_ruby_ex_application.py | 4 ++-- test/test_helm_ruby_imagestreams.py | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/test_helm_rails_ex_application.py b/test/test_helm_rails_ex_application.py index da1889b1..dde93643 100644 --- a/test/test_helm_rails_ex_application.py +++ b/test/test_helm_rails_ex_application.py @@ -53,7 +53,7 @@ def test_curl_connection(self): assert self.hc_api.helm_installation() self.hc_api.package_name = "redhat-ruby-rails-application" assert self.hc_api.helm_package() - pod_name = f"rails_{VERSION.replace(".", "")}" + pod_name = f"rails-{VERSION.replace(".", "")}" assert self.hc_api.helm_installation( values={ "ruby_version": f"{VERSION}{TAG}", @@ -78,7 +78,7 @@ def test_by_helm_test(self): assert self.hc_api.helm_installation() self.hc_api.package_name = "redhat-ruby-rails-application" assert self.hc_api.helm_package() - pod_name = f"rails_{VERSION.replace(".", "")}" + pod_name = f"rails-{VERSION.replace(".", "")}" assert self.hc_api.helm_installation( values={ "ruby_version": f"{VERSION}{TAG}", diff --git a/test/test_helm_ruby_ex_application.py b/test/test_helm_ruby_ex_application.py index a1f5d737..69bcf72d 100644 --- a/test/test_helm_ruby_ex_application.py +++ b/test/test_helm_ruby_ex_application.py @@ -53,7 +53,7 @@ def test_curl_connection(self): assert self.hc_api.helm_installation() self.hc_api.package_name = "redhat-ruby-rails-application" assert self.hc_api.helm_package() - pod_name = f"rails_{VERSION.replace(".", "")}" + pod_name = f"rails-{VERSION.replace(".", "")}" assert self.hc_api.helm_installation( values={ "ruby_version": f"{VERSION}{TAG}", @@ -78,7 +78,7 @@ def test_by_helm_test(self): assert self.hc_api.helm_installation() self.hc_api.package_name = "redhat-ruby-rails-application" assert self.hc_api.helm_package() - pod_name = f"rails_{VERSION.replace(".", "")}" + pod_name = f"rails-{VERSION.replace(".", "")}" assert self.hc_api.helm_installation( values={ "ruby_version": f"{VERSION}{TAG}", diff --git a/test/test_helm_ruby_imagestreams.py b/test/test_helm_ruby_imagestreams.py index 4d6379ac..6d4a9f5c 100644 --- a/test/test_helm_ruby_imagestreams.py +++ b/test/test_helm_ruby_imagestreams.py @@ -24,6 +24,10 @@ @pytest.fixture(scope="module") def helm_api(request): helm_api = HelmChartsAPI(path=test_dir / "../charts/redhat", package_name="redhat-ruby-imagestreams", tarball_dir=test_dir) + helm_api.clone_helm_chart_repo( + repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", + subdir="charts/redhat" + ) # app_name = os.path.basename(request.param) yield helm_api pass From f46bb1fe74bac64440672f489f76722a7adcc68e Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 9 Dec 2024 14:26:26 +0100 Subject: [PATCH 6/6] Increase timeout to 480s. S2I build takes really too much time. Signed-off-by: Petr "Stone" Hracek --- test/test_helm_rails_ex_application.py | 6 +++--- test/test_helm_ruby_ex_application.py | 6 +++--- test/test_helm_ruby_imagestreams.py | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/test/test_helm_rails_ex_application.py b/test/test_helm_rails_ex_application.py index dde93643..02a6de1c 100644 --- a/test/test_helm_rails_ex_application.py +++ b/test/test_helm_rails_ex_application.py @@ -33,7 +33,7 @@ class TestHelmRailsExTemplate: def setup_method(self): package_name = "redhat-ruby-rails-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=False) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" @@ -63,7 +63,7 @@ def test_curl_connection(self): "name": pod_name, } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name) + assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=480) assert self.hc_api.test_helm_curl_output( route_name=pod_name, expected_str="Welcome to your Rails application" @@ -88,5 +88,5 @@ def test_by_helm_test(self): "name": pod_name } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name) + assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=480) assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Rails application"]) diff --git a/test/test_helm_ruby_ex_application.py b/test/test_helm_ruby_ex_application.py index 69bcf72d..f413a9d3 100644 --- a/test/test_helm_ruby_ex_application.py +++ b/test/test_helm_ruby_ex_application.py @@ -33,7 +33,7 @@ class TestHelmRubyExTemplate: def setup_method(self): package_name = "redhat-ruby-rails-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=False) self.hc_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat" @@ -63,7 +63,7 @@ def test_curl_connection(self): "name": pod_name, } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=300) + assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=480) assert self.hc_api.test_helm_curl_output( route_name=pod_name, expected_str="Welcome to your Ruby application" @@ -88,5 +88,5 @@ def test_by_helm_test(self): "name": pod_name, } ) - assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=300) + assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=480) assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Ruby application"]) diff --git a/test/test_helm_ruby_imagestreams.py b/test/test_helm_ruby_imagestreams.py index 6d4a9f5c..e0a23ed6 100644 --- a/test/test_helm_ruby_imagestreams.py +++ b/test/test_helm_ruby_imagestreams.py @@ -23,7 +23,9 @@ @pytest.fixture(scope="module") def helm_api(request): - helm_api = HelmChartsAPI(path=test_dir / "../charts/redhat", package_name="redhat-ruby-imagestreams", tarball_dir=test_dir) + helm_api = HelmChartsAPI( + path=test_dir / "../charts/redhat", package_name="redhat-ruby-imagestreams", tarball_dir=test_dir + ) helm_api.clone_helm_chart_repo( repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", subdir="charts/redhat"