Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support testing helm charts #225

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion 2.4-micro/test/run-openshift

This file was deleted.

1 change: 1 addition & 0 deletions 2.4-micro/test/test_httpd_helm_chart_imagestreams.py
1 change: 1 addition & 0 deletions 2.4-micro/test/test_httpd_helm_chart_template.py
1 change: 0 additions & 1 deletion 2.4/test/run-openshift

This file was deleted.

1 change: 1 addition & 0 deletions 2.4/test/test_httpd_helm_chart_imagestreams.py
1 change: 1 addition & 0 deletions 2.4/test/test_httpd_helm_chart_template.py
65 changes: 65 additions & 0 deletions test/test_httpd_helm_chart_imagestreams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import os

import pytest
from pathlib import Path

from container_ci_suite.helm import HelmChartsAPI

test_dir = Path(os.path.abspath(os.path.dirname(__file__)))


class TestHelmRHELHttpdImageStreams:

def setup_method(self):
package_name = "httpd-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",
[
("2.4-ubi9", "registry.redhat.io/ubi9/httpd-24:latest"),
("2.4-ubi8", "registry.redhat.io/ubi8/httpd-24:latest"),
("2.4-el8", "registry.redhat.io/rhel8/httpd-24"),
("2.4-el9", "registry.redhat.io/rhel9/httpd-24"),
],
)
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)


class TestHelmCentOSHttpdImagestreams:
def setup_method(self):
package_name = "httpd-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/centos"
)

def teardown_method(self):
self.hc_api.delete_project()

@pytest.mark.parametrize(
"version,registry",
[
("2.4-ubi9", "registry.access.redhat.com/ubi9/httpd-24:latest"),
("2.4-ubi8", "registry.access.redhat.com/ubi8/httpd-24:latest"),
("2.4-el8", "quay.io/sclorg/httpd-24-c8s:latest"),
("2.4-el9", "quay.io/sclorg/httpd-24-c9s: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)
76 changes: 76 additions & 0 deletions test/test_httpd_helm_chart_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import os

import pytest
from pathlib import Path

from container_ci_suite.helm import HelmChartsAPI

test_dir = Path(os.path.abspath(os.path.dirname(__file__)))

VERSION = os.getenv("VERSION")
IMAGE_NAME = os.getenv("IMAGE_NAME")
BRANCH_TO_TEST = "master"
OS = os.getenv("OS")

TAGS = {
"rhel8": "-el8",
"rhel9": "-el9"
}

TAG = TAGS.get(OS, None)


class TestHelmHTTPDTemplate:

def setup_method(self):
package_name = "httpd-template"
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_package_persistent_by_curl(self):
if self.hc_api.oc_api.shared_cluster:
pytest.skip("Do NOT test on shared cluster")
new_version = VERSION
if "micro" in VERSION:
new_version = VERSION.replace("-micro", "")
self.hc_api.package_name = "httpd-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "httpd-template"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"httpd_version": f"{new_version}{TAG}",
"namespace": self.hc_api.namespace
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="httpd-example")
assert self.hc_api.test_helm_curl_output(
route_name="httpd-example",
expected_str="Welcome to your static httpd application on OpenShift"
)

def test_package_persistent_by_helm_chart_test(self):
new_version = VERSION
if "micro" in VERSION:
new_version = VERSION.replace("-micro", "")
self.hc_api.package_name = "httpd-imagestreams"
self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "httpd-template"
self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"httpd_version": f"{new_version}{TAG}",
"namespace": self.hc_api.namespace
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="httpd-example")
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your static httpd application on OpenShift"])