diff options
author | Milas Bowman <milas.bowman@docker.com> | 2022-08-12 14:27:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-12 14:27:53 -0400 |
commit | e901eac7a8c5f29c7720eafb9f58c8356cca2324 (patch) | |
tree | 6cd2001cb03956b54c50384076521b8ab144abfc | |
parent | fc86ab0d8501b10dbe9be203625e9002cf3922ed (diff) | |
download | docker-py-e901eac7a8c5f29c7720eafb9f58c8356cca2324.tar.gz |
test: add additional tests for cgroupns option (#3024)6.0.0
See #2930.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
-rw-r--r-- | tests/integration/api_container_test.py | 14 | ||||
-rw-r--r-- | tests/unit/api_container_test.py | 19 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/integration/api_container_test.py b/tests/integration/api_container_test.py index 8f69e41..0cb8fec 100644 --- a/tests/integration/api_container_test.py +++ b/tests/integration/api_container_test.py @@ -215,6 +215,20 @@ class CreateContainerTest(BaseAPIIntegrationTest): self.client.kill(id) + @requires_api_version('1.41') + def test_create_with_cgroupns(self): + host_config = self.client.create_host_config(cgroupns='private') + + container = self.client.create_container( + image=TEST_IMG, + command=['sleep', '60'], + host_config=host_config, + ) + self.tmp_containers.append(container) + + res = self.client.inspect_container(container) + assert 'private' == res['HostConfig']['CgroupnsMode'] + def test_group_id_ints(self): container = self.client.create_container( TEST_IMG, 'id -G', diff --git a/tests/unit/api_container_test.py b/tests/unit/api_container_test.py index 3a2fbde..8f120f4 100644 --- a/tests/unit/api_container_test.py +++ b/tests/unit/api_container_test.py @@ -1069,6 +1069,25 @@ class CreateContainerTest(BaseAPIClientTest): ''') assert args[1]['headers'] == {'Content-Type': 'application/json'} + @requires_api_version('1.41') + def test_create_container_with_cgroupns(self): + self.client.create_container( + image='busybox', + command='true', + host_config=self.client.create_host_config( + cgroupns='private', + ), + ) + + args = fake_request.call_args + assert args[0][1] == url_prefix + 'containers/create' + + expected_payload = self.base_create_payload() + expected_payload['HostConfig'] = self.client.create_host_config() + expected_payload['HostConfig']['CgroupnsMode'] = 'private' + assert json.loads(args[1]['data']) == expected_payload + assert args[1]['headers'] == {'Content-Type': 'application/json'} + class ContainerTest(BaseAPIClientTest): def test_list_containers(self): |