Skip to content

Commit fe88fb9

Browse files
committed
Add nginx-ex tests executed on OpenShift 4
Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent fc389c5 commit fe88fb9

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.PHONY: test-openshift-4
2+
test-openshift-4:
3+
cd tests && PYTHONPATH=$(CURDIR) python3 -m pytest --verbose --color=yes --showlocals .

tests/test_nginx.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import os
2+
3+
import pytest
4+
from pathlib import Path
5+
6+
from container_ci_suite.openshift import OpenShiftAPI
7+
8+
test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
9+
10+
VERSION=os.getenv("SINGLE_VERSION")
11+
if not VERSION:
12+
VERSION="1.20-ubi8"
13+
14+
class TestNginxExTemplate:
15+
16+
def setup_method(self):
17+
self.oc_api = OpenShiftAPI(pod_name_prefix="nginx-example")
18+
json_raw_file = self.oc_api.get_raw_url_for_json(
19+
container="nginx-container", dir="imagestreams", filename="nginx-rhel.json"
20+
)
21+
self.oc_api.import_is(path=json_raw_file, name="nginx")
22+
23+
def teardown_method(self):
24+
self.oc_api.delete_project()
25+
26+
def test_template_inside_cluster(self):
27+
template_json = self.oc_api.get_raw_url_for_json(
28+
container="nginx-ex", dir="openshift/templates", filename="nginx.json"
29+
)
30+
assert self.oc_api.deploy_template(
31+
template=template_json, name_in_template="nginx-example", expected_output="Welcome to your static nginx application",
32+
openshift_args=["SOURCE_REPOSITORY_REF=master", f"NGINX_VERSION={VERSION}", "NAME=nginx-example"]
33+
)
34+
assert self.oc_api.template_deployed(name_in_template="nginx-example")
35+
assert self.oc_api.check_response_inside_cluster(
36+
name_in_template="nginx-example", expected_output="Welcome to your static nginx application"
37+
)
38+
39+
def test_template_by_request(self):
40+
template_json = self.oc_api.get_raw_url_for_json(
41+
container="nginx-ex", dir="openshift/templates", filename="nginx.json"
42+
)
43+
assert self.oc_api.deploy_template(
44+
template=template_json, name_in_template="nginx-example", expected_output="Welcome to your static nginx application",
45+
openshift_args=["SOURCE_REPOSITORY_REF=master", f"NGINX_VERSION={VERSION}", "NAME=nginx-example"]
46+
)
47+
assert self.oc_api.template_deployed(name_in_template="nginx-example")
48+
assert self.oc_api.check_response_outside_cluster(
49+
name_in_template="nginx-example", expected_output="Welcome to your static nginx application"
50+
)

0 commit comments

Comments
 (0)