|
| 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="20-ubi8" |
| 13 | + |
| 14 | +class TestNodeJSAppPostgreSQLExTemplate: |
| 15 | + |
| 16 | + def setup_method(self): |
| 17 | + self.oc_api = OpenShiftAPI(pod_name_prefix="nodejs-example") |
| 18 | + json_raw_file = self.oc_api.get_raw_url_for_json( |
| 19 | + container="s2i-nodejs-container", dir="imagestreams", filename="nodejs-rhel.json" |
| 20 | + ) |
| 21 | + self.oc_api.import_is(path=json_raw_file, name="node") |
| 22 | + json_raw_file = self.oc_api.get_raw_url_for_json( |
| 23 | + container="postgresql-container", dir="imagestreams", filename="postgresql-rhel.json" |
| 24 | + ) |
| 25 | + self.oc_api.import_is(path=json_raw_file, name="postgresql") |
| 26 | + |
| 27 | + def teardown_method(self): |
| 28 | + self.oc_api.delete_project() |
| 29 | + |
| 30 | + def test_local_template_inside_cluster(self): |
| 31 | + expected_output = "Node.js Crud Application" |
| 32 | + template_json = "../openshift/templates/nodejs-postgresql-persistent.json" |
| 33 | + assert self.oc_api.deploy_template( |
| 34 | + template=template_json, name_in_template="nodejs-example", expected_output=expected_output, |
| 35 | + openshift_args=[ |
| 36 | + "SOURCE_REPOSITORY_REF=master", |
| 37 | + f"NODEJS_VERSION={VERSION}", |
| 38 | + "NAME=nodejs-example", |
| 39 | + "POSTGRESQL_VERSION=12-el8" |
| 40 | + ] |
| 41 | + ) |
| 42 | + assert self.oc_api.template_deployed(name_in_template="nodejs-example") |
| 43 | + assert self.oc_api.check_response_inside_cluster( |
| 44 | + name_in_template="nodejs-example", expected_output=expected_output |
| 45 | + ) |
| 46 | + |
| 47 | + |
| 48 | + def test_remote_template_inside_cluster(self): |
| 49 | + expected_output = "Node.js Crud Application" |
| 50 | + template_json = self.oc_api.get_raw_url_for_json( |
| 51 | + container="nodejs-ex", dir="openshift/templates", filename="nodejs-postgresql-persistent.json" |
| 52 | + ) |
| 53 | + assert self.oc_api.deploy_template( |
| 54 | + template=template_json, name_in_template="dancer-example", expected_output=expected_output, |
| 55 | + openshift_args=[ |
| 56 | + "SOURCE_REPOSITORY_REF=master", |
| 57 | + f"NODEJS_VERSION={VERSION}", |
| 58 | + "NAME=nodejs-example", |
| 59 | + "POSTGRESQL_VERSION=12-el8" |
| 60 | + ] |
| 61 | + ) |
| 62 | + assert self.oc_api.template_deployed(name_in_template="nodejs-example") |
| 63 | + assert self.oc_api.check_response_inside_cluster( |
| 64 | + name_in_template="nodejs-example", expected_output=expected_output |
| 65 | + ) |
| 66 | + |
| 67 | + def test_remote_template_by_request(self): |
| 68 | + expected_output = "Node.js Crud Application" |
| 69 | + template_json = self.oc_api.get_raw_url_for_json( |
| 70 | + container="nodejs-ex", dir="openshift/templates", filename="nodejs-postgresql-persistent.json" |
| 71 | + ) |
| 72 | + assert self.oc_api.deploy_template( |
| 73 | + template=template_json, name_in_template="nodejs-example", expected_output=expected_output, |
| 74 | + openshift_args=[ |
| 75 | + "SOURCE_REPOSITORY_REF=master", |
| 76 | + f"NODEJS_VERSION={VERSION}", |
| 77 | + "NAME=nodejs-example", |
| 78 | + "POSTGRESQL_VERSION=12-el8" |
| 79 | + ] |
| 80 | + ) |
| 81 | + assert self.oc_api.template_deployed(name_in_template="nodejs-example") |
| 82 | + assert self.oc_api.check_response_outside_cluster( |
| 83 | + name_in_template="nodejs-example", expected_output=expected_output |
| 84 | + ) |
0 commit comments