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

Add Helm chart tests for PSQL #591

Merged
merged 1 commit into from
Sep 16, 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
2 changes: 1 addition & 1 deletion test/run-openshift-pytest
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ THISDIR=$(dirname ${BASH_SOURCE[0]})

git show -s

cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_postgresql_*.py
cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_*.py
47 changes: 47 additions & 0 deletions test/test_helm_postgresql_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 TestHelmRHELPostgresqlImageStreams:

def setup_method(self):
package_name = "postgresql-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,expected",
[
("10-el8", "registry.redhat.io/rhel8/postgresql-10:latest", False),
("13-el8", "registry.redhat.io/rhel8/postgresql-13:latest", True),
("13-el9", "registry.redhat.io/rhel9/postgresql-13:latest", True),
("15-el8", "registry.redhat.io/rhel8/postgresql-15:latest", True),
("15-el9", "registry.redhat.io/rhel9/postgresql-15:latest", True),
("16-el8", "registry.redhat.io/rhel8/postgresql-16:latest", True),
("16-el9", "registry.redhat.io/rhel9/postgresql-16:latest", True),
],
)
def test_package_imagestream(self, version, registry, expected):
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected
56 changes: 56 additions & 0 deletions test/test_helm_postgresql_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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": "-el8",
"rhel9": "-el9"
}
TAG = TAGS.get(OS, None)


class TestHelmPostgresqlPersistent:

def setup_method(self):
package_name = "postgresql-persistent"
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(self):
self.hc_api.package_name = "postgresql-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "postgresql-persistent"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
".image.tag": f"{VERSION}{TAG}",
".namespace": self.hc_api.namespace
}
)
assert self.hc_api.is_pod_running(pod_name_prefix="postgresql-persistent")
assert self.hc_api.test_helm_chart(expected_str=["accepting connection"])