Skip to content

Commit 22773e9

Browse files
committed
Add Helm chart tests for PSQL
We need to test if helm charts work in postgresql container Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent a101cde commit 22773e9

File tree

3 files changed

+104
-1
lines changed

3 files changed

+104
-1
lines changed

test/run-openshift-pytest

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ THISDIR=$(dirname ${BASH_SOURCE[0]})
1010

1111
git show -s
1212

13-
cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_postgresql_*.py
13+
cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_*.py
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
16+
17+
18+
class TestHelmRHELPostgresqlImageStreams:
19+
20+
def setup_method(self):
21+
package_name = "postgresql-imagestreams"
22+
path = test_dir
23+
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
24+
self.hc_api.clone_helm_chart_repo(
25+
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
26+
subdir="charts/redhat"
27+
)
28+
29+
def teardown_method(self):
30+
self.hc_api.delete_project()
31+
32+
@pytest.mark.parametrize(
33+
"version,registry,expected",
34+
[
35+
("10-el8", "registry.redhat.io/rhel8/postgresql-10:latest", False),
36+
("13-el8", "registry.redhat.io/rhel8/postgresql-13:latest", True),
37+
("13-el9", "registry.redhat.io/rhel9/postgresql-13:latest", True),
38+
("15-el8", "registry.redhat.io/rhel8/postgresql-15:latest", True),
39+
("15-el9", "registry.redhat.io/rhel9/postgresql-15:latest", True),
40+
("16-el8", "registry.redhat.io/rhel8/postgresql-16:latest", True),
41+
("16-el9", "registry.redhat.io/rhel9/postgresql-16:latest", True),
42+
],
43+
)
44+
def test_package_imagestream(self, version, registry, expected):
45+
assert self.hc_api.helm_package()
46+
assert self.hc_api.helm_installation()
47+
assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected

test/test_helm_postgresql_template.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
16+
17+
18+
VERSION = os.getenv("VERSION")
19+
IMAGE_NAME = os.getenv("IMAGE_NAME")
20+
OS = os.getenv("TARGET")
21+
22+
TAGS = {
23+
"rhel8": "-el8",
24+
"rhel9": "-el9"
25+
}
26+
TAG = TAGS.get(OS, None)
27+
28+
29+
class TestHelmPostgresqlPersistent:
30+
31+
def setup_method(self):
32+
package_name = "postgresql-persistent"
33+
path = test_dir
34+
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
35+
self.hc_api.clone_helm_chart_repo(
36+
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
37+
subdir="charts/redhat"
38+
)
39+
40+
def teardown_method(self):
41+
self.hc_api.delete_project()
42+
43+
def test_package_persistent(self):
44+
self.hc_api.package_name = "postgresql-imagestreams"
45+
assert self.hc_api.helm_package()
46+
assert self.hc_api.helm_installation()
47+
self.hc_api.package_name = "postgresql-persistent"
48+
assert self.hc_api.helm_package()
49+
assert self.hc_api.helm_installation(
50+
values={
51+
".image.tag": f"{VERSION}{TAG}",
52+
".namespace": self.hc_api.namespace
53+
}
54+
)
55+
assert self.hc_api.is_pod_running(pod_name_prefix="postgresql-persistent")
56+
assert self.hc_api.test_helm_chart(expected_str=["accepting connection"])

0 commit comments

Comments
 (0)