mirror of
https://github.com/containers/podman-compose.git
synced 2025-02-05 21:09:46 +01:00
Merge pull request #1113 from mokibit/categorize-integration-tests
tests/integration: Categorize integration tests
This commit is contained in:
commit
d79ff01e77
1
tests/integration/additional_contexts/__init__.py
Normal file
1
tests/integration/additional_contexts/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -7,8 +7,8 @@ import os
|
||||
import subprocess
|
||||
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 podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/build/__init__.py
Normal file
1
tests/integration/build/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -5,8 +5,8 @@ import unittest
|
||||
|
||||
import requests
|
||||
|
||||
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 podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
from tests.integration.test_utils import RunSubprocessMixin
|
||||
|
||||
|
1
tests/integration/build_fail/__init__.py
Normal file
1
tests/integration/build_fail/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -3,9 +3,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
0
tests/integration/build_labels/__init__.py
Normal file
0
tests/integration/build_labels/__init__.py
Normal file
@ -5,9 +5,9 @@ import json
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
class TestBuildLabels(unittest.TestCase, RunSubprocessMixin):
|
||||
|
1
tests/integration/build_secrets/__init__.py
Normal file
1
tests/integration/build_secrets/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -7,8 +7,8 @@ import os
|
||||
import subprocess
|
||||
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 podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
@ -9,9 +9,9 @@ import unittest
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
|
||||
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
expected_lines = [
|
||||
"default: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFYQvN9a+toIB6jSs4zY7FMapZnHt80EKCUr/WhLwUum",
|
||||
|
1
tests/integration/default_net_behavior/__init__.py
Normal file
1
tests/integration/default_net_behavior/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -5,9 +5,9 @@ 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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path(scenario):
|
1
tests/integration/deps/__init__.py
Normal file
1
tests/integration/deps/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -2,9 +2,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path(suffix=""):
|
||||
@ -87,6 +87,58 @@ class TestComposeBaseDeps(unittest.TestCase, RunSubprocessMixin):
|
||||
"down",
|
||||
])
|
||||
|
||||
def test_podman_compose_run(self):
|
||||
"""
|
||||
This will test depends_on as well
|
||||
"""
|
||||
run_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "deps", "docker-compose.yaml"),
|
||||
"run",
|
||||
"--rm",
|
||||
"sleep",
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"wget -q -O - http://web:8000/hosts",
|
||||
]
|
||||
|
||||
out, _ = self.run_subprocess_assert_returncode(run_cmd)
|
||||
self.assertIn(b"127.0.0.1\tlocalhost", out)
|
||||
|
||||
# Run it again to make sure we can run it twice. I saw an issue where a second run, with
|
||||
# the container left up, would fail
|
||||
run_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "deps", "docker-compose.yaml"),
|
||||
"run",
|
||||
"--rm",
|
||||
"sleep",
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"wget -q -O - http://web:8000/hosts",
|
||||
]
|
||||
|
||||
out, _ = self.run_subprocess_assert_returncode(run_cmd)
|
||||
self.assertIn(b"127.0.0.1\tlocalhost", out)
|
||||
|
||||
# This leaves a container running. Not sure it's intended, but it matches docker-compose
|
||||
down_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "deps", "docker-compose.yaml"),
|
||||
"down",
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
|
||||
|
||||
class TestComposeConditionalDeps(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_deps_succeeds(self):
|
1
tests/integration/env-file-tests/__init__.py
Normal file
1
tests/integration/env-file-tests/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -3,9 +3,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_base_path():
|
1
tests/integration/env-tests/__init__.py
Normal file
1
tests/integration/env-tests/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -3,9 +3,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/exit-from/__init__.py
Normal file
1
tests/integration/exit-from/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -3,9 +3,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
||||
@ -52,3 +52,16 @@ class TestComposeExitFrom(unittest.TestCase, RunSubprocessMixin):
|
||||
compose_yaml_path(),
|
||||
"down",
|
||||
])
|
||||
|
||||
def test_podman_compose_exit_from(self):
|
||||
up_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "exit-from", "docker-compose.yaml"),
|
||||
"up",
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(up_cmd + ["--exit-code-from", "sh1"], 1)
|
||||
self.run_subprocess_assert_returncode(up_cmd + ["--exit-code-from", "sh2"], 2)
|
1
tests/integration/extends/__init__.py
Normal file
1
tests/integration/extends/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -3,9 +3,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/extends_w_empty_service/__init__.py
Normal file
1
tests/integration/extends_w_empty_service/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
||||
@ -37,3 +38,26 @@ class TestComposeExtendsWithEmptyService(unittest.TestCase, RunSubprocessMixin):
|
||||
compose_yaml_path(),
|
||||
"down",
|
||||
])
|
||||
|
||||
def test_podman_compose_extends_w_empty_service(self):
|
||||
"""
|
||||
Test that podman-compose can execute podman-compose -f <file> up with extended File which
|
||||
includes an empty service. (e.g. if the file is used as placeholder for more complex
|
||||
configurations.)
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_empty_service", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(command_up)
|
1
tests/integration/extends_w_file/__init__.py
Normal file
1
tests/integration/extends_w_file/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -3,9 +3,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/extends_w_file_subdir/__init__.py
Normal file
1
tests/integration/extends_w_file_subdir/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -5,31 +5,47 @@ import unittest
|
||||
from pathlib import Path
|
||||
|
||||
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 base_path():
|
||||
"""Returns the base path for the project"""
|
||||
return Path(__file__).parent.parent.parent
|
||||
def compose_yaml_path():
|
||||
return os.path.join(os.path.join(test_path(), "extends_w_file_subdir"), "docker-compose.yml")
|
||||
|
||||
|
||||
def test_path():
|
||||
"""Returns the path to the tests directory"""
|
||||
return os.path.join(base_path(), "tests/integration")
|
||||
class TestComposeExtendsWithFileSubdir(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_extends_w_file_subdir(self): # when file is Dockerfile for building the image
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(
|
||||
[
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"up",
|
||||
],
|
||||
)
|
||||
output, _ = self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"ps",
|
||||
])
|
||||
self.assertIn("extends_w_file_subdir_web_1", str(output))
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"down",
|
||||
])
|
||||
|
||||
|
||||
def podman_compose_path():
|
||||
"""Returns the path to the podman compose script"""
|
||||
return os.path.join(base_path(), "podman_compose.py")
|
||||
|
||||
|
||||
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_extends_w_file_subdir(self):
|
||||
def test_podman_compose_extends_w_file_subdir(self):
|
||||
"""
|
||||
Test that podman-compose can execute podman-compose -f <file> up with extended File which
|
||||
includes a build context
|
||||
:return:
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
main_path = Path(__file__).parent.parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"coverage",
|
||||
@ -86,26 +102,3 @@ class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
|
||||
# check container did not exists anymore
|
||||
out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
||||
self.assertEqual(out, b'')
|
||||
|
||||
def test_extends_w_empty_service(self):
|
||||
"""
|
||||
Test that podman-compose can execute podman-compose -f <file> up with extended File which
|
||||
includes an empty service. (e.g. if the file is used as placeholder for more complex
|
||||
configurations.)
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_empty_service", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(command_up)
|
1
tests/integration/filesystem/__init__.py
Normal file
1
tests/integration/filesystem/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -4,9 +4,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
class TestFilesystem(unittest.TestCase, RunSubprocessMixin):
|
1
tests/integration/in_pod/__init__.py
Normal file
1
tests/integration/in_pod/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -8,7 +8,7 @@ from tests.integration.test_utils import RunSubprocessMixin
|
||||
|
||||
def base_path():
|
||||
"""Returns the base path for the project"""
|
||||
return os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
return os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||
|
||||
|
||||
def test_path():
|
1
tests/integration/include/__init__.py
Normal file
1
tests/integration/include/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -12,7 +12,7 @@ class TestPodmanComposeInclude(unittest.TestCase, RunSubprocessMixin):
|
||||
Test that podman-compose can execute podman-compose -f <file> up with include
|
||||
:return:
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
main_path = Path(__file__).parent.parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"coverage",
|
1
tests/integration/interpolation/__init__.py
Normal file
1
tests/integration/interpolation/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -3,9 +3,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/ipam_default/__init__.py
Normal file
1
tests/integration/ipam_default/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -4,9 +4,9 @@ import json
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
@ -6,9 +6,9 @@ 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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
class TestLifetime(unittest.TestCase, RunSubprocessMixin):
|
||||
|
1
tests/integration/multicompose/__init__.py
Normal file
1
tests/integration/multicompose/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -3,9 +3,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/nethost/__init__.py
Normal file
1
tests/integration/nethost/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -5,9 +5,9 @@ import unittest
|
||||
|
||||
import requests
|
||||
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/nets_test1/__init__.py
Normal file
1
tests/integration/nets_test1/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -6,9 +6,9 @@ import unittest
|
||||
|
||||
import requests
|
||||
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/nets_test2/__init__.py
Normal file
1
tests/integration/nets_test2/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -6,9 +6,9 @@ import unittest
|
||||
|
||||
import requests
|
||||
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/network/__init__.py
Normal file
1
tests/integration/network/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -10,9 +10,9 @@ Tests the podman networking parameters
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
class TestPodmanComposeNetwork(RunSubprocessMixin, unittest.TestCase):
|
||||
@ -114,3 +114,28 @@ class TestPodmanComposeNetwork(RunSubprocessMixin, unittest.TestCase):
|
||||
ip, mac = values
|
||||
self.assertIn(f"ether {mac}", out.decode('utf-8'))
|
||||
self.assertIn(f"inet {ip}/", out.decode('utf-8'))
|
||||
|
||||
def test_down_with_network(self):
|
||||
try:
|
||||
self.run_subprocess_assert_returncode([
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "network", "docker-compose.yml"),
|
||||
"up",
|
||||
"-d",
|
||||
])
|
||||
output, _, _ = self.run_subprocess(["podman", "network", "ls"])
|
||||
self.assertIn("network_mystack", output.decode())
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode([
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "network", "docker-compose.yml"),
|
||||
"down",
|
||||
])
|
||||
output, _, _ = self.run_subprocess(["podman", "network", "ls"])
|
||||
self.assertNotIn("network_mystack", output.decode())
|
1
tests/integration/network_scoped_aliases/__init__.py
Normal file
1
tests/integration/network_scoped_aliases/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -4,9 +4,9 @@
|
||||
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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
class TestPodmanComposeNetworkScopedAliases(RunSubprocessMixin, unittest.TestCase):
|
1
tests/integration/ports/__init__.py
Normal file
1
tests/integration/ports/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
85
tests/integration/ports/test_podman_compose_ports.py
Normal file
85
tests/integration/ports/test_podman_compose_ports.py
Normal file
@ -0,0 +1,85 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
"""
|
||||
test_podman_compose_up_down.py
|
||||
|
||||
Tests the podman compose up and down commands used to create and remove services.
|
||||
"""
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests.integration.test_utils import RunSubprocessMixin
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_up_with_ports(self):
|
||||
up_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "ports", "docker-compose.yml"),
|
||||
"up",
|
||||
"-d",
|
||||
"--force-recreate",
|
||||
]
|
||||
|
||||
down_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "ports", "docker-compose.yml"),
|
||||
"down",
|
||||
"--volumes",
|
||||
]
|
||||
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(up_cmd)
|
||||
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
|
||||
def test_down_with_orphans(self):
|
||||
container_id, _ = self.run_subprocess_assert_returncode([
|
||||
"podman",
|
||||
"run",
|
||||
"--rm",
|
||||
"-d",
|
||||
"nopush/podman-compose-test",
|
||||
"dumb-init",
|
||||
"/bin/busybox",
|
||||
"httpd",
|
||||
"-f",
|
||||
"-h",
|
||||
"/etc/",
|
||||
"-p",
|
||||
"8000",
|
||||
])
|
||||
|
||||
down_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "ports", "docker-compose.yml"),
|
||||
"down",
|
||||
"--volumes",
|
||||
"--remove-orphans",
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
|
||||
self.run_subprocess_assert_returncode(
|
||||
[
|
||||
"podman",
|
||||
"container",
|
||||
"exists",
|
||||
container_id.decode("utf-8"),
|
||||
],
|
||||
1,
|
||||
)
|
1
tests/integration/profile/__init__.py
Normal file
1
tests/integration/profile/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -12,9 +12,9 @@ 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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def profile_compose_file():
|
@ -12,9 +12,9 @@ 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
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def profile_compose_file():
|
@ -1,39 +0,0 @@
|
||||
# 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_w_file_subdir"), "docker-compose.yml")
|
||||
|
||||
|
||||
class TestComposeExtendsWithFileSubdir(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_extends_w_file_subdir(self): # when file is Dockerfile for building the image
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(
|
||||
[
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"up",
|
||||
],
|
||||
)
|
||||
output, _ = self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"ps",
|
||||
])
|
||||
self.assertIn("extends_w_file_subdir_web_1", str(output))
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"down",
|
||||
])
|
@ -1,214 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
"""
|
||||
test_podman_compose_up_down.py
|
||||
|
||||
Tests the podman compose up and down commands used to create and remove services.
|
||||
"""
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
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
|
||||
|
||||
|
||||
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_exit_from(self):
|
||||
up_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "exit-from", "docker-compose.yaml"),
|
||||
"up",
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(up_cmd + ["--exit-code-from", "sh1"], 1)
|
||||
self.run_subprocess_assert_returncode(up_cmd + ["--exit-code-from", "sh2"], 2)
|
||||
|
||||
def test_run(self):
|
||||
"""
|
||||
This will test depends_on as well
|
||||
"""
|
||||
run_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "deps", "docker-compose.yaml"),
|
||||
"run",
|
||||
"--rm",
|
||||
"sleep",
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"wget -q -O - http://web:8000/hosts",
|
||||
]
|
||||
|
||||
out, _ = self.run_subprocess_assert_returncode(run_cmd)
|
||||
self.assertIn(b"127.0.0.1\tlocalhost", out)
|
||||
|
||||
# Run it again to make sure we can run it twice. I saw an issue where a second run, with
|
||||
# the container left up, would fail
|
||||
run_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "deps", "docker-compose.yaml"),
|
||||
"run",
|
||||
"--rm",
|
||||
"sleep",
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"wget -q -O - http://web:8000/hosts",
|
||||
]
|
||||
|
||||
out, _ = self.run_subprocess_assert_returncode(run_cmd)
|
||||
self.assertIn(b"127.0.0.1\tlocalhost", out)
|
||||
|
||||
# This leaves a container running. Not sure it's intended, but it matches docker-compose
|
||||
down_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "deps", "docker-compose.yaml"),
|
||||
"down",
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
|
||||
def test_up_with_ports(self):
|
||||
up_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "ports", "docker-compose.yml"),
|
||||
"up",
|
||||
"-d",
|
||||
"--force-recreate",
|
||||
]
|
||||
|
||||
down_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "ports", "docker-compose.yml"),
|
||||
"down",
|
||||
"--volumes",
|
||||
]
|
||||
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(up_cmd)
|
||||
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
|
||||
def test_down_with_vols(self):
|
||||
up_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "vol", "docker-compose.yaml"),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
down_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "vol", "docker-compose.yaml"),
|
||||
"down",
|
||||
"--volumes",
|
||||
]
|
||||
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(["podman", "volume", "create", "my-app-data"])
|
||||
self.run_subprocess_assert_returncode([
|
||||
"podman",
|
||||
"volume",
|
||||
"create",
|
||||
"actual-name-of-volume",
|
||||
])
|
||||
|
||||
self.run_subprocess_assert_returncode(up_cmd)
|
||||
self.run_subprocess(["podman", "inspect", "volume", ""])
|
||||
|
||||
finally:
|
||||
out, _, return_code = self.run_subprocess(down_cmd)
|
||||
self.run_subprocess(["podman", "volume", "rm", "my-app-data"])
|
||||
self.run_subprocess(["podman", "volume", "rm", "actual-name-of-volume"])
|
||||
self.assertEqual(return_code, 0)
|
||||
|
||||
def test_down_with_orphans(self):
|
||||
container_id, _ = self.run_subprocess_assert_returncode([
|
||||
"podman",
|
||||
"run",
|
||||
"--rm",
|
||||
"-d",
|
||||
"nopush/podman-compose-test",
|
||||
"dumb-init",
|
||||
"/bin/busybox",
|
||||
"httpd",
|
||||
"-f",
|
||||
"-h",
|
||||
"/etc/",
|
||||
"-p",
|
||||
"8000",
|
||||
])
|
||||
|
||||
down_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "ports", "docker-compose.yml"),
|
||||
"down",
|
||||
"--volumes",
|
||||
"--remove-orphans",
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
|
||||
self.run_subprocess_assert_returncode(
|
||||
[
|
||||
"podman",
|
||||
"container",
|
||||
"exists",
|
||||
container_id.decode("utf-8"),
|
||||
],
|
||||
1,
|
||||
)
|
||||
|
||||
def test_down_with_network(self):
|
||||
try:
|
||||
self.run_subprocess_assert_returncode([
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "network", "docker-compose.yml"),
|
||||
"up",
|
||||
"-d",
|
||||
])
|
||||
output, _, _ = self.run_subprocess(["podman", "network", "ls"])
|
||||
self.assertIn("network_mystack", output.decode())
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode([
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "network", "docker-compose.yml"),
|
||||
"down",
|
||||
])
|
||||
output, _, _ = self.run_subprocess(["podman", "network", "ls"])
|
||||
self.assertNotIn("network_mystack", output.decode())
|
@ -3,6 +3,22 @@
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def base_path():
|
||||
"""Returns the base path for the project"""
|
||||
return Path(__file__).parent.parent.parent
|
||||
|
||||
|
||||
def test_path():
|
||||
"""Returns the path to the tests directory"""
|
||||
return os.path.join(base_path(), "tests/integration")
|
||||
|
||||
|
||||
def podman_compose_path():
|
||||
"""Returns the path to the podman compose script"""
|
||||
return os.path.join(base_path(), "podman_compose.py")
|
||||
|
||||
|
||||
class RunSubprocessMixin:
|
||||
|
1
tests/integration/ulimit_build/__init__.py
Normal file
1
tests/integration/ulimit_build/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -7,8 +7,8 @@ import os
|
||||
import subprocess
|
||||
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 podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
1
tests/integration/vol/__init__.py
Normal file
1
tests/integration/vol/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
56
tests/integration/vol/test_podman_compose_vol.py
Normal file
56
tests/integration/vol/test_podman_compose_vol.py
Normal file
@ -0,0 +1,56 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
"""
|
||||
test_podman_compose_up_down.py
|
||||
|
||||
Tests the podman compose up and down commands used to create and remove services.
|
||||
"""
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests.integration.test_utils import RunSubprocessMixin
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_down_with_vols(self):
|
||||
up_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "vol", "docker-compose.yaml"),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
down_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
os.path.join(test_path(), "vol", "docker-compose.yaml"),
|
||||
"down",
|
||||
"--volumes",
|
||||
]
|
||||
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(["podman", "volume", "create", "my-app-data"])
|
||||
self.run_subprocess_assert_returncode([
|
||||
"podman",
|
||||
"volume",
|
||||
"create",
|
||||
"actual-name-of-volume",
|
||||
])
|
||||
|
||||
self.run_subprocess_assert_returncode(up_cmd)
|
||||
self.run_subprocess(["podman", "inspect", "volume", ""])
|
||||
|
||||
finally:
|
||||
out, _, return_code = self.run_subprocess(down_cmd)
|
||||
self.run_subprocess(["podman", "volume", "rm", "my-app-data"])
|
||||
self.run_subprocess(["podman", "volume", "rm", "actual-name-of-volume"])
|
||||
self.assertEqual(return_code, 0)
|
Loading…
Reference in New Issue
Block a user