Skip to content

Commit e901eac

Browse files
authored
test: add additional tests for cgroupns option (#3024)
See #2930. Signed-off-by: Milas Bowman <[email protected]>
1 parent fc86ab0 commit e901eac

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tests/integration/api_container_test.py

+14
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,20 @@ def test_create_with_mac_address(self):
215215

216216
self.client.kill(id)
217217

218+
@requires_api_version('1.41')
219+
def test_create_with_cgroupns(self):
220+
host_config = self.client.create_host_config(cgroupns='private')
221+
222+
container = self.client.create_container(
223+
image=TEST_IMG,
224+
command=['sleep', '60'],
225+
host_config=host_config,
226+
)
227+
self.tmp_containers.append(container)
228+
229+
res = self.client.inspect_container(container)
230+
assert 'private' == res['HostConfig']['CgroupnsMode']
231+
218232
def test_group_id_ints(self):
219233
container = self.client.create_container(
220234
TEST_IMG, 'id -G',

tests/unit/api_container_test.py

+19
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,25 @@ def test_create_container_with_host_config_cpus(self):
10691069
''')
10701070
assert args[1]['headers'] == {'Content-Type': 'application/json'}
10711071

1072+
@requires_api_version('1.41')
1073+
def test_create_container_with_cgroupns(self):
1074+
self.client.create_container(
1075+
image='busybox',
1076+
command='true',
1077+
host_config=self.client.create_host_config(
1078+
cgroupns='private',
1079+
),
1080+
)
1081+
1082+
args = fake_request.call_args
1083+
assert args[0][1] == url_prefix + 'containers/create'
1084+
1085+
expected_payload = self.base_create_payload()
1086+
expected_payload['HostConfig'] = self.client.create_host_config()
1087+
expected_payload['HostConfig']['CgroupnsMode'] = 'private'
1088+
assert json.loads(args[1]['data']) == expected_payload
1089+
assert args[1]['headers'] == {'Content-Type': 'application/json'}
1090+
10721091

10731092
class ContainerTest(BaseAPIClientTest):
10741093
def test_list_containers(self):

0 commit comments

Comments
 (0)