Skip to content

Commit

Permalink
Add support for testing Helm Charts from https://github.com/sclorg/he…
Browse files Browse the repository at this point in the history
…lm-charts

repository in s2i-ruby-container.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
  • Loading branch information
phracek committed Sep 13, 2024
1 parent adfd752 commit a02bea5
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/test_helm_ruby_imagestreams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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")


class TestHelmRHELRubyImageStreams:

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()

@pytest.mark.parametrize(
"version,registry",
[
("3.3-ubi9", "registry.redhat.io/ubi9/ruby-33:latest"),
("3.3-ubi8", "registry.redhat.io/ubi8/ruby-33:latest"),
("3.1-ubi9", "registry.redhat.io/ubi9/ruby-31:latest"),
("3.1-ubi8", "registry.redhat.io/ubi8/ruby-31:latest"),
("3.0-ubi9", "registry.redhat.io/ubi9/ruby-30:latest"),
("2.5-ubi8", "registry.redhat.io/ubi8/ruby-25:latest"),
],
)
def test_package_imagestream(self, version, registry):
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
assert self.hc_api.check_imagestreams(version=version, registry=registry)
78 changes: 78 additions & 0 deletions test/test_helm_ruby_rails_application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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 TestHelmCakePHPTemplate:

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")
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
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example")
assert self.hc_api.test_helm_curl_output(
route_name="rails-example",
expected_str="Welcome to your Rails application"
)

def test_by_helm_test(self):
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
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example")
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Rails application"])

0 comments on commit a02bea5

Please sign in to comment.