|
1 | | -import os |
2 | | -import sys |
3 | | - |
4 | 1 | import pytest |
5 | 2 |
|
6 | 3 | from container_ci_suite.openshift import OpenShiftAPI |
7 | | -from container_ci_suite.utils import check_variables |
8 | | - |
9 | | -from constants import TAGS |
10 | | - |
11 | | -if not check_variables(): |
12 | | - print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") |
13 | | - sys.exit(1) |
14 | | - |
15 | 4 |
|
16 | | -VERSION = os.getenv("VERSION") |
17 | | -IMAGE_NAME = os.getenv("IMAGE_NAME") |
18 | | -OS = os.getenv("TARGET") |
19 | | - |
20 | | -TAG = TAGS.get(OS) |
| 5 | +from conftest import VARS |
21 | 6 |
|
22 | 7 |
|
23 | 8 | class TestPostgreSQLDeployTemplate: |
24 | | - |
25 | 9 | def setup_method(self): |
26 | | - self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql-testing", version=VERSION, shared_cluster=True) |
| 10 | + self.oc_api = OpenShiftAPI( |
| 11 | + pod_name_prefix="postgresql-testing", |
| 12 | + version=VARS.VERSION, |
| 13 | + shared_cluster=True, |
| 14 | + ) |
27 | 15 |
|
28 | 16 | def teardown_method(self): |
29 | 17 | self.oc_api.delete_project() |
30 | 18 |
|
31 | 19 | @pytest.mark.parametrize( |
32 | 20 | "template", |
33 | | - [ |
34 | | - "postgresql-ephemeral-template.json", |
35 | | - "postgresql-persistent-template.json" |
36 | | - ] |
| 21 | + ["postgresql-ephemeral-template.json", "postgresql-persistent-template.json"], |
37 | 22 | ) |
38 | 23 | def test_psql_template_inside_cluster(self, template): |
39 | | - short_version = VERSION.replace(".", "") |
| 24 | + short_version = VARS.VERSION.replace(".", "") |
40 | 25 | assert self.oc_api.deploy_template_with_image( |
41 | | - image_name=IMAGE_NAME, |
| 26 | + image_name=VARS.IMAGE_NAME, |
42 | 27 | template=f"examples/{template}", |
43 | 28 | name_in_template="postgresql", |
44 | 29 | openshift_args=[ |
45 | | - f"POSTGRESQL_VERSION={VERSION}", |
| 30 | + f"POSTGRESQL_VERSION={VARS.VERSION}", |
46 | 31 | f"DATABASE_SERVICE_NAME={self.oc_api.pod_name_prefix}", |
47 | | - f"POSTGRESQL_USER=testu", |
48 | | - f"POSTGRESQL_PASSWORD=testp", |
49 | | - f"POSTGRESQL_DATABASE=testdb" |
50 | | - ] |
| 32 | + "POSTGRESQL_USER=testu", |
| 33 | + "POSTGRESQL_PASSWORD=testp", |
| 34 | + "POSTGRESQL_DATABASE=testdb", |
| 35 | + ], |
51 | 36 | ) |
52 | 37 |
|
53 | 38 | assert self.oc_api.is_pod_running(pod_name_prefix=self.oc_api.pod_name_prefix) |
54 | 39 | assert self.oc_api.check_command_internal( |
55 | | - image_name=f"registry.redhat.io/{OS}/postgresql-{short_version}", |
| 40 | + image_name=f"registry.redhat.io/{VARS.OS}/postgresql-{short_version}", |
56 | 41 | service_name=self.oc_api.pod_name_prefix, |
57 | 42 | cmd="PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb", |
58 | | - expected_output="accepting connections" |
| 43 | + expected_output="accepting connections", |
59 | 44 | ) |
0 commit comments