Debian Codegraph @

tests/integration/ulimit/test_podman_compose_ulimit.py

raw symbols SCIP
1 # SPDX-License-Identifier: GPL-2.0
2
3
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 class TestUlimit(unittest.TestCase, RunSubprocessMixin):
13 def test_ulimit(self) -> None:
14 compose_path = os.path.join(test_path(), "ulimit/docker-compose.yaml")
15 try:
16 self.run_subprocess_assert_returncode([
17 podman_compose_path(),
18 "-f",
19 compose_path,
20 "up",
21 "-d",
22 ])
23
24 out, _ = self.run_subprocess_assert_returncode([
25 "podman",
26 "logs",
27 "ulimit_ulimit1_1",
28 ])
29 split_output = out.strip(b"\n").split(b"\n")
30
31 # trow away system specific default ulimit values
32 output_part = [
33 el
34 for el in split_output
35 if not el.startswith(b"soft process") and not el.startswith(b"hard process")
36 ]
37 self.assertEqual(
38 output_part,
39 [
40 b"soft nofile limit 1001",
41 b"hard nofile limit 1001",
42 ],
43 )
44
45 out, _ = self.run_subprocess_assert_returncode([
46 "podman",
47 "logs",
48 "ulimit_ulimit2_1",
49 ])
50 self.assertEqual(
51 out,
52 b"soft process limit 1002\nhard process limit 2002\nsoft nofile limit 1002\n"
53 b"hard nofile limit 1002\n",
54 )
55
56 out, _ = self.run_subprocess_assert_returncode([
57 "podman",
58 "logs",
59 "ulimit_ulimit3_1",
60 ])
61 self.assertEqual(
62 out,
63 b"soft process limit 1003\nhard process limit 2003\nsoft nofile limit 1003\n"
64 b"hard nofile limit 1003\n",
65 )
66 finally:
67 self.run_subprocess_assert_returncode([
68 podman_compose_path(),
69 "-f",
70 compose_path,
71 "down",
72 ])