Skip to content

Commit

Permalink
Add helm charts tests into s2i-nodejs-container.
Browse files Browse the repository at this point in the history
We need to check by each PR, that also helm charts are working properly.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
  • Loading branch information
phracek committed Sep 16, 2024
1 parent 60426f6 commit 429c86a
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
74 changes: 74 additions & 0 deletions test/test_helm_nodejs_application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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 TestHelmNodeJSApplication:

def setup_method(self):
package_name = "nodejs-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 = "nodejs-imagestreams"
self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "nodejs-application"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"nodejs_version": f"{VERSION}{TAG}",
"namespace": self.hc_api.namespace
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="nodejs-example")
assert self.hc_api.test_helm_curl_output(
route_name="nodejs-example",
expected_str="Node.js Crud Application"
)

def test_by_helm_test(self):
self.hc_api.package_name = "nodejs-imagestreams"
self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "nodejs-application"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"nodejs": f"{VERSION}{TAG}",
"namespace": self.hc_api.namespace
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="nodejs-example")
assert self.hc_api.test_helm_chart(expected_str=["Node.js Crud Application"])
47 changes: 47 additions & 0 deletions test/test_helm_nodejs_imagestreams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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__)))


class TestHelmRHELNodeJSImageStreams:

def setup_method(self):
package_name = "nodejs-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",
[
("20-ubi9", "registry.redhat.io/ubi9/nodejs-20:latest"),
("20-ubi9-minimal", "registry.redhat.io/ubi9/nodejs-20-minimal:latest"),
("20-ubi8", "registry.redhat.io/ubi8/nodejs-20:latest"),
("20-ubi8-minimal", "registry.redhat.io/ubi8/nodejs-20-minimal:latest"),
("18-ubi9", "registry.redhat.io/ubi9/nodejs-18:latest"),
("18-ubi9-minimal", "registry.redhat.io/ubi9/nodejs-18-minimal:latest"),
("18-ubi8", "registry.redhat.io/ubi8/nodejs-18:latest"),
("18-ubi8-minimal", "registry.redhat.io/ubi8/nodejs-18-minimal: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)

0 comments on commit 429c86a

Please sign in to comment.