Skip to content

Commit 1ef68a0

Browse files
committed
Rename test_* python files for OpenShift to test_ocp.
Also VARS.* variables are used during the migration. Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
1 parent 6d0f7d4 commit 1ef68a0

10 files changed

+168
-174
lines changed

test/test_deploy_templates.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

test/test_imagestreams_quickstart.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

test/test_ocp_deploy_templates.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import pytest
2+
3+
from container_ci_suite.openshift import OpenShiftAPI
4+
5+
from conftest import VARS
6+
7+
8+
class TestDeployTemplate:
9+
def setup_method(self):
10+
self.oc_api = OpenShiftAPI(
11+
pod_name_prefix=f"python-{VARS.SHORT_VERSION}-test",
12+
version=VARS.VERSION_NO_MINIMAL,
13+
shared_cluster=True,
14+
)
15+
16+
def teardown_method(self):
17+
self.oc_api.delete_project()
18+
19+
@pytest.mark.parametrize(
20+
"template", ["django-postgresql.json", "django-postgresql-persistent.json"]
21+
)
22+
def test_python_template_inside_cluster(self, template):
23+
assert self.oc_api.upload_image(VARS.DEPLOYED_PSQL_IMAGE, VARS.IMAGE_TAG)
24+
service_name = f"python-{VARS.SHORT_VERSION}-test"
25+
template_url = self.oc_api.get_raw_url_for_json(
26+
container="django-ex",
27+
dir="openshift/templates",
28+
filename=template,
29+
branch=VARS.BRANCH_TO_TEST,
30+
)
31+
assert self.oc_api.deploy_template_with_image(
32+
image_name=VARS.IMAGE_NAME,
33+
template=template_url,
34+
name_in_template="python",
35+
openshift_args=[
36+
f"SOURCE_REPOSITORY_REF={VARS.BRANCH_TO_TEST}",
37+
f"PYTHON_VERSION={VARS.VERSION_NO_MINIMAL}",
38+
f"NAME={service_name}",
39+
f"POSTGRESQL_VERSION={VARS.PSQL_VERSION}",
40+
],
41+
)
42+
assert self.oc_api.is_template_deployed(name_in_template=service_name)
43+
assert self.oc_api.check_response_inside_cluster(
44+
name_in_template=service_name,
45+
expected_output="Welcome to your Django application on OpenShift",
46+
)

test/test_helm_python_django_app.py renamed to test/test_ocp_helm_python_django_app.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,20 @@
22

33
from conftest import skip_helm_charts_tests, VARS
44

5-
DEPLOYED_PSQL_IMAGE = "quay.io/sclorg/postgresql-10-c8s:c8s"
6-
IMAGE_TAG = "postgresql:10"
7-
PSQL_VERSION = "10"
8-
BRANCH_TO_TEST = "2.2.x"
9-
10-
if VARS.VERSION in ("3.11", "3.12", "3.12-minimal"):
11-
DEPLOYED_PSQL_IMAGE = "quay.io/sclorg/postgresql-12-c8s"
12-
IMAGE_TAG = "postgresql:12"
13-
PSQL_VERSION = "12"
14-
BRANCH_TO_TEST = "4.2.x"
155

166
class TestHelmPythonDjangoAppTemplate:
17-
187
def setup_method(self):
198
package_name = "redhat-python-django-application"
20-
self.hc_api = HelmChartsAPI(path=VARS.TEST_DIR, package_name=package_name, tarball_dir=VARS.TEST_DIR, shared_cluster=True)
9+
self.hc_api = HelmChartsAPI(
10+
path=VARS.TEST_DIR,
11+
package_name=package_name,
12+
tarball_dir=VARS.TEST_DIR,
13+
shared_cluster=True,
14+
)
2115
self.hc_api.clone_helm_chart_repo(
22-
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
23-
subdir="charts/redhat"
16+
repo_url="https://github.com/sclorg/helm-charts",
17+
repo_name="helm-charts",
18+
subdir="charts/redhat",
2419
)
2520

2621
def teardown_method(self):
@@ -37,8 +32,10 @@ def test_django_application_helm_test(self):
3732
values={
3833
"python_version": f"{VARS.VERSION}{VARS.TAG}",
3934
"namespace": self.hc_api.namespace,
40-
"source_repository_ref": BRANCH_TO_TEST,
35+
"source_repository_ref": VARS.BRANCH_TO_TEST,
4136
}
4237
)
4338
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-example")
44-
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Django application"])
39+
assert self.hc_api.test_helm_chart(
40+
expected_str=["Welcome to your Django application"]
41+
)

test/test_helm_python_django_psql_persistent.py renamed to test/test_ocp_helm_python_django_psql_persistent.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
from conftest import skip_helm_charts_tests, VARS
44

5-
BRANCH_TO_TEST = "2.2.x"
6-
7-
if VARS.VERSION in ("3.11", "3.12", "3.12-minimal"):
8-
BRANCH_TO_TEST = "4.2.x"
9-
105

116
class TestHelmPythonDjangoPsqlTemplate:
12-
137
def setup_method(self):
148
package_name = "redhat-django-psql-persistent"
15-
self.hc_api = HelmChartsAPI(path=VARS.TEST_DIR, package_name=package_name, tarball_dir=VARS.TEST_DIR, shared_cluster=True)
9+
self.hc_api = HelmChartsAPI(
10+
path=VARS.TEST_DIR,
11+
package_name=package_name,
12+
tarball_dir=VARS.TEST_DIR,
13+
shared_cluster=True,
14+
)
1615
self.hc_api.clone_helm_chart_repo(
17-
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
18-
subdir="charts/redhat"
16+
repo_url="https://github.com/sclorg/helm-charts",
17+
repo_name="helm-charts",
18+
subdir="charts/redhat",
1919
)
2020

2121
def teardown_method(self):
@@ -35,8 +35,10 @@ def test_django_psql_helm_test(self):
3535
values={
3636
"python_version": f"{VARS.VERSION}{VARS.TAG}",
3737
"namespace": self.hc_api.namespace,
38-
"source_repository_ref": BRANCH_TO_TEST,
38+
"source_repository_ref": VARS.BRANCH_TO_TEST,
3939
}
4040
)
4141
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-psql")
42-
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Django application"])
42+
assert self.hc_api.test_helm_chart(
43+
expected_str=["Welcome to your Django application"]
44+
)

test/test_helm_python_imagestreams.py renamed to test/test_ocp_helm_python_imagestreams.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44

55
from conftest import VARS
66

7-
class TestHelmRHELPythonImageStreams:
87

8+
class TestHelmRHELPythonImageStreams:
99
def setup_method(self):
1010
package_name = "redhat-python-imagestreams"
11-
self.hc_api = HelmChartsAPI(path=VARS.TEST_DIR, package_name=package_name, tarball_dir=VARS.TEST_DIR, shared_cluster=True)
11+
self.hc_api = HelmChartsAPI(
12+
path=VARS.TEST_DIR,
13+
package_name=package_name,
14+
tarball_dir=VARS.TEST_DIR,
15+
shared_cluster=True,
16+
)
1217
self.hc_api.clone_helm_chart_repo(
13-
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
14-
subdir="charts/redhat"
18+
repo_url="https://github.com/sclorg/helm-charts",
19+
repo_name="helm-charts",
20+
subdir="charts/redhat",
1521
)
1622

1723
def teardown_method(self):
@@ -20,7 +26,10 @@ def teardown_method(self):
2026
@pytest.mark.parametrize(
2127
"version,registry",
2228
[
23-
("3.12-minimal-ubi10", "registry.redhat.io/ubi10/python-312-minimal:latest"),
29+
(
30+
"3.12-minimal-ubi10",
31+
"registry.redhat.io/ubi10/python-312-minimal:latest",
32+
),
2433
("3.12-ubi9", "registry.redhat.io/ubi9/python-312:latest"),
2534
("3.12-ubi8", "registry.redhat.io/ubi8/python-312:latest"),
2635
("3.11-ubi9", "registry.redhat.io/ubi9/python-311:latest"),
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import pytest
2+
3+
from container_ci_suite.openshift import OpenShiftAPI
4+
5+
from conftest import VARS
6+
7+
8+
class TestImagestreamsQuickstart:
9+
def setup_method(self):
10+
self.oc_api = OpenShiftAPI(
11+
pod_name_prefix=f"python-{VARS.SHORT_VERSION}-test",
12+
version=VARS.VERSION_NO_MINIMAL,
13+
shared_cluster=True,
14+
)
15+
16+
def teardown_method(self):
17+
self.oc_api.delete_project()
18+
19+
@pytest.mark.parametrize(
20+
"template", ["django.json", "django-postgresql-persistent.json"]
21+
)
22+
def test_python_template_inside_cluster(self, template):
23+
if self.oc_api.shared_cluster:
24+
assert self.oc_api.upload_image_to_external_registry(
25+
VARS.DEPLOYED_PSQL_IMAGE, VARS.IMAGE_TAG
26+
)
27+
else:
28+
assert self.oc_api.upload_image(VARS.DEPLOYED_PSQL_IMAGE, VARS.IMAGE_TAG)
29+
service_name = f"python-{VARS.SHORT_VERSION}-test"
30+
template_url = self.oc_api.get_raw_url_for_json(
31+
container="django-ex",
32+
dir="openshift/templates",
33+
filename=template,
34+
branch=VARS.BRANCH_TO_TEST,
35+
)
36+
openshift_args = [
37+
f"SOURCE_REPOSITORY_REF={VARS.BRANCH_TO_TEST}",
38+
f"PYTHON_VERSION={VARS.VERSION_NO_MINIMAL}",
39+
f"NAME={service_name}",
40+
]
41+
if template != "django.json":
42+
openshift_args = [
43+
f"SOURCE_REPOSITORY_REF={VARS.BRANCH_TO_TEST}",
44+
f"POSTGRESQL_VERSION={VARS.PSQL_VERSION}",
45+
f"PYTHON_VERSION={VARS.VERSION_NO_MINIMAL}",
46+
f"NAME={service_name}",
47+
"DATABASE_USER=testu",
48+
"DATABASE_PASSWORD=testp",
49+
]
50+
assert self.oc_api.imagestream_quickstart(
51+
imagestream_file="imagestreams/python-rhel.json",
52+
template_file=template_url,
53+
image_name=VARS.IMAGE_NAME,
54+
name_in_template="python",
55+
openshift_args=openshift_args,
56+
)
57+
assert self.oc_api.is_template_deployed(name_in_template=service_name)
58+
assert self.oc_api.check_response_inside_cluster(
59+
name_in_template=service_name,
60+
expected_output="Welcome to your Django application on OpenShift",
61+
)

test/test_latest_imagestreams.py renamed to test/test_ocp_latest_imagestreams.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55

66
# Replacement with 'test_latest_imagestreams'
77
class TestLatestImagestreams:
8-
98
def setup_method(self):
109
self.isc = ImageStreamChecker(working_dir=VARS.TEST_DIR.parent.parent)
1110

1211
def test_latest_imagestream(self):
1312
self.latest_version = self.isc.get_latest_version()
14-
assert self.latest_version != ""
13+
assert self.latest_version
1514
self.isc.check_imagestreams(self.latest_version)

0 commit comments

Comments
 (0)