-
Notifications
You must be signed in to change notification settings - Fork 329
/
Copy pathtest_shared_helm_cakephp_application.py
97 lines (82 loc) · 3.32 KB
/
test_shared_helm_cakephp_application.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
90
91
92
93
94
95
96
97
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")
if VERSION == "7.4" or VERSION == "8.0":
check_msg = "Welcome to CakePHP"
elif VERSION == "8.1" or VERSION == "8.2" or VERSION == "8.3":
check_msg = "Welcome to CakePHP"
else:
check_msg = "Welcome to your CakePHP application on OpenShift"
TAGS = {
"rhel8": "-ubi8",
"rhel9": "-ubi9"
}
TAG = TAGS.get(OS, None)
class TestHelmCakePHPTemplate:
def setup_method(self):
package_name = "redhat-php-cakephp-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_curl_connection(self):
branch_to_test = "4.X"
check_msg = "Welcome to CakePHP"
if self.hc_api.shared_cluster:
pytest.skip("Do NOT test on shared cluster")
if VERSION.startswith("8.2") or VERSION.startswith("8.3"):
branch_to_test = "5.X"
check_msg = "Welcome to CakePHP"
self.hc_api.package_name = "redhat-php-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "redhat-php-cakephp-application"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"php_version": f"{VERSION}{TAG}",
"namespace": self.hc_api.namespace,
"source_repository_ref": branch_to_test,
"name": "cakephp-example"
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="cakephp-example", timeout=300)
assert self.hc_api.oc_api.check_response_inside_cluster(
name_in_template="cakephp-example",
expected_output=check_msg,
)
def test_by_helm_test(self):
branch_to_test = "4.X"
check_msg = "Welcome to CakePHP"
if VERSION.startswith("8.2") or VERSION.startswith("8.3"):
branch_to_test = "5.X"
check_msg = "Welcome to CakePHP"
self.hc_api.package_name = "redhat-php-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "redhat-php-cakephp-application"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"php_version": f"{VERSION}{TAG}",
"namespace": self.hc_api.namespace,
"source_repository_ref": branch_to_test,
"name": "cakephp-example"
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="cakephp-example", timeout=300)
assert self.hc_api.test_helm_chart(expected_str=[check_msg])