Skip to content

Commit 7609389

Browse files
committed
tests/integration: Add override tag service test
Signed-off-by: Monika Kairaityte <[email protected]>
1 parent efc7f2a commit 7609389

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "3"
2+
services:
3+
app: !override
4+
image: busybox
5+
command: ["/bin/busybox", "echo", "One"]
6+
ports:
7+
- "8111:81"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "3"
2+
services:
3+
app:
4+
image: busybox
5+
command: ["/bin/busybox", "echo", "Zero"]
6+
ports:
7+
- "8080:80"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
import json
4+
import os
5+
import unittest
6+
7+
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
10+
11+
12+
def compose_yaml_path():
13+
return os.path.join(os.path.join(test_path(), "override_tag_service"), "docker-compose.yaml")
14+
15+
16+
class TestComposeOverrideTagService(unittest.TestCase, RunSubprocessMixin):
17+
# test if whole service from docker-compose.yaml file is overridden in another file
18+
def test_override_tag_service(self):
19+
override_file = os.path.join(
20+
os.path.join(test_path(), "override_tag_service"),
21+
"docker-compose.override_service.yaml",
22+
)
23+
try:
24+
self.run_subprocess_assert_returncode([
25+
podman_compose_path(),
26+
"-f",
27+
compose_yaml_path(),
28+
"-f",
29+
override_file,
30+
"up",
31+
])
32+
33+
# Whole app service was overridden in the docker-compose.override_tag_service.yaml file.
34+
# Command and port is overriden accordingly.
35+
output, _ = self.run_subprocess_assert_returncode([
36+
podman_compose_path(),
37+
"-f",
38+
compose_yaml_path(),
39+
"-f",
40+
override_file,
41+
"logs",
42+
])
43+
self.assertEqual(output, b"One\n")
44+
45+
output, _ = self.run_subprocess_assert_returncode([
46+
"podman",
47+
"inspect",
48+
"override_tag_service_app_1",
49+
])
50+
container_info = json.loads(output.decode('utf-8'))[0]
51+
self.assertEqual(
52+
container_info['NetworkSettings']["Ports"],
53+
{"81/tcp": [{"HostIp": "", "HostPort": "8111"}]},
54+
)
55+
finally:
56+
self.run_subprocess_assert_returncode([
57+
podman_compose_path(),
58+
"-f",
59+
compose_yaml_path(),
60+
"down",
61+
])

0 commit comments

Comments
 (0)