Skip to content

Commit d79ff01

Browse files
authored
Merge pull request containers#1113 from mokibit/categorize-integration-tests
tests/integration: Categorize integration tests
2 parents f376700 + d9ef3d2 commit d79ff01

File tree

64 files changed

+391
-352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+391
-352
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_additional_contexts.py tests/integration/additional_contexts/test_podman_compose_additional_contexts.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import subprocess
88
import unittest
99

10-
from tests.integration.test_podman_compose import podman_compose_path
11-
from tests.integration.test_podman_compose import test_path
10+
from tests.integration.test_utils import podman_compose_path
11+
from tests.integration.test_utils import test_path
1212

1313

1414
def compose_yaml_path():

tests/integration/build/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_build.py tests/integration/build/test_podman_compose_build.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import requests
77

8-
from tests.integration.test_podman_compose import podman_compose_path
9-
from tests.integration.test_podman_compose import test_path
8+
from tests.integration.test_utils import podman_compose_path
9+
from tests.integration.test_utils import test_path
1010
from tests.integration.test_utils import RunSubprocessMixin
1111

1212

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_build_fail.py tests/integration/build_fail/test_podman_compose_build_fail.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import os
44
import unittest
55

6-
from tests.integration.test_podman_compose import podman_compose_path
7-
from tests.integration.test_podman_compose import test_path
86
from tests.integration.test_utils import RunSubprocessMixin
7+
from tests.integration.test_utils import podman_compose_path
8+
from tests.integration.test_utils import test_path
99

1010

1111
def compose_yaml_path():

tests/integration/build_labels/__init__.py

Whitespace-only changes.

tests/integration/build_labels/test_build_labels.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import os
66
import unittest
77

8-
from tests.integration.test_podman_compose import podman_compose_path
9-
from tests.integration.test_podman_compose import test_path
108
from tests.integration.test_utils import RunSubprocessMixin
9+
from tests.integration.test_utils import podman_compose_path
10+
from tests.integration.test_utils import test_path
1111

1212

1313
class TestBuildLabels(unittest.TestCase, RunSubprocessMixin):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_build_secrets.py tests/integration/build_secrets/test_podman_compose_build_secrets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import subprocess
88
import unittest
99

10-
from tests.integration.test_podman_compose import podman_compose_path
11-
from tests.integration.test_podman_compose import test_path
10+
from tests.integration.test_utils import podman_compose_path
11+
from tests.integration.test_utils import test_path
1212

1313

1414
def compose_yaml_path():

tests/integration/build_ssh/test_build_ssh.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from cryptography.hazmat.primitives import serialization
1010
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
1111

12-
from tests.integration.test_podman_compose import podman_compose_path
13-
from tests.integration.test_podman_compose import test_path
1412
from tests.integration.test_utils import RunSubprocessMixin
13+
from tests.integration.test_utils import podman_compose_path
14+
from tests.integration.test_utils import test_path
1515

1616
expected_lines = [
1717
"default: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFYQvN9a+toIB6jSs4zY7FMapZnHt80EKCUr/WhLwUum",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_default_net_behavior.py tests/integration/default_net_behavior/test_podman_compose_default_net_behavior.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
from parameterized import parameterized
77

8-
from tests.integration.test_podman_compose import podman_compose_path
9-
from tests.integration.test_podman_compose import test_path
108
from tests.integration.test_utils import RunSubprocessMixin
9+
from tests.integration.test_utils import podman_compose_path
10+
from tests.integration.test_utils import test_path
1111

1212

1313
def compose_yaml_path(scenario):

tests/integration/deps/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_deps.py tests/integration/deps/test_podman_compose_deps.py

+54-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import os
33
import unittest
44

5-
from tests.integration.test_podman_compose import podman_compose_path
6-
from tests.integration.test_podman_compose import test_path
75
from tests.integration.test_utils import RunSubprocessMixin
6+
from tests.integration.test_utils import podman_compose_path
7+
from tests.integration.test_utils import test_path
88

99

1010
def compose_yaml_path(suffix=""):
@@ -87,6 +87,58 @@ def test_up_nodeps(self):
8787
"down",
8888
])
8989

