|
| 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