Skip to content

Commit 60a698c

Browse files
authored
Merge pull request #162 from sclorg/fix_tests
Fix test suite for testing PHP application
2 parents 366dd76 + e51c66d commit 60a698c

File tree

3 files changed

+16
-112
lines changed

3 files changed

+16
-112
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
.PHONY: test-openshift-4
2-
test-openshift-4:
3-
cd tests && PYTHONPATH=$(CURDIR) python3 -m pytest --verbose --color=yes --showlocals .
1+
.PHONY: test-openshift-pytest
2+
test-openshift-pytest:
3+
cd tests && PYTHONPATH=$(CURDIR) python3.12 -m pytest -s -rA --showlocals -vv test_cakephp.py

tests/test_cakephp.py

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,18 @@ def setup_method(self):
1818
self.oc_api = OpenShiftAPI(pod_name_prefix="cakephp-example")
1919
json_raw_file = self.oc_api.get_raw_url_for_json(container="s2i-php-container", dir="imagestreams",
2020
filename="php-rhel.json")
21-
self.oc_api.import_is(path=json_raw_file, name="php")
21+
self.oc_api.import_is(path=json_raw_file, name="php", skip_check=True)
2222

2323
def teardown_method(self):
2424
self.oc_api.delete_project()
2525

26-
def test_local_template_inside_cluster(self):
27-
branch_to_test = "master"
28-
expected_output = "Welcome to PHP"
29-
if VERSION.startswith("7.4") or VERSION.startswith("8.0"):
30-
branch_to_test = "4.X"
31-
expected_output = "Welcome to CakePHP 4"
32-
if VERSION.startswith("8.1") or VERSION.startswith("8.2"):
33-
branch_to_test = "5.X"
34-
expected_output = "Welcome to CakePHP 5"
35-
36-
template_json = "../openshift/templates/cakephp.json"
37-
assert self.oc_api.deploy_template(
38-
template=template_json, name_in_template="cakephp-example", expected_output=expected_output,
39-
openshift_args=[
40-
f"SOURCE_REPOSITORY_REF={branch_to_test}",
41-
f"PHP_VERSION={VERSION}",
42-
"NAME=cakephp-example"
43-
]
44-
)
45-
assert self.oc_api.template_deployed(name_in_template="cakephp-example")
46-
assert self.oc_api.check_response_inside_cluster(
47-
name_in_template="cakephp-example", expected_output=expected_output
48-
)
49-
5026
def test_remote_template_inside_cluster(self):
5127
branch_to_test = "master"
5228
expected_output = "Welcome to PHP"
5329
if VERSION.startswith("7.4") or VERSION.startswith("8.0"):
5430
branch_to_test = "4.X"
5531
expected_output = "Welcome to CakePHP 4"
56-
if VERSION.startswith("8.1") or VERSION.startswith("8.2"):
32+
if VERSION.startswith("8.1") or VERSION.startswith("8.2") or VERSION.startswith("8.3"):
5733
branch_to_test = "5.X"
5834
expected_output = "Welcome to CakePHP 5"
5935

@@ -64,30 +40,7 @@ def test_remote_template_inside_cluster(self):
6440
template=template_json, name_in_template="cakephp-example", expected_output=expected_output,
6541
openshift_args=[f"SOURCE_REPOSITORY_REF={branch_to_test}", f"PHP_VERSION={VERSION}", "NAME=cakephp-example"]
6642
)
67-
assert self.oc_api.template_deployed(name_in_template="cakephp-example")
43+
assert self.oc_api.is_template_deployed(name_in_template="cakephp-example")
6844
assert self.oc_api.check_response_inside_cluster(
6945
name_in_template="cakephp-example", expected_output=expected_output
7046
)
71-
72-
def test_remote_template_by_request(self):
73-
branch_to_test = "master"
74-
expected_output = "Welcome to PHP"
75-
if VERSION.startswith("7.4") or VERSION.startswith("8.0"):
76-
branch_to_test = "4.X"
77-
expected_output = "Welcome to CakePHP 4"
78-
elif VERSION.startswith("8.1") or VERSION.startswith("8.2"):
79-
branch_to_test = "5.X"
80-
expected_output = "Welcome to CakePHP 5"
81-
82-
template_json = self.oc_api.get_raw_url_for_json(
83-
container="cakephp-ex", branch=branch_to_test, dir="openshift/templates", filename="cakephp.json"
84-
)
85-
assert self.oc_api.deploy_template(
86-
template=template_json, name_in_template="cakephp-example", expected_output=expected_output,
87-
openshift_args=[f"SOURCE_REPOSITORY_REF={branch_to_test}", f"PHP_VERSION={VERSION}", "NAME=cakephp-example"]
88-
)
89-
assert self.oc_api.template_deployed(name_in_template="cakephp-example")
90-
assert self.oc_api.check_response_outside_cluster(
91-
protocol="https",
92-
name_in_template="cakephp-example", expected_output=expected_output
93-
)

tests/test_cakephp_mysql.py

Lines changed: 10 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,24 @@ def setup_method(self):
1818
self.oc_api = OpenShiftAPI(pod_name_prefix="cakephp-example")
1919
json_raw_file = self.oc_api.get_raw_url_for_json(container="s2i-php-container", dir="imagestreams",
2020
filename="php-rhel.json")
21-
self.oc_api.import_is(path=json_raw_file, name="php")
21+
self.oc_api.import_is(path=json_raw_file, name="php", skip_check=True)
2222
json_raw_file = self.oc_api.get_raw_url_for_json(
2323
container="mysql-container", dir="imagestreams", filename="mysql-rhel.json"
2424
)
25-
self.oc_api.import_is(path=json_raw_file, name="mysql")
25+
self.oc_api.import_is(path=json_raw_file, name="mysql", skip_check=True)
2626

2727
def teardown_method(self):
2828
self.oc_api.delete_project()
2929

30-
def test_local_template_inside_cluster(self):
31-
branch_to_test = "master"
32-
expected_output = "Welcome to PHP"
33-
if VERSION.startswith("7.4") or VERSION.startswith("8.0"):
34-
branch_to_test = "4.X"
35-
expected_output = "Welcome to CakePHP 4"
36-
if VERSION.startswith("8.1") or VERSION.startswith("8.2"):
37-
branch_to_test = "5.X"
38-
expected_output = "Welcome to CakePHP 5"
39-
template_json = "../openshift/templates/cakephp-mysql-persistent.json"
40-
assert self.oc_api.deploy_template(
41-
template=template_json, name_in_template="cakephp-example", expected_output=expected_output,
42-
openshift_args=[
43-
f"SOURCE_REPOSITORY_REF={branch_to_test}",
44-
f"PHP_VERSION={VERSION}",
45-
"NAME=cakephp-example",
46-
"MYSQL_VERSION=8.0-el8"
47-
]
48-
)
49-
assert self.oc_api.template_deployed(name_in_template="cakephp-example")
50-
assert self.oc_api.check_response_inside_cluster(
51-
name_in_template="cakephp-example", expected_output=expected_output
52-
)
53-
5430
def test_remote_template_inside_cluster(self):
5531
branch_to_test = "master"
5632
expected_output = "Welcome to PHP"
5733
if VERSION.startswith("7.4") or VERSION.startswith("8.0"):
5834
branch_to_test = "4.X"
59-
expected_output = "Welcome to CakePHP 4"
60-
if VERSION.startswith("8.1") or VERSION.startswith("8.2"):
35+
expected_output = "Welcome to CakePHP"
36+
if VERSION.startswith("8.1") or VERSION.startswith("8.2") or VERSION.startswith("8.3"):
6137
branch_to_test = "5.X"
62-
expected_output = "Welcome to CakePHP 5"
38+
expected_output = "Welcome to CakePHP"
6339

6440
template_json = self.oc_api.get_raw_url_for_json(
6541
container="cakephp-ex", branch=branch_to_test, dir="openshift/templates", filename="cakephp-mysql-persistent.json"
@@ -70,38 +46,13 @@ def test_remote_template_inside_cluster(self):
7046
f"SOURCE_REPOSITORY_REF={branch_to_test}",
7147
f"PHP_VERSION={VERSION}",
7248
"NAME=cakephp-example",
73-
"MYSQL_VERSION=8.0-el8"
49+
"MYSQL_VERSION=8.0-el8",
50+
"DATABASE_USER=testu",
51+
"DATABASE_PASSWORD=testp",
52+
"DATABASE_NAME=mysql"
7453
]
7554
)
76-
assert self.oc_api.template_deployed(name_in_template="cakephp-example")
55+
assert self.oc_api.is_template_deployed(name_in_template="cakephp-example")
7756
assert self.oc_api.check_response_inside_cluster(
7857
name_in_template="cakephp-example", expected_output=expected_output
7958
)
80-
81-
def test_remote_template_by_request(self):
82-
branch_to_test = "master"
83-
expected_output = "Welcome to PHP"
84-
if VERSION.startswith("7.4") or VERSION.startswith("8.0"):
85-
branch_to_test = "4.X"
86-
expected_output = "Welcome to CakePHP 4"
87-
elif VERSION.startswith("8.1") or VERSION.startswith("8.2"):
88-
branch_to_test = "5.X"
89-
expected_output = "Welcome to CakePHP 5"
90-
91-
template_json = self.oc_api.get_raw_url_for_json(
92-
container="cakephp-ex", branch=branch_to_test, dir="openshift/templates", filename="cakephp-mysql-persistent.json"
93-
)
94-
assert self.oc_api.deploy_template(
95-
template=template_json, name_in_template="cakephp-example", expected_output=expected_output,
96-
openshift_args=[
97-
f"SOURCE_REPOSITORY_REF={branch_to_test}",
98-
f"PHP_VERSION={VERSION}",
99-
"NAME=cakephp-example",
100-
"MYSQL_VERSION=8.0-el8"
101-
]
102-
)
103-
assert self.oc_api.template_deployed(name_in_template="cakephp-example")
104-
assert self.oc_api.check_response_outside_cluster(
105-
protocol="https",
106-
name_in_template="cakephp-example", expected_output=expected_output
107-
)

0 commit comments

Comments
 (0)