Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add additional tests for cgroupns option #3024

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/integration/api_container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ def test_create_with_mac_address(self):

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',
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/api_container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,25 @@ def test_create_container_with_host_config_cpus(self):
''')
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):
Expand Down