Files
.github
completion
docs
examples
newsfragments
scripts
tests
integration
abort
additional_contexts
base_image
build
build_fail
build_fail_multi
build_labels
build_secrets
build_ssh
default_net_behavior
deps
env-file-tests
env-tests
exit-from
extends
extends_w_empty_service
extends_w_file
extends_w_file_subdir
filesystem
in_pod
include
interpolation
ipam_default
lifetime
merge
multicompose
nethost
nets_test1
nets_test2
nets_test3
docker-compose.yml
test1.txt
test2.txt
test3.txt
test_podman_compose_nets_test3.py
nets_test_ip
network
network_interface_name
network_scoped_aliases
no_services
pid
pod_args
ports
profile
seccomp
secrets
selinux
service_scale
short
testlogs
uidmaps
ulimit
ulimit_build
up_down
vol
yamlmagic
__init__.py
test_utils.py
unit
.codespellignore
.codespellrc
.coveragerc
.editorconfig
.gitignore
.pre-commit-config.yaml
.pylintrc
CODE-OF-CONDUCT.md
CONTRIBUTING.md
Dockerfile
LICENSE
README.md
RELEASING.md
SECURITY.md
podman_compose.py
pyproject.toml
requirements.txt
setup.cfg
setup.py
test-requirements.txt
podman-compose/tests/integration/nets_test3/test_podman_compose_nets_test3.py
Monika Kairaityte 29404af723 tests/integration: Automate manual 'nets_test3' test
Signed-off-by: Monika Kairaityte <monika@kibit.lt>
2025-02-03 19:04:15 +02:00

69 lines
2.3 KiB
Python

# SPDX-License-Identifier: GPL-2.0
import os
import unittest
from parameterized import parameterized
from tests.integration.test_utils import RunSubprocessMixin
from tests.integration.test_utils import podman_compose_path
from tests.integration.test_utils import test_path
def compose_yaml_path():
return os.path.join(os.path.join(test_path(), "nets_test3"), "docker-compose.yml")
class TestComposeNetsTest3(unittest.TestCase, RunSubprocessMixin):
# test if services can access the networks of other services using their respective aliases
@parameterized.expand([
("nets_test3_web2_1", "web3", b"test3", 0),
("nets_test3_web2_1", "alias11", b"test3", 0),
("nets_test3_web2_1", "alias12", b"test3", 0),
("nets_test3_web2_1", "alias21", b"test3", 0),
("nets_test3_web1_1", "web3", b"test3", 0),
("nets_test3_web1_1", "alias11", b"test3", 0),
("nets_test3_web1_1", "alias12", b"test3", 0),
# connection fails as web1 service does not know net2 and its aliases
("nets_test3_web1_1", "alias21", b"", 1),
])
def test_nets_test3(
self, container_name, nework_alias_name, expected_text, expected_returncode
):
try:
self.run_subprocess_assert_returncode(
[
podman_compose_path(),
"-f",
compose_yaml_path(),
"up",
"-d",
],
)
# check connection from different services to network aliases of web3 service
cmd = [
"podman",
"exec",
"-it",
f"{container_name}",
"/bin/busybox",
"wget",
"-O",
"-",
"-o",
"/dev/null",
f"http://{nework_alias_name}:8001/index.txt",
]
out, _, returncode = self.run_subprocess(cmd)
self.assertEqual(expected_returncode, returncode)
self.assertEqual(expected_text, out.strip())
finally:
self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"down",
"-t",
"0",
])