-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathtest_mariadb_local_template.py
65 lines (53 loc) · 1.98 KB
/
test_mariadb_local_template.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
import os
import sys
import pytest
from container_ci_suite.openshift import OpenShiftAPI
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)
VERSION = os.getenv("VERSION")
IMAGE_NAME = os.getenv("IMAGE_NAME")
OS = os.getenv("TARGET")
TAGS = {
"rhel8": "-el8",
"rhel9": "-el9",
"rhel10": "-el10",
}
TAG = TAGS.get(OS, None)
class TestMariaDBDeployTemplate:
def setup_method(self):
self.oc_api = OpenShiftAPI(pod_name_prefix="mariadb-testing", version=VERSION, shared_cluster=True)
self.oc_api.import_is("imagestreams/mariadb-rhel.json", "", skip_check=True)
def teardown_method(self):
self.oc_api.delete_project()
@pytest.mark.parametrize(
"template",
[
"mariadb-ephemeral-template.json",
"mariadb-persistent-template.json"
]
)
def test_python_template_inside_cluster(self, template):
if OS == "rhel10":
pytest.skip("Skipping test for rhel10")
short_version = VERSION.replace(".", "")
assert self.oc_api.deploy_template_with_image(
image_name=IMAGE_NAME,
template=template,
name_in_template="mariadb",
openshift_args=[
f"MARIADB_VERSION={VERSION}{TAG}",
f"DATABASE_SERVICE_NAME={self.oc_api.pod_name_prefix}",
f"MYSQL_USER=testu",
f"MYSQL_PASSWORD=testp",
f"MYSQL_DATABASE=testdb"
]
)
assert self.oc_api.is_pod_running(pod_name_prefix=self.oc_api.pod_name_prefix)
assert self.oc_api.check_command_internal(
image_name=f"registry.redhat.io/{OS}/mariadb-{short_version}",
service_name=self.oc_api.pod_name_prefix,
cmd="echo 'SELECT 42 as testval\\g' | mysql --connect-timeout=15 -h <IP> testdb -utestu -ptestp",
expected_output="42"
)