Skip to content

Commit ac38f6f

Browse files
authored
Merge pull request #33 from sclorg/add_tests
Add nginx-ex tests executed on OpenShift 4
2 parents fc389c5 + f0aee90 commit ac38f6f

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

.github/workflows/openshift-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
version: [ "1.20-ubi7", "1.20-ubi8", "1.22-ubi8", "1.20-ubi9", "1.22-ubi9" ]
13+
version: [ "1.20-ubi7", "1.22-ubi8", "1.20-ubi9", "1.22-ubi9" ]
1414

1515
if: |
1616
github.event.issue.pull_request

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.22-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)