Skip to content

Commit 936ee6d

Browse files
committed
Rename test_*.py OpenShift PyTest to `test_ocp_*.py
Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent f70850f commit 936ee6d

9 files changed

+41
-115
lines changed

test/constants.py

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

test/run-openshift-pytest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
THISDIR=$(dirname ${BASH_SOURCE[0]})
1010

11-
cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_*.py
11+
cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_ocp_*.py
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,19 @@
1-
import os
2-
import sys
3-
41
import pytest
52

63
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-
16-
VERSION = os.getenv("VERSION").replace("-minimal", "")
17-
IMAGE_NAME = os.getenv("IMAGE_NAME")
18-
OS = os.getenv("OS")
194

20-
DEPLOYED_PGSQL_IMAGE = "quay.io/sclorg/postgresql-15-c9s"
21-
22-
23-
TAG = TAGS.get(OS)
24-
PGSQL_IMAGE_TAG = f"postgresql:15-c9s"
25-
IMAGE_TAG = f"15-c9s"
5+
from conftest import VARS, DEPLOYED_PGSQL_IMAGE, PGSQL_IMAGE_TAG, IMAGE_TAG
266

277

288
# Replacement with 'test_python_s2i_templates'
299
class TestImagestreamsQuickstart:
3010

3111
def setup_method(self):
32-
self.oc_api = OpenShiftAPI(pod_name_prefix=f"nodejs-{VERSION}-example", version=VERSION, shared_cluster=True)
12+
self.oc_api = OpenShiftAPI(
13+
pod_name_prefix=f"nodejs-{VARS.VERSION_NO_MINIMAL}-example",
14+
version=VARS.VERSION_NO_MINIMAL,
15+
shared_cluster=True
16+
)
3317

3418
def teardown_method(self):
3519
self.oc_api.delete_project()
@@ -43,22 +27,22 @@ def teardown_method(self):
4327
)
4428
def test_nodejs_template_inside_cluster(self, template):
4529
assert self.oc_api.upload_image(DEPLOYED_PGSQL_IMAGE, PGSQL_IMAGE_TAG)
46-
service_name = f"nodejs-{VERSION}-example"
30+
service_name = f"nodejs-{VARS.VERSION}-example"
4731
template_url = self.oc_api.get_raw_url_for_json(
4832
container="nodejs-ex", dir="openshift/templates", filename=template, branch="master"
4933
)
5034
openshift_args = [
5135
"SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git",
5236
"SOURCE_REPOSITORY_REF=master",
53-
f"NODEJS_VERSION={VERSION}",
37+
f"NODEJS_VERSION={VARS.VERSION_NO_MINIMAL}",
5438
f"NAME={service_name}"
5539
]
5640
if template != "nodejs.json":
5741
openshift_args = [
5842
"SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git",
5943
"SOURCE_REPOSITORY_REF=master",
6044
f"POSTGRESQL_VERSION={IMAGE_TAG}",
61-
f"NODEJS_VERSION={VERSION}",
45+
f"NODEJS_VERSION={VARS.VERSION_NO_MINIMAL}",
6246
f"NAME={service_name}",
6347
"DATABASE_USER=testu",
6448
"DATABASE_PASSWORD=testpwd",
@@ -67,12 +51,11 @@ def test_nodejs_template_inside_cluster(self, template):
6751
assert self.oc_api.imagestream_quickstart(
6852
imagestream_file="imagestreams/nodejs-rhel.json",
6953
template_file=template_url,
70-
image_name=IMAGE_NAME,
54+
image_name=VARS.IMAGE_NAME,
7155
name_in_template="nodejs",
7256
openshift_args=openshift_args
7357
)
7458
assert self.oc_api.is_template_deployed(name_in_template=service_name)
7559
assert self.oc_api.check_response_inside_cluster(
7660
name_in_template=service_name, expected_output="Node.js Crud Application"
7761
)
78-
Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
1-
import os
2-
import sys
3-
4-
import pytest
5-
6-
from container_ci_suite.utils import check_variables
71
from container_ci_suite.openshift import OpenShiftAPI
82

9-
if not check_variables():
10-
print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
11-
sys.exit(1)
12-
13-
14-
VERSION = os.getenv("VERSION").replace("-minimal", "")
15-
IMAGE_NAME = os.getenv("IMAGE_NAME")
16-
OS = os.getenv("TARGET")
3+
from conftest import VARS
174

185

196
class TestNodeJSExTemplate:
207

218
def setup_method(self):
22-
self.oc_api = OpenShiftAPI(pod_name_prefix=f"nodejs-{VERSION}-testing", version=VERSION, shared_cluster=True)
9+
self.oc_api = OpenShiftAPI(
10+
pod_name_prefix=f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing",
11+
version=VARS.VERSION_NO_MINIMAL,
12+
shared_cluster=True
13+
)
2314

2415
def teardown_method(self):
2516
self.oc_api.delete_project()
2617

2718
def test_nodejs_ex_template_inside_cluster(self):
28-
service_name = f"nodejs-{VERSION}-testing"
19+
service_name = f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing"
2920
assert self.oc_api.deploy_s2i_app(
30-
image_name=IMAGE_NAME, app=f"https://github.com/sclorg/nodejs-ex.git",
21+
image_name=VARS.IMAGE_NAME, app="https://github.com/sclorg/nodejs-ex.git",
3122
context=".",
3223
service_name=service_name
3324
)
Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,19 @@
1-
import os
2-
import sys
3-
41
import pytest
5-
from container_ci_suite.openshift import OpenShiftAPI
6-
from container_ci_suite.utils import check_variables
7-
8-
from constants import TAGS
9-
10-
if not check_variables():
11-
print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
12-
sys.exit(1)
132

143

15-
VERSION = os.getenv("VERSION").replace("-minimal", "")
16-
IMAGE_NAME = os.getenv("IMAGE_NAME")
17-
OS = os.getenv("TARGET")
18-
19-
DEPLOYED_PGSQL_IMAGE = "quay.io/sclorg/postgresql-15-c9s"
20-
4+
from container_ci_suite.openshift import OpenShiftAPI
215

22-
NODEJS_TAG = TAGS.get(OS)
23-
PGSQL_IMAGE_NAME = f"postgresql:15-c9s"
24-
IMAGE_TAG = f"15-c9s"
6+
from conftest import VARS, DEPLOYED_PGSQL_IMAGE, PGSQL_IMAGE_TAG, IMAGE_TAG
257

268

279
class TestDeployNodeJSExTemplate:
2810

2911
def setup_method(self):
30-
self.oc_api = OpenShiftAPI(pod_name_prefix=f"nodejs-{VERSION}-testing", version=VERSION, shared_cluster=True)
12+
self.oc_api = OpenShiftAPI(
13+
pod_name_prefix=f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing",
14+
version=VARS.VERSION_NO_MINIMAL,
15+
shared_cluster=True
16+
)
3117

3218
def teardown_method(self):
3319
self.oc_api.delete_project()
@@ -40,30 +26,30 @@ def teardown_method(self):
4026
]
4127
)
4228
def test_nodejs_ex_template_inside_cluster(self, template):
43-
assert self.oc_api.upload_image(DEPLOYED_PGSQL_IMAGE, PGSQL_IMAGE_NAME)
29+
assert self.oc_api.upload_image(DEPLOYED_PGSQL_IMAGE, PGSQL_IMAGE_TAG)
4430
template_url = self.oc_api.get_raw_url_for_json(
4531
container="nodejs-ex", dir="openshift/templates", filename=template, branch="master"
4632
)
47-
service_name = f"nodejs-{VERSION}-testing"
33+
service_name = f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing"
4834
openshift_args = [
4935
"SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git",
5036
"SOURCE_REPOSITORY_REF=master",
51-
f"NODEJS_VERSION={VERSION}",
37+
f"NODEJS_VERSION={VARS.VERSION_NO_MINIMAL}",
5238
f"NAME={service_name}"
5339
]
5440
if template != "nodejs.json":
5541
openshift_args = [
5642
"SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git",
5743
"SOURCE_REPOSITORY_REF=master",
5844
f"POSTGRESQL_VERSION={IMAGE_TAG}",
59-
f"NODEJS_VERSION={VERSION}",
45+
f"NODEJS_VERSION={VARS.VERSION_NO_MINIMAL}",
6046
f"NAME={service_name}",
6147
"DATABASE_USER=testu",
6248
"DATABASE_PASSWORD=testpwd",
6349
"DATABASE_ADMIN_PASSWORD=testadminpwd"
6450
]
6551
assert self.oc_api.deploy_template_with_image(
66-
image_name=IMAGE_NAME,
52+
image_name=VARS.IMAGE_NAME,
6753
template=template_url,
6854
name_in_template="nodejs",
6955
openshift_args=openshift_args
Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
1-
import os
2-
import sys
3-
4-
import pytest
5-
6-
from container_ci_suite.utils import check_variables
71
from container_ci_suite.openshift import OpenShiftAPI
82

9-
if not check_variables():
10-
print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
11-
sys.exit(1)
3+
from conftest import VARS
124

135

14-
VERSION = os.getenv("VERSION").replace("-minimal", "")
15-
IMAGE_NAME = os.getenv("IMAGE_NAME")
16-
OS = os.getenv("TARGET")
17-
186
class TestNodeJSExTemplate:
197

208
def setup_method(self):
21-
self.oc_api = OpenShiftAPI(pod_name_prefix=f"nodejs-{VERSION}-testing", version=VERSION)
9+
self.oc_api = OpenShiftAPI(
10+
pod_name_prefix=f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing",
11+
version=VARS.VERSION_NO_MINIMAL
12+
)
2213

2314
def teardown_method(self):
2415
self.oc_api.delete_project()
2516

2617
def test_nodejs_ex_template_inside_cluster(self):
27-
service_name = f"nodejs-{VERSION}-testing"
18+
service_name = f"nodejs-{VARS.VERSION_NO_MINIMAL}-testing"
2819
assert self.oc_api.deploy_s2i_app(
29-
image_name=IMAGE_NAME, app=f"https://github.com/sclorg/s2i-nodejs-container.git",
20+
image_name=VARS.IMAGE_NAME, app="https://github.com/sclorg/s2i-nodejs-container.git",
3021
context="test/test-app",
3122
service_name=service_name
3223
)

test/test_shared_helm_nodejs_application.py renamed to test/test_ocp_shared_helm_nodejs_application.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
1-
import os
2-
import sys
3-
4-
import pytest
5-
from pathlib import Path
6-
71
from container_ci_suite.helm import HelmChartsAPI
8-
from container_ci_suite.utils import check_variables
9-
10-
from constants import TAGS
11-
12-
if not check_variables():
13-
print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
14-
sys.exit(1)
15-
16-
test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
17-
18-
VERSION = os.getenv("VERSION")
19-
IMAGE_NAME = os.getenv("IMAGE_NAME")
20-
OS = os.getenv("TARGET")
212

22-
TAG = TAGS.get(OS)
3+
from conftest import VARS, TAGS
234

245

256
class TestHelmNodeJSApplication:
267

278
def setup_method(self):
289
package_name = "redhat-nodejs-application"
29-
path = test_dir
30-
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)
10+
self.hc_api = HelmChartsAPI(path=VARS.TEST_DIR, package_name=package_name, tarball_dir=VARS.TEST_DIR)
3111
self.hc_api.clone_helm_chart_repo(
3212
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
3313
subdir="charts/redhat"
@@ -44,7 +24,7 @@ def test_by_helm_test(self):
4424
assert self.hc_api.helm_package()
4525
assert self.hc_api.helm_installation(
4626
values={
47-
"nodejs": f"{VERSION}{TAG}",
27+
"nodejs": f"{VARS.VERSION}{TAGS.get(VARS.OS)}",
4828
"namespace": self.hc_api.namespace
4929
}
5030
)
File renamed without changes.

0 commit comments

Comments
 (0)