-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test for default network behavior
Signed-off-by: Songmin Li <[email protected]>
- Loading branch information
Showing
9 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
tests/integration/default_net_behavior/docker-compose_no_nets.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
services: | ||
web: | ||
image: busybox | ||
command: httpd -f -p 8123 -h /tmp/ |
7 changes: 7 additions & 0 deletions
7
tests/integration/default_net_behavior/docker-compose_no_nets_compat.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
web: | ||
image: busybox | ||
command: httpd -f -p 8123 -h /tmp/ | ||
|
||
x-podman: | ||
default_net_behavior_compat: true |
7 changes: 7 additions & 0 deletions
7
tests/integration/default_net_behavior/docker-compose_one_net.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
web: | ||
image: busybox | ||
command: httpd -f -p 8123 -h /tmp/ | ||
|
||
networks: | ||
net0: {} |
10 changes: 10 additions & 0 deletions
10
tests/integration/default_net_behavior/docker-compose_one_net_compat.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
web: | ||
image: busybox | ||
command: httpd -f -p 8123 -h /tmp/ | ||
|
||
networks: | ||
net0: {} | ||
|
||
x-podman: | ||
default_net_behavior_compat: true |
8 changes: 8 additions & 0 deletions
8
tests/integration/default_net_behavior/docker-compose_two_nets.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
web: | ||
image: busybox | ||
command: httpd -f -p 8123 -h /tmp/ | ||
|
||
networks: | ||
net0: {} | ||
net1: {} |
11 changes: 11 additions & 0 deletions
11
tests/integration/default_net_behavior/docker-compose_two_nets_compat.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
services: | ||
web: | ||
image: busybox | ||
command: httpd -f -p 8123 -h /tmp/ | ||
|
||
networks: | ||
net0: {} | ||
net1: {} | ||
|
||
x-podman: | ||
default_net_behavior_compat: true |
9 changes: 9 additions & 0 deletions
9
tests/integration/default_net_behavior/docker-compose_with_default.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
web: | ||
image: busybox | ||
command: httpd -f -p 8123 -h /tmp/ | ||
|
||
networks: | ||
net0: {} | ||
net1: {} | ||
default: {} |
12 changes: 12 additions & 0 deletions
12
tests/integration/default_net_behavior/docker-compose_with_default_compat.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
services: | ||
web: | ||
image: busybox | ||
command: httpd -f -p 8123 -h /tmp/ | ||
|
||
networks: | ||
net0: {} | ||
net1: {} | ||
default: {} | ||
|
||
x-podman: | ||
default_net_behavior_compat: true |
65 changes: 65 additions & 0 deletions
65
tests/integration/test_podman_compose_default_net_behavior.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
import os | ||
import unittest | ||
|
||
from parameterized import parameterized | ||
|
||
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(scenario): | ||
return os.path.join( | ||
os.path.join(test_path(), "default_net_behavior"), f"docker-compose_{scenario}.yaml" | ||
) | ||
|
||
|
||
class TestComposeDefaultNetBehavior(unittest.TestCase, RunSubprocessMixin): | ||
@parameterized.expand([ | ||
('no_nets', 'default_net_behavior_default'), | ||
('one_net', 'default_net_behavior_net0'), | ||
('two_nets', 'podman'), | ||
('with_default', 'default_net_behavior_default'), | ||
('no_nets_compat', 'default_net_behavior_default'), | ||
('one_net_compat', 'default_net_behavior_default'), | ||
('two_nets_compat', 'default_net_behavior_default'), | ||
('with_default_compat', 'default_net_behavior_default'), | ||
]) | ||
def test_nethost(self, scenario, default_net): | ||
try: | ||
self.run_subprocess_assert_returncode( | ||
[podman_compose_path(), "-f", compose_yaml_path(scenario), "up", "-d"], | ||
) | ||
|
||
container_id, _ = self.run_subprocess_assert_returncode( | ||
[ | ||
podman_compose_path(), | ||
"-f", | ||
compose_yaml_path(scenario), | ||
"ps", | ||
"--format", | ||
'{{.ID}}', | ||
], | ||
) | ||
container_id = container_id.decode('utf-8').split('\n')[0] | ||
output, _ = self.run_subprocess_assert_returncode( | ||
[ | ||
"podman", | ||
"inspect", | ||
container_id, | ||
"--format", | ||
"{{range $key, $value := .NetworkSettings.Networks }}{{ $key }}\n{{ end }}", | ||
], | ||
) | ||
self.assertEqual(output.decode('utf-8').strip(), default_net) | ||
finally: | ||
self.run_subprocess_assert_returncode([ | ||
podman_compose_path(), | ||
"-f", | ||
compose_yaml_path(scenario), | ||
"down", | ||
"-t", | ||
"0", | ||
]) |