Browse Source

Merge "Add tempest test for container rename"

changes/33/466933/1
Jenkins 4 years ago
committed by Gerrit Code Review
parent
commit
8226aaf033
  1. 6
      zun/tests/tempest/api/clients.py
  2. 11
      zun/tests/tempest/api/common/datagen.py
  3. 10
      zun/tests/tempest/api/test_containers.py

6
zun/tests/tempest/api/clients.py

@ -160,6 +160,12 @@ class ZunClient(rest_client.RestClient):
self.container_uri(container_id), body=model.to_json(), **kwargs)
return self.deserialize(resp, body, container_model.ContainerEntity)
def rename_container(self, container_id, model, **kwargs):
resp, body = self.post(
self.container_uri(container_id, action='rename'),
body=model.to_json(), **kwargs)
return self.deserialize(resp, body, container_model.ContainerEntity)
def list_services(self, **kwargs):
resp, body = self.get(self.services_uri(), **kwargs)
return self.deserialize(resp, body,

11
zun/tests/tempest/api/common/datagen.py

@ -73,3 +73,14 @@ def container_patch_data(**kwargs):
model = container_model.ContainerPatchEntity.from_dict(data)
return model
def container_rename_data(**kwargs):
data = {
'name': 'new_name',
}
data.update(kwargs)
model = container_model.ContainerPatchEntity.from_dict(data)
return model

10
zun/tests/tempest/api/test_containers.py

@ -166,6 +166,16 @@ class TestContainer(base.BaseZunTest):
container = self.docker_client.get_container(model.uuid)
self._assert_resource_constraints(container, cpu=0.2, memory=200)
@decorators.idempotent_id('b218bea7-f19b-499f-9819-c7021ffc59f4')
def test_rename_container(self):
_, model = self._run_container(name='container1')
self.assertEqual('container1', model.name)
gen_model = datagen.container_rename_data(name='container2')
resp, model = self.container_client.rename_container(model.uuid,
gen_model)
self.assertEqual(200, resp.status)
self.assertEqual('container2', model.name)
def _assert_resource_constraints(self, container, cpu=None, memory=None):
if cpu is not None:
cpu_quota = container.get('HostConfig').get('CpuQuota')

Loading…
Cancel
Save