mirror of
https://github.com/containers/podman-compose.git
synced 2025-06-20 03:37:47 +02:00
Add unittest for pid limits
Signed-off-by: Elsa <zeyugao@outlook.com>
This commit is contained in:
parent
c3cac2c26b
commit
c381e118ee
@ -612,3 +612,82 @@ class TestContainerToArgs(unittest.IsolatedAsyncioTestCase):
|
|||||||
"busybox",
|
"busybox",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def test_pids_limit_container_level(self):
|
||||||
|
c = create_compose_mock()
|
||||||
|
cnt = get_minimal_container()
|
||||||
|
cnt["pids_limit"] = 100
|
||||||
|
|
||||||
|
args = await container_to_args(c, cnt)
|
||||||
|
self.assertEqual(
|
||||||
|
args,
|
||||||
|
[
|
||||||
|
"--name=project_name_service_name1",
|
||||||
|
"-d",
|
||||||
|
"--network=bridge:alias=service_name",
|
||||||
|
"--pids-limit", "100",
|
||||||
|
"busybox",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
async def test_pids_limit_deploy_section(self):
|
||||||
|
c = create_compose_mock()
|
||||||
|
cnt = get_minimal_container()
|
||||||
|
cnt["deploy"] = {
|
||||||
|
"resources": {
|
||||||
|
"limits": {
|
||||||
|
"pids": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
args = await container_to_args(c, cnt)
|
||||||
|
self.assertEqual(
|
||||||
|
args,
|
||||||
|
[
|
||||||
|
"--name=project_name_service_name1",
|
||||||
|
"-d",
|
||||||
|
"--network=bridge:alias=service_name",
|
||||||
|
"--pids-limit", "100",
|
||||||
|
"busybox",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
async def test_pids_limit_both_same(self):
|
||||||
|
c = create_compose_mock()
|
||||||
|
cnt = get_minimal_container()
|
||||||
|
cnt["pids_limit"] = 100
|
||||||
|
cnt["deploy"] = {
|
||||||
|
"resources": {
|
||||||
|
"limits": {
|
||||||
|
"pids": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
args = await container_to_args(c, cnt)
|
||||||
|
self.assertEqual(
|
||||||
|
args,
|
||||||
|
[
|
||||||
|
"--name=project_name_service_name1",
|
||||||
|
"-d",
|
||||||
|
"--network=bridge:alias=service_name",
|
||||||
|
"--pids-limit", "100",
|
||||||
|
"busybox",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
async def test_pids_limit_both_different(self):
|
||||||
|
c = create_compose_mock()
|
||||||
|
cnt = get_minimal_container()
|
||||||
|
cnt["pids_limit"] = 100
|
||||||
|
cnt["deploy"] = {
|
||||||
|
"resources": {
|
||||||
|
"limits": {
|
||||||
|
"pids": 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
await container_to_args(c, cnt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user