2024-03-08 11:19:12 +01:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
2024-03-08 10:00:34 +01:00
|
|
|
import unittest
|
2024-03-08 22:46:19 +01:00
|
|
|
from pathlib import Path
|
2023-07-14 06:11:29 +02:00
|
|
|
|
2024-07-03 18:30:40 +02:00
|
|
|
from tests.integration.test_utils import RunSubprocessMixin
|
2023-07-14 06:11:29 +02:00
|
|
|
|
|
|
|
|
2024-03-08 12:14:02 +01:00
|
|
|
class TestPodmanComposeInclude(unittest.TestCase, RunSubprocessMixin):
|
2024-03-08 10:00:34 +01:00
|
|
|
def test_podman_compose_include(self):
|
|
|
|
"""
|
|
|
|
Test that podman-compose can execute podman-compose -f <file> up with include
|
|
|
|
:return:
|
|
|
|
"""
|
2024-06-26 10:01:48 +02:00
|
|
|
main_path = Path(__file__).parent.parent.parent
|
2023-07-14 06:11:29 +02:00
|
|
|
|
2024-03-08 10:00:34 +01:00
|
|
|
command_up = [
|
|
|
|
"coverage",
|
|
|
|
"run",
|
|
|
|
str(main_path.joinpath("podman_compose.py")),
|
|
|
|
"-f",
|
2024-06-26 10:01:48 +02:00
|
|
|
str(main_path.joinpath("tests", "integration", "include", "docker-compose.yaml")),
|
2024-03-08 10:00:34 +01:00
|
|
|
"up",
|
|
|
|
"-d",
|
|
|
|
]
|
2023-07-14 06:11:29 +02:00
|
|
|
|
2024-03-08 10:00:34 +01:00
|
|
|
command_check_container = [
|
|
|
|
"podman",
|
|
|
|
"ps",
|
|
|
|
"-a",
|
|
|
|
"--filter",
|
|
|
|
"label=io.podman.compose.project=include",
|
|
|
|
"--format",
|
|
|
|
'"{{.Image}}"',
|
|
|
|
]
|
2023-07-14 06:11:29 +02:00
|
|
|
|
2024-03-08 10:00:34 +01:00
|
|
|
command_container_id = [
|
|
|
|
"podman",
|
|
|
|
"ps",
|
|
|
|
"-a",
|
|
|
|
"--filter",
|
|
|
|
"label=io.podman.compose.project=include",
|
|
|
|
"--format",
|
|
|
|
'"{{.ID}}"',
|
|
|
|
]
|
2023-07-14 06:11:29 +02:00
|
|
|
|
2024-05-21 05:20:40 +02:00
|
|
|
command_down = ["podman", "rm", "--force"]
|
2023-07-14 06:11:29 +02:00
|
|
|
|
2024-03-08 12:14:02 +01:00
|
|
|
self.run_subprocess_assert_returncode(command_up)
|
|
|
|
out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
2024-05-21 05:20:40 +02:00
|
|
|
expected_output = b'"localhost/nopush/podman-compose-test:latest"\n' * 2
|
|
|
|
self.assertEqual(out, expected_output)
|
2024-03-08 10:00:34 +01:00
|
|
|
# Get container ID to remove it
|
2024-03-08 12:14:02 +01:00
|
|
|
out, _ = self.run_subprocess_assert_returncode(command_container_id)
|
2024-03-08 10:00:34 +01:00
|
|
|
self.assertNotEqual(out, b"")
|
2024-05-21 05:20:40 +02:00
|
|
|
container_ids = out.decode().strip().split("\n")
|
|
|
|
container_ids = [container_id.replace('"', "") for container_id in container_ids]
|
|
|
|
command_down.extend(container_ids)
|
2024-03-08 12:14:02 +01:00
|
|
|
out, _ = self.run_subprocess_assert_returncode(command_down)
|
2024-03-08 10:00:34 +01:00
|
|
|
# cleanup test image(tags)
|
|
|
|
self.assertNotEqual(out, b"")
|
|
|
|
# check container did not exists anymore
|
2024-03-08 12:14:02 +01:00
|
|
|
out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
2024-03-08 10:00:34 +01:00
|
|
|
self.assertEqual(out, b"")
|