Skip to content

Commit

Permalink
Add testing httpd-container also by Helm Charts
Browse files Browse the repository at this point in the history
Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek committed Sep 3, 2024
1 parent 379b278 commit f6e53c9
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 1 deletion.
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: 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
2 changes: 1 addition & 1 deletion test/run-openshift-pytest
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

THISDIR=$(dirname ${BASH_SOURCE[0]})

cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_httpd*.py
cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_httpd_h*.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"])

0 comments on commit f6e53c9

Please sign in to comment.