| 1 |
|
| 2 |
|
| 3 |
import unittest |
| 4 |
from pathlib import Path |
| 5 |
|
| 6 |
from packaging import version |
| 7 |
|
| 8 |
from tests.integration.test_utils import RunSubprocessMixin |
| 9 |
from tests.integration.test_utils import get_podman_version |
| 10 |
|
| 11 |
|
| 12 |
class TestPodmanComposeInclude(unittest.TestCase, RunSubprocessMixin): |
| 13 |
@unittest.skipIf(get_podman_version() >= version.parse("5.0.0"), "Breaks as of podman-5.4.2.") |
| 14 |
def test_podman_compose_include(self) -> None: |
| 15 |
""" |
| 16 |
Test that podman-compose can execute podman-compose -f <file> up with include |
| 17 |
:return: |
| 18 |
""" |
| 19 |
main_path = Path(__file__).parent.parent.parent.parent |
| 20 |
|
| 21 |
command_up = [ |
| 22 |
"coverage", |
| 23 |
"run", |
| 24 |
str(main_path.joinpath("podman_compose.py")), |
| 25 |
"-f", |
| 26 |
str(main_path.joinpath("tests", "integration", "include", "docker-compose.yaml")), |
| 27 |
"up", |
| 28 |
"-d", |
| 29 |
] |
| 30 |
|
| 31 |
command_check_container = [ |
| 32 |
"podman", |
| 33 |
"ps", |
| 34 |
"-a", |
| 35 |
"--filter", |
| 36 |
"label=io.podman.compose.project=include", |
| 37 |
"--format", |
| 38 |
'"{{.Image}}"', |
| 39 |
] |
| 40 |
|
| 41 |
command_container_id = [ |
| 42 |
"podman", |
| 43 |
"ps", |
| 44 |
"-a", |
| 45 |
"--filter", |
| 46 |
"label=io.podman.compose.project=include", |
| 47 |
"--format", |
| 48 |
'"{{.ID}}"', |
| 49 |
] |
| 50 |
|
| 51 |
command_down = ["podman", "rm", "--force"] |
| 52 |
|
| 53 |
self.run_subprocess_assert_returncode(command_up) |
| 54 |
out, _ = self.run_subprocess_assert_returncode(command_check_container) |
| 55 |
expected_output = b'"localhost/nopush/podman-compose-test:latest"\n' * 2 |
| 56 |
self.assertEqual(out, expected_output) |
| 57 |
|
| 58 |
out, _ = self.run_subprocess_assert_returncode(command_container_id) |
| 59 |
self.assertNotEqual(out, b"") |
| 60 |
container_ids = out.decode().strip().split("\n") |
| 61 |
container_ids = [container_id.replace('"', "") for container_id in container_ids] |
| 62 |
command_down.extend(container_ids) |
| 63 |
out, _ = self.run_subprocess_assert_returncode(command_down) |
| 64 |
|
| 65 |
self.assertNotEqual(out, b"") |
| 66 |
|
| 67 |
out, _ = self.run_subprocess_assert_returncode(command_check_container) |
| 68 |
self.assertEqual(out, b"") |