90+
def test_podman_compose_run(self):
91+
"""
92+
This will test depends_on as well
93+
"""
94+
run_cmd = [
95+
"coverage",
96+
"run",
97+
podman_compose_path(),
98+
"-f",
99+
os.path.join(test_path(), "deps", "docker-compose.yaml"),
100+
"run",
101+
"--rm",
102+
"sleep",
103+
"/bin/sh",
104+
"-c",
105+
"wget -q -O - http://web:8000/hosts",
106+
]
107+
108+
out, _ = self.run_subprocess_assert_returncode(run_cmd)
109+
self.assertIn(b"127.0.0.1\tlocalhost", out)
110+
111+
# Run it again to make sure we can run it twice. I saw an issue where a second run, with
112+
# the container left up, would fail
113+
run_cmd = [
114+
"coverage",
115+
"run",
116+
podman_compose_path(),
117+
"-f",
118+
os.path.join(test_path(), "deps", "docker-compose.yaml"),
119+
"run",
120+
"--rm",
121+
"sleep",
122+
"/bin/sh",
123+
"-c",
124+
"wget -q -O - http://web:8000/hosts",
125+
]
126+
127+
out, _ = self.run_subprocess_assert_returncode(run_cmd)
128+
self.assertIn(b"127.0.0.1\tlocalhost", out)
129+
130+
# This leaves a container running. Not sure it's intended, but it matches docker-compose
131+
down_cmd = [
132+
"coverage",
133+
"run",
134+
podman_compose_path(),
135+
"-f",
136+
os.path.join(test_path(), "deps", "docker-compose.yaml"),
137+
"down",
138+
]
139+
140+
self.run_subprocess_assert_returncode(down_cmd)
141+
90142

91143
class TestComposeConditionalDeps(unittest.TestCase, RunSubprocessMixin):
92144
def test_deps_succeeds(self):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_env_file.py tests/integration/env-file-tests/test_podman_compose_env_file.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import os
44
import unittest
55

6-
from tests.integration.test_podman_compose import podman_compose_path
7-
from tests.integration.test_podman_compose import test_path
86
from tests.integration.test_utils import RunSubprocessMixin
7+
from tests.integration.test_utils import podman_compose_path
8+
from tests.integration.test_utils import test_path
99

1010

1111
def compose_base_path():
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_env.py tests/integration/env-tests/test_podman_compose_env.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import os
44
import unittest
55

6-
from tests.integration.test_podman_compose import podman_compose_path
7-
from tests.integration.test_podman_compose import test_path
86
from tests.integration.test_utils import RunSubprocessMixin
7+
from tests.integration.test_utils import podman_compose_path
8+
from tests.integration.test_utils import test_path
99

1010

1111
def compose_yaml_path():
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_exit_from.py tests/integration/exit-from/test_podman_compose_exit_from.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import os
44
import unittest
55

6-
from tests.integration.test_podman_compose import podman_compose_path
7-
from tests.integration.test_podman_compose import test_path
86
from tests.integration.test_utils import RunSubprocessMixin
7+
from tests.integration.test_utils import podman_compose_path
8+
from tests.integration.test_utils import test_path
99

1010

1111
def compose_yaml_path():
@@ -52,3 +52,16 @@ def test_exit_code_sh2(self):
5252
compose_yaml_path(),
5353
"down",
5454
])
55+
56+
def test_podman_compose_exit_from(self):
57+
up_cmd = [
58+
"coverage",
59+
"run",
60+
podman_compose_path(),
61+
"-f",
62+
os.path.join(test_path(), "exit-from", "docker-compose.yaml"),
63+
"up",
64+
]
65+
66+
self.run_subprocess_assert_returncode(up_cmd + ["--exit-code-from", "sh1"], 1)
67+
self.run_subprocess_assert_returncode(up_cmd + ["--exit-code-from", "sh2"], 2)

tests/integration/extends/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_extends.py tests/integration/extends/test_podman_compose_extends.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import os
44
import unittest
55

6-
from tests.integration.test_podman_compose import podman_compose_path
7-
from tests.integration.test_podman_compose import test_path
86
from tests.integration.test_utils import RunSubprocessMixin
7+
from tests.integration.test_utils import podman_compose_path
8+
from tests.integration.test_utils import test_path
99

1010

1111
def compose_yaml_path():
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_extends_w_empty_service.py tests/integration/extends_w_empty_service/test_podman_compose_extends_w_empty_service.py

+26-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import os
44
import unittest
5+
from pathlib import Path
56

6-
from tests.integration.test_podman_compose import podman_compose_path
7-
from tests.integration.test_podman_compose import test_path
87
from tests.integration.test_utils import RunSubprocessMixin
8+
from tests.integration.test_utils import podman_compose_path
9+
from tests.integration.test_utils import test_path
910

1011

1112
def compose_yaml_path():
@@ -37,3 +38,26 @@ def test_extends_w_empty_service(self):
3738
compose_yaml_path(),
3839
"down",
3940
])
41+
42+
def test_podman_compose_extends_w_empty_service(self):
43+
"""
44+
Test that podman-compose can execute podman-compose -f <file> up with extended File which
45+
includes an empty service. (e.g. if the file is used as placeholder for more complex
46+
configurations.)
47+
"""
48+
main_path = Path(__file__).parent.parent.parent.parent
49+
50+
command_up = [
51+
"python3",
52+
str(main_path.joinpath("podman_compose.py")),
53+
"-f",
54+
str(
55+
main_path.joinpath(
56+
"tests", "integration", "extends_w_empty_service", "docker-compose.yml"
57+
)
58+
),
59+
"up",
60+
"-d",
61+
]
62+
63+
self.run_subprocess_assert_returncode(command_up)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose_extends_w_file.py tests/integration/extends_w_file/test_podman_compose_extends_w_file.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import os
44
import unittest
55

6-
from tests.integration.test_podman_compose import podman_compose_path
7-
from tests.integration.test_podman_compose import test_path
86
from tests.integration.test_utils import RunSubprocessMixin
7+
from tests.integration.test_utils import podman_compose_path
8+
from tests.integration.test_utils import test_path
99

1010

1111
def compose_yaml_path():
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/integration/test_podman_compose.py tests/integration/extends_w_file_subdir/test_podman_compose_extends_w_file_subdir.py

+36-43
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,47 @@
55
from pathlib import Path
66

77
from tests.integration.test_utils import RunSubprocessMixin
8-
9-
10-
def base_path():
11-
"""Returns the base path for the project"""
12-
return Path(__file__).parent.parent.parent
13-
14-
15-
def test_path():
16-
"""Returns the path to the tests directory"""
17-
return os.path.join(base_path(), "tests/integration")
18-
19-
20-
def podman_compose_path():
21-
"""Returns the path to the podman compose script"""
22-
return os.path.join(base_path(), "podman_compose.py")
23-
24-
25-
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
26-
def test_extends_w_file_subdir(self):
8+
from tests.integration.test_utils import podman_compose_path
9+
from tests.integration.test_utils import test_path
10+
11+
12+
def compose_yaml_path():
13+
return os.path.join(os.path.join(test_path(), "extends_w_file_subdir"), "docker-compose.yml")
14+
15+
16+
class TestComposeExtendsWithFileSubdir(unittest.TestCase, RunSubprocessMixin):
17+
def test_extends_w_file_subdir(self): # when file is Dockerfile for building the image
18+
try:
19+
self.run_subprocess_assert_returncode(
20+
[
21+
podman_compose_path(),
22+
"-f",
23+
compose_yaml_path(),
24+
"up",
25+
],
26+
)
27+
output, _ = self.run_subprocess_assert_returncode([
28+
podman_compose_path(),
29+
"-f",
30+
compose_yaml_path(),
31+
"ps",
32+
])
33+
self.assertIn("extends_w_file_subdir_web_1", str(output))
34+
finally:
35+
self.run_subprocess_assert_returncode([
36+
podman_compose_path(),
37+
"-f",
38+
compose_yaml_path(),
39+
"down",
40+
])
41+
42+
def test_podman_compose_extends_w_file_subdir(self):
2743
"""
2844
Test that podman-compose can execute podman-compose -f <file> up with extended File which
2945
includes a build context
3046
:return:
3147
"""
32-
main_path = Path(__file__).parent.parent.parent
48+
main_path = Path(__file__).parent.parent.parent.parent
3349

3450
command_up = [
3551
"coverage",
@@ -86,26 +102,3 @@ def test_extends_w_file_subdir(self):
86102
# check container did not exists anymore
87103
out, _ = self.run_subprocess_assert_returncode(command_check_container)
88104
self.assertEqual(out, b'')
89-
90-
def test_extends_w_empty_service(self):
91-
"""
92-
Test that podman-compose can execute podman-compose -f <file> up with extended File which
93-
includes an empty service. (e.g. if the file is used as placeholder for more complex
94-
configurations.)
95-
"""
96-
main_path = Path(__file__).parent.parent.parent
97-
98-
command_up = [
99-
"python3",
100-
str(main_path.joinpath("podman_compose.py")),
101-
"-f",
102-
str(
103-
main_path.joinpath(
104-
"tests", "integration", "extends_w_empty_service", "docker-compose.yml"
105-
)
106-
),
107-
"up",
108-
"-d",
109-
]
110-
111-
self.run_subprocess_assert_returncode(command_up)
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)