Skip to content

Commit a02bea5

Browse files
committed
Add support for testing Helm Charts from https://github.com/sclorg/helm-charts
repository in s2i-ruby-container. Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent adfd752 commit a02bea5

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

test/test_helm_ruby_imagestreams.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import os
2+
import sys
3+
4+
import pytest
5+
6+
from pathlib import Path
7+
8+
from container_ci_suite.helm import HelmChartsAPI
9+
from container_ci_suite.utils import check_variables
10+
11+
if not check_variables():
12+
print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
13+
sys.exit(1)
14+
15+
16+
test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
17+
18+
19+
VERSION = os.getenv("VERSION")
20+
IMAGE_NAME = os.getenv("IMAGE_NAME")
21+
OS = os.getenv("TARGET")
22+
23+
24+
class TestHelmRHELRubyImageStreams:
25+
26+
def setup_method(self):
27+
package_name = "ruby-imagestreams"
28+
path = test_dir
29+
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
30+
self.hc_api.clone_helm_chart_repo(
31+
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
32+
subdir="charts/redhat"
33+
)
34+
35+
def teardown_method(self):
36+
self.hc_api.delete_project()
37+
38+
@pytest.mark.parametrize(
39+
"version,registry",
40+
[
41+
("3.3-ubi9", "registry.redhat.io/ubi9/ruby-33:latest"),
42+
("3.3-ubi8", "registry.redhat.io/ubi8/ruby-33:latest"),
43+
("3.1-ubi9", "registry.redhat.io/ubi9/ruby-31:latest"),
44+
("3.1-ubi8", "registry.redhat.io/ubi8/ruby-31:latest"),
45+
("3.0-ubi9", "registry.redhat.io/ubi9/ruby-30:latest"),
46+
("2.5-ubi8", "registry.redhat.io/ubi8/ruby-25:latest"),
47+
],
48+
)
49+
def test_package_imagestream(self, version, registry):
50+
assert self.hc_api.helm_package()
51+
assert self.hc_api.helm_installation()
52+
assert self.hc_api.check_imagestreams(version=version, registry=registry)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import os
2+
import sys
3+
4+
import pytest
5+
6+
from pathlib import Path
7+
8+
from container_ci_suite.helm import HelmChartsAPI
9+
from container_ci_suite.utils import check_variables
10+
11+
if not check_variables():
12+
print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
13+
sys.exit(1)
14+
15+
16+
test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
17+
18+
19+
VERSION = os.getenv("VERSION")
20+
IMAGE_NAME = os.getenv("IMAGE_NAME")
21+
OS = os.getenv("TARGET")
22+
23+
24+
TAGS = {
25+
"rhel8": "-ubi8",
26+
"rhel9": "-ubi9"
27+
}
28+
TAG = TAGS.get(OS, None)
29+
30+
31+
class TestHelmCakePHPTemplate:
32+
33+
def setup_method(self):
34+
package_name = "ruby-rails-application"
35+
path = test_dir
36+
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
37+
self.hc_api.clone_helm_chart_repo(
38+
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
39+
subdir="charts/redhat"
40+
)
41+
42+
def teardown_method(self):
43+
self.hc_api.delete_project()
44+
45+
def test_curl_connection(self):
46+
if self.hc_api.oc_api.shared_cluster:
47+
pytest.skip("Do NOT test on shared cluster")
48+
self.hc_api.package_name = "ruby-imagestreams"
49+
assert self.hc_api.helm_package()
50+
assert self.hc_api.helm_installation()
51+
self.hc_api.package_name = "ruby-rails-application"
52+
assert self.hc_api.helm_package()
53+
assert self.hc_api.helm_installation(
54+
values={
55+
"ruby_version": f"{VERSION}{TAG}",
56+
"namespace": self.hc_api.namespace
57+
}
58+
)
59+
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example")
60+
assert self.hc_api.test_helm_curl_output(
61+
route_name="rails-example",
62+
expected_str="Welcome to your Rails application"
63+
)
64+
65+
def test_by_helm_test(self):
66+
self.hc_api.package_name = "ruby-imagestreams"
67+
assert self.hc_api.helm_package()
68+
assert self.hc_api.helm_installation()
69+
self.hc_api.package_name = "ruby-rails-application"
70+
assert self.hc_api.helm_package()
71+
assert self.hc_api.helm_installation(
72+
values={
73+
"ruby_version": f"{VERSION}{TAG}",
74+
"namespace": self.hc_api.namespace
75+
}
76+
)
77+
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example")
78+
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Rails application"])

0 commit comments

Comments
 (0)