| 1 |
|
| 2 |
|
| 3 |
import os |
| 4 |
import unittest |
| 5 |
|
| 6 |
from parameterized import parameterized |
| 7 |
|
| 8 |
from tests.integration.test_utils import RunSubprocessMixin |
| 9 |
from tests.integration.test_utils import podman_compose_path |
| 10 |
from tests.integration.test_utils import test_path |
| 11 |
|
| 12 |
|
| 13 |
def compose_yaml_path(failure_order: str) -> str: |
| 14 |
return os.path.join(test_path(), "abort", f"docker-compose-fail-{failure_order}.yaml") |
| 15 |
|
| 16 |
|
| 17 |
class TestComposeAbort(unittest.TestCase, RunSubprocessMixin): |
| 18 |
@parameterized.expand([ |
| 19 |
("exit", "first", 0), |
| 20 |
("failure", "first", 1), |
| 21 |
("exit", "second", 0), |
| 22 |
("failure", "second", 1), |
| 23 |
("exit", "simultaneous", 0), |
| 24 |
("failure", "simultaneous", 1), |
| 25 |
("exit", "none", 0), |
| 26 |
("failure", "none", 0), |
| 27 |
]) |
| 28 |
def test_abort(self, abort_type: str, failure_order: str, expected_exit_code: int) -> None: |
| 29 |
try: |
| 30 |
self.run_subprocess_assert_returncode( |
| 31 |
[ |
| 32 |
podman_compose_path(), |
| 33 |
"-f", |
| 34 |
compose_yaml_path(failure_order), |
| 35 |
"up", |
| 36 |
f"--abort-on-container-{abort_type}", |
| 37 |
], |
| 38 |
expected_exit_code, |
| 39 |
) |
| 40 |
finally: |
| 41 |
self.run_subprocess_assert_returncode([ |
| 42 |
podman_compose_path(), |
| 43 |
"-f", |
| 44 |
compose_yaml_path(failure_order), |
| 45 |
"down", |
| 46 |
]) |