From 6a2d66f67ffa3361bff52fa9e24836b36252b082 Mon Sep 17 00:00:00 2001 From: Monika Kairaityte Date: Thu, 1 Aug 2024 15:52:48 +0300 Subject: [PATCH] tests/integration: Automate manual 'extends' test Signed-off-by: Monika Kairaityte --- .../test_podman_compose_extends.py | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tests/integration/test_podman_compose_extends.py diff --git a/tests/integration/test_podman_compose_extends.py b/tests/integration/test_podman_compose_extends.py new file mode 100644 index 00000000..fde789f3 --- /dev/null +++ b/tests/integration/test_podman_compose_extends.py @@ -0,0 +1,88 @@ +# SPDX-License-Identifier: GPL-2.0 + +import os +import unittest + +from tests.integration.test_podman_compose import podman_compose_path +from tests.integration.test_podman_compose import test_path +from tests.integration.test_utils import RunSubprocessMixin + + +def compose_yaml_path(): + return os.path.join(os.path.join(test_path(), "extends"), "docker-compose.yaml") + + +class TestComposeExteds(unittest.TestCase, RunSubprocessMixin): + def test_extends_service(self): + try: + self.run_subprocess_assert_returncode([ + podman_compose_path(), + "-f", + compose_yaml_path(), + "up", + "echo", + ]) + output, _ = self.run_subprocess_assert_returncode([ + podman_compose_path(), + "-f", + compose_yaml_path(), + "logs", + "echo", + ]) + self.assertEqual(output, b"Zero\n") + + self.run_subprocess_assert_returncode([ + podman_compose_path(), + "-f", + compose_yaml_path(), + "up", + "echo1", + ]) + output, _ = self.run_subprocess_assert_returncode([ + podman_compose_path(), + "-f", + compose_yaml_path(), + "logs", + "echo1", + ]) + self.assertEqual(output, b"One\n") + + self.run_subprocess_assert_returncode([ + podman_compose_path(), + "-f", + compose_yaml_path(), + "up", + "env1", + ]) + output, _ = self.run_subprocess_assert_returncode([ + podman_compose_path(), + "-f", + compose_yaml_path(), + "logs", + "env1", + ]) + lines = output.decode('utf-8').split('\n') + # HOSTNAME name is random number so is ignored in asserting + lines = [for line in lines if not line[0:8] == "HOSTNAME"] + lines.sort() + + self.assertEqual( + lines, + [ + '', + 'BAR=local', + 'BAZ=local', + 'FOO=original', + 'HOME=/root', + 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + 'TERM=xterm', + 'container=podman', + ], + ) + finally: + self.run_subprocess_assert_returncode([ + podman_compose_path(), + "-f", + compose_yaml_path(), + "down", + ])