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 diff --git a/test/run b/test/run index 64b9e3eb..d0942136 100755 --- a/test/run +++ b/test/run @@ -134,13 +134,7 @@ function test_application() { function test_from_dockerfile() { dockerfile="Dockerfile${1:-}" TESTCASE_RESULT=0 - info "Check building using a $dockerfile" - - # 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. + info "Check building using a $dockerfile on rails-ex repository." # Latest stable rails_example_repo_branch="3.3" @@ -158,6 +152,21 @@ 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_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 +244,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 70% rename from test/test_helm_ruby_rails_application.py rename to test/test_helm_rails_ex_application.py index f45e899a..02a6de1c 100644 --- a/test/test_helm_ruby_rails_application.py +++ b/test/test_helm_rails_ex_application.py @@ -28,12 +28,12 @@ TAG = TAGS.get(OS, None) -class TestHelmCakePHPTemplate: +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 = 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" @@ -48,21 +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, timeout=480) assert self.hc_api.test_helm_curl_output( - route_name="rails-example", + route_name=pod_name, expected_str="Welcome to your Rails application" ) @@ -70,17 +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, 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 new file mode 100644 index 00000000..f413a9d3 --- /dev/null +++ b/test/test_helm_ruby_ex_application.py @@ -0,0 +1,92 @@ +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 = "redhat-ruby-rails-application" + path = test_dir + 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" + ) + + 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 = "redhat-ruby-imagestreams" + assert self.hc_api.helm_package() + 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(".", "")}" + 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=pod_name, timeout=480) + assert self.hc_api.test_helm_curl_output( + route_name=pod_name, + 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 = "redhat-ruby-imagestreams" + assert self.hc_api.helm_package() + 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(".", "")}" + 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=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 0feb2b06..e0a23ed6 100644 --- a/test/test_helm_ruby_imagestreams.py +++ b/test/test_helm_ruby_imagestreams.py @@ -21,19 +21,22 @@ OS = os.getenv("TARGET") -class TestHelmRHELRubyImageStreams: +@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 + 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 +50,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" )