Add tempest test for container rename
Change-Id: I5107b207f44ffdadab6f9ca8ba82b11a2e57db6c Partial-Implements: blueprint zun-functional-test
This commit is contained in:
parent
912ddbfb96
commit
2bd5d41e7d
|
@ -160,6 +160,12 @@ class ZunClient(rest_client.RestClient):
|
||||||
self.container_uri(container_id), body=model.to_json(), **kwargs)
|
self.container_uri(container_id), body=model.to_json(), **kwargs)
|
||||||
return self.deserialize(resp, body, container_model.ContainerEntity)
|
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):
|
def list_services(self, **kwargs):
|
||||||
resp, body = self.get(self.services_uri(), **kwargs)
|
resp, body = self.get(self.services_uri(), **kwargs)
|
||||||
return self.deserialize(resp, body,
|
return self.deserialize(resp, body,
|
||||||
|
|
|
@ -73,3 +73,14 @@ def container_patch_data(**kwargs):
|
||||||
model = container_model.ContainerPatchEntity.from_dict(data)
|
model = container_model.ContainerPatchEntity.from_dict(data)
|
||||||
|
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
||||||
|
def container_rename_data(**kwargs):
|
||||||
|
data = {
|
||||||
|
'name': 'new_name',
|
||||||
|
}
|
||||||
|
|
||||||
|
data.update(kwargs)
|
||||||
|
model = container_model.ContainerPatchEntity.from_dict(data)
|
||||||
|
|
||||||
|
return model
|
||||||
|
|
|
@ -166,6 +166,16 @@ class TestContainer(base.BaseZunTest):
|
||||||
container = self.docker_client.get_container(model.uuid)
|
container = self.docker_client.get_container(model.uuid)
|
||||||
self._assert_resource_constraints(container, cpu=0.2, memory=200)
|
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):
|
def _assert_resource_constraints(self, container, cpu=None, memory=None):
|
||||||
if cpu is not None:
|
if cpu is not None:
|
||||||
cpu_quota = container.get('HostConfig').get('CpuQuota')
|
cpu_quota = container.get('HostConfig').get('CpuQuota')
|
||||||
|
|
Loading…
Reference in New Issue