Skip to content

Commit 3491af1

Browse files
committed
Add several comments to each test so we understand
what we tests. Add description, why sleep(3) is present in HotPlug test Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
1 parent adae112 commit 3491af1

10 files changed

+87
-5
lines changed

test/test_container_basics.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,28 @@ def setup_method(self):
1414
def teardown_method(self):
1515
self.app.cleanup()
1616

17-
# test_s2i_usage
1817
def test_run_s2i_usage(self):
18+
"""
19+
Test checks if `usage` script works properly
20+
"""
1921
output = self.app.s2i_usage()
2022
assert output
2123

2224
# # test_docker_run_usage
2325
def test_docker_run_usage(self):
26+
"""
27+
Test checks if `docker run` script works properly and do not fail
28+
"""
2429
assert PodmanCLIWrapper.call_podman_command(
2530
cmd=f"run --rm {VARS.IMAGE_NAME} &>/dev/null",
2631
return_output=False
2732
) == 0
2833

2934
def test_scl_usage(self):
35+
"""
36+
Test checks if command `perl --version` script works properly
37+
and returns version without -mod_fcgid
38+
"""
3039
assert f"v{VARS.VERSION_NO_FCGID}" in PodmanCLIWrapper.podman_run_command(
3140
f"--rm {VARS.IMAGE_NAME} /bin/bash -c 'perl --version'"
3241
)
@@ -39,6 +48,10 @@ def test_scl_usage(self):
3948
]
4049
)
4150
def test_dockerfiles(self, dockerfile):
51+
"""
52+
Test checks if we are able to build a container from
53+
`examples/from-dockerfile/<version>/{Dockerfile,Dockerfile.s2i}
54+
"""
4255
assert self.app.build_test_container(
4356
dockerfile=VARS.TEST_DIR / "examples/from-dockerfile" / VARS.VERSION / dockerfile,
4457
app_url="https://github.com/sclorg/dancer-ex.git",

test/test_container_s2i.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,17 @@ def teardown_method(self):
5151
self.s2i_app.cleanup()
5252

5353
def test_run_s2i_usage(self):
54+
"""
55+
Test checks if `usage` script works properly
56+
"""
5457
output = self.s2i_app.s2i_usage()
5558
assert output
5659

5760
# test_docker_run_usage
5861
def test_docker_run_usage(self):
62+
"""
63+
Test checks if `docker run` script works properly and do not fail
64+
"""
5965
assert PodmanCLIWrapper.call_podman_command(
6066
cmd=f"run --rm {VARS.IMAGE_NAME} &>/dev/null",
6167
return_output=False
@@ -69,6 +75,10 @@ def test_docker_run_usage(self):
6975
]
7076
)
7177
def test_run_app_test(self, container_arg):
78+
"""
79+
Test checks if we are able to run a container as deamon
80+
and response works as expected
81+
"""
7282
cid_file_name = self.s2i_app.app_name
7383
assert self.s2i_app.create_container(cid_file_name=cid_file_name, container_args=container_arg)
7484
assert ContainerImage.wait_for_cid(cid_file_name=cid_file_name)
@@ -97,6 +107,11 @@ def test_run_app_test(self, container_arg):
97107
)
98108
class TestPerlExampleAppContainer:
99109
def test_run_app_test(self, application_path, container_args, page, expected_output):
110+
"""
111+
Test class checks specific applications
112+
and response works as expected. See parametrized parameters for more
113+
details
114+
"""
100115
self.s2i_app = build_s2i_app(application_path, container_args=container_args)
101116
cid_file_name = self.s2i_app.app_name
102117
assert self.s2i_app.create_container(
@@ -128,6 +143,9 @@ def teardown_method(self):
128143
self.s2i_app.cleanup()
129144

130145
def test_npm_works(self):
146+
"""
147+
Test checks if NPM works in container.
148+
"""
131149
assert self.s2i_app.npm_works(image_name=VARS.IMAGE_NAME)
132150

133151

@@ -140,6 +158,10 @@ def test_npm_works(self):
140158
)
141159
class TestPerlHotDeployAppContainer:
142160
def test_run_app_test(self, application_path, container_args, hot_deploy):
161+
"""
162+
Test checks hot deploy application
163+
It checks what is present in HTTP response
164+
"""
143165
self.s2i_app = build_s2i_app(application_path, container_args=container_args)
144166
cid_file_name = self.s2i_app.app_name
145167
assert self.s2i_app.create_container(
@@ -156,13 +178,19 @@ def test_run_app_test(self, application_path, container_args, hot_deploy):
156178
assert self.s2i_app.test_response(
157179
url=f"http://{cip}", expected_output="old initial value: 1"
158180
)
159-
sleep(2)
181+
# We need to wait couple seconds till container
182+
# before changing 'string' in 'Test.pm' file
183+
# If we don't set PSGI_RELOAD, this change don't affects application.
184+
# If we set PSGI_RELOAD, this change affects application.
185+
sleep(3)
160186
PodmanCLIWrapper.podman_exec_shell_command(
161187
cid_file_name=cid,
162188
cmd="sed -ie 's/old initial value/new initial value/' lib/My/Test.pm",
163189
used_shell="/bin/sh"
164190
)
165191
if hot_deploy:
192+
# We need to wait couple seconds till container
193+
# does not update page. HotDeploy needs at least 3 seconds
166194
sleep(3)
167195
assert PodmanCLIWrapper.podman_exec_shell_command(
168196
cid_file_name=cid,
@@ -173,7 +201,6 @@ def test_run_app_test(self, application_path, container_args, hot_deploy):
173201
url=f"http://{cip}", expected_output="new initial value: 0"
174202
)
175203
else:
176-
sleep(2)
177204
assert self.s2i_app.test_response(
178205
url=f"http://{cip}", expected_output="old initial value: 2"
179206
)

test/test_ocp_dancer_ex_standalone.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from conftest import VARS
44

55

6-
# Replacement with 'test_python_s2i_app_ex'
76
class TestPerlDancerExTemplate:
87

98
def setup_method(self):
@@ -17,6 +16,10 @@ def teardown_method(self):
1716
self.oc_api.delete_project()
1817

1918
def test_dancer_ex_template_inside_cluster(self):
19+
"""
20+
Test checks if example GitHub application dancer-ex
21+
works properly and response is as expected
22+
"""
2023
service_name = f"perl-{VARS.SHORT_VERSION}-testing"
2124
assert self.oc_api.deploy_s2i_app(
2225
image_name=VARS.IMAGE_NAME, app="https://github.com/sclorg/dancer-ex.git",

test/test_ocp_dancer_ex_templates.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ def teardown_method(self):
1616
self.oc_api.delete_project()
1717

1818
def test_perl_template_inside_cluster(self):
19+
"""
20+
Test checks if local imagestream and GitHub application dancer-ex
21+
works properly and response is as expected.
22+
The response is taken from POD `command-app`
23+
executed inside the same project.
24+
"""
1925
self.oc_api.import_is("imagestreams/perl-rhel.json", "", skip_check=True)
2026
service_name = f"perl-{VARS.SHORT_VERSION}-testing"
2127
template_url = self.oc_api.get_raw_url_for_json(
@@ -49,6 +55,13 @@ def teardown_method(self):
4955
self.oc_api.delete_project()
5056

5157
def test_perl_template_inside_cluster(self):
58+
"""
59+
Test checks if local imagestream and GitHub application dancer-ex
60+
works properly and response is as expected.
61+
MySQL persistent database is enabled as well.
62+
The response is taken from POD `command-app`
63+
executed inside the same project.
64+
"""
5265
self.oc_api.import_is("imagestreams/perl-rhel.json", "", skip_check=True)
5366
assert self.oc_api.upload_image(DEPLOYED_MYSQL_IMAGE, f"{IMAGE_TAG}")
5467
service_name = f"perl-{VARS.SHORT_VERSION}-testing"

test/test_ocp_deploy_templates.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ def teardown_method(self):
1616
self.oc_api.delete_project()
1717

1818
def test_perl_template_inside_cluster(self):
19+
"""
20+
Test checks if local imagestream and local sample app
21+
works properly and response is as expected.
22+
The response is taken from POD `command-app`
23+
executed inside the same project.
24+
"""
1925
self.oc_api.import_is("imagestreams/perl-rhel.json", "", skip_check=True)
2026
service_name = f"perl-{VARS.SHORT_VERSION}-testing"
2127
assert self.oc_api.deploy_template_with_image(

test/test_ocp_helm_dancer_app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def teardown_method(self):
2222
self.hc_api.delete_project()
2323

2424
def test_dancer_application_helm_test(self):
25+
"""
26+
Test checks if Helm imagestream and Helm perl dancer application
27+
works properly and response is as expected.
28+
"""
2529
self.hc_api.package_name = "redhat-perl-imagestreams"
2630
assert self.hc_api.helm_package()
2731
assert self.hc_api.helm_installation()

test/test_ocp_helm_dancer_mysql_template.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def teardown_method(self):
1717
self.hc_api.delete_project()
1818

1919
def test_dancer_application_helm_test(self):
20+
"""
21+
Test checks if Helm imagestream and Helm perl dancer application
22+
works properly and response is as expected.
23+
"""
2024
skip_helm_charts_tests()
2125
self.hc_api.package_name = "redhat-perl-imagestreams"
2226
assert self.hc_api.helm_package()

test/test_ocp_helm_perl_imagestreams.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def teardown_method(self):
3333
],
3434
)
3535
def test_package_imagestream(self, version, registry, expected):
36+
"""
37+
Test checks if Helm imagestreams
38+
"""
3639
assert self.hc_api.helm_package()
3740
assert self.hc_api.helm_installation()
3841
assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected

test/test_ocp_imagestreams_quickstart.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from conftest import VARS, TAGS, skip_helm_charts_tests
55

66

7-
# Replacement with 'test_python_s2i_templates'
7+
# Replacement with 'test_perl_s2i_templates'
88
class TestImagestreamsQuickstart:
99

1010
def setup_method(self):
@@ -18,6 +18,12 @@ def teardown_method(self):
1818
self.oc_api.delete_project()
1919

2020
def test_perl_template_inside_cluster(self):
21+
"""
22+
Test checks if local imagestream and local sample app
23+
works properly and response is as expected.
24+
The response is taken from POD `command-app`
25+
executed inside the same project.
26+
"""
2127
skip_helm_charts_tests()
2228
service_name = f"perl-{VARS.SHORT_VERSION}-testing"
2329
assert self.oc_api.imagestream_quickstart(

test/test_ocp_latest_imagestreams.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ def setup_method(self):
1010
self.isc = ImageStreamChecker(working_dir=VARS.TEST_DIR.parent.parent)
1111

1212
def test_latest_imagestream(self):
13+
"""
14+
Test checks if local imagestream is the latest one
15+
"""
1316
self.latest_version = self.isc.get_latest_version()
1417
assert self.latest_version != ""
1518
self.isc.check_imagestreams(self.latest_version)

0 commit comments

Comments
 (0)