-
Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathtest_helm_python_django_app.py
89 lines (76 loc) · 3.08 KB
/
test_helm_python_django_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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")
OS = os.getenv("TARGET")
TAGS = {
"rhel8": "-ubi8",
"rhel9": "-ubi9",
"rhel10": "-ubi10",
}
TAG = TAGS.get(OS, None)
DEPLOYED_PSQL_IMAGE = "quay.io/centos7/postgresql-10-centos7:centos7"
IMAGE_TAG = "postgresql:10"
PSQL_VERSION = "10"
if VERSION == "3.11" or VERSION == "3.12":
DEPLOYED_PSQL_IMAGE = "quay.io/sclorg/postgresql-12-c8s"
IMAGE_TAG = "postgresql:12"
PSQL_VERSION = "12"
BRANCH_TO_TEST = "master"
if VERSION == "3.11" or VERSION == "3.12":
BRANCH_TO_TEST = "4.2.x"
class TestHelmPythonDjangoAppTemplate:
def setup_method(self):
package_name = "redhat-python-django-application"
path = test_dir
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=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_django_application_curl_output(self):
if self.hc_api.oc_api.shared_cluster:
pytest.skip("Do NOT test on shared cluster")
new_version = VERSION
if "minimal" in VERSION:
new_version = VERSION.replace("-minimal", "")
self.hc_api.package_name = "redhat-python-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "redhat-python-django-application"
self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"python_version": f"{new_version}{TAG}",
"namespace": self.hc_api.namespace,
"source_repository_ref": BRANCH_TO_TEST,
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-example")
assert self.hc_api.test_helm_curl_output(
route_name="django-example",
expected_str="Welcome to your Django application"
)
def test_django_application_helm_test(self):
new_version = VERSION
if "minimal" in VERSION:
new_version = VERSION.replace("-minimal", "")
self.hc_api.package_name = "redhat-python-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "redhat-python-django-application"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"python_version": f"{new_version}{TAG}",
"namespace": self.hc_api.namespace,
"source_repository_ref": BRANCH_TO_TEST,
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-example")
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Django application"])