forked from sclorg/nginx-container
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_container_basics.py
More file actions
82 lines (70 loc) · 2.31 KB
/
test_container_basics.py
File metadata and controls
82 lines (70 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import pytest
from container_ci_suite.container_lib import ContainerTestLib
from container_ci_suite.engines.podman_wrapper import PodmanCLIWrapper
from container_ci_suite.dockerfile_processor import DockerfileProcessor
from conftest import VARS
class TestNginxContainer:
"""
Test container basics
"""
def setup_method(self):
"""
Setup method
"""
self.app = ContainerTestLib(image_name=VARS.IMAGE_NAME, s2i_image=True)
def teardown_method(self):
"""
Teardown method
"""
self.app.cleanup()
def test_run_s2i_usage(self):
"""
Test if s2i usage works
"""
output = self.app.s2i_usage()
assert output != ""
def test_docker_run_usage(self):
"""
Test if container is runnable
"""
assert (
PodmanCLIWrapper.call_podman_command(
cmd=f"run --rm {VARS.IMAGE_NAME} &>/dev/null", return_output=False
)
== 0
)
def test_scl_usage(self):
"""
Test if nginx -v returns proper output
"""
assert (
f"nginx/{VARS.VERSION_NO_MICRO}"
in PodmanCLIWrapper.podman_run_command_and_remove(
cid_file_name=VARS.IMAGE_NAME, cmd="nginx -v"
)
)
@pytest.mark.parametrize("dockerfile", ["Dockerfile", "Dockerfile.s2i"])
def test_dockerfiles(self, dockerfile):
"""
Test if building nginx-container based on
examples/Dockerfile works
"""
dp = DockerfileProcessor(
dockerfile_path=f"{VARS.TEST_DIR}/examples/{dockerfile}"
)
dp.update_env_in_dockerfile(
version=VARS.VERSION_NO_MICRO, what_to_replace="ENV NGINX_VERSION"
)
dp.update_variable_in_dockerfile(
version=VARS.VERSION_NO_MICRO, variable="NGINX_VERSION"
)
new_docker_file = dp.create_temp_dockerfile()
assert self.app.build_test_container(
dockerfile=new_docker_file,
app_url="https://github.com/sclorg/nginx-container.git",
app_dir="nginx-container",
)
assert self.app.test_app_dockerfile()
cip = self.app.get_cip()
assert cip
assert self.app.test_response(url=cip, expected_output="NGINX is working")