Merge "Add tempest test for rebuild"
This commit is contained in:
commit
7eae05b45e
|
@ -153,6 +153,11 @@ class ZunClient(rest_client.RestClient):
|
||||||
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
def container_action_uri(cls, container_id, request_id):
|
||||||
|
url = "/containers/{0}/container_actions/{1}".format(
|
||||||
|
container_id, request_id)
|
||||||
|
return url
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_params(cls, url, params):
|
def add_params(cls, url, params):
|
||||||
"""add_params adds dict values (params) to url as query parameters
|
"""add_params adds dict values (params) to url as query parameters
|
||||||
|
@ -258,6 +263,10 @@ class ZunClient(rest_client.RestClient):
|
||||||
return self.post(
|
return self.post(
|
||||||
self.container_uri(container_id, action='reboot'), None, **kwargs)
|
self.container_uri(container_id, action='reboot'), None, **kwargs)
|
||||||
|
|
||||||
|
def rebuild_container(self, container_id, **kwargs):
|
||||||
|
return self.post(
|
||||||
|
self.container_uri(container_id, action='rebuild'), None, **kwargs)
|
||||||
|
|
||||||
def exec_container(self, container_id, command, **kwargs):
|
def exec_container(self, container_id, command, **kwargs):
|
||||||
return self.post(
|
return self.post(
|
||||||
self.container_uri(container_id, action='execute'),
|
self.container_uri(container_id, action='execute'),
|
||||||
|
@ -301,6 +310,12 @@ class ZunClient(rest_client.RestClient):
|
||||||
return self.deserialize(resp, body,
|
return self.deserialize(resp, body,
|
||||||
service_model.ServiceCollection)
|
service_model.ServiceCollection)
|
||||||
|
|
||||||
|
def get_container_action(self, container_id, request_id):
|
||||||
|
resp, body = self.get(
|
||||||
|
self.container_action_uri(container_id, request_id))
|
||||||
|
return self.deserialize(
|
||||||
|
resp, body, container_model.ContainerActionEntity)
|
||||||
|
|
||||||
def ensure_container_in_desired_state(self, container_id, status):
|
def ensure_container_in_desired_state(self, container_id, status):
|
||||||
def is_container_in_desired_state():
|
def is_container_in_desired_state():
|
||||||
_, container = self.get_container(container_id)
|
_, container = self.get_container(container_id)
|
||||||
|
@ -320,6 +335,15 @@ class ZunClient(rest_client.RestClient):
|
||||||
return True
|
return True
|
||||||
utils.wait_for_condition(is_container_deleted)
|
utils.wait_for_condition(is_container_deleted)
|
||||||
|
|
||||||
|
def ensure_action_finished(self, container_id, request_id):
|
||||||
|
def is_action_finished():
|
||||||
|
_, action = self.get_container_action(container_id, request_id)
|
||||||
|
if action.finish_time is not None:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
utils.wait_for_condition(is_action_finished, timeout=120)
|
||||||
|
|
||||||
def network_attach(self, container_id, params=None, **kwargs):
|
def network_attach(self, container_id, params=None, **kwargs):
|
||||||
return self.post(
|
return self.post(
|
||||||
self.container_uri(container_id, action='network_attach',
|
self.container_uri(container_id, action='network_attach',
|
||||||
|
|
|
@ -39,3 +39,14 @@ class ContainerPatchEntity(base_model.EntityModel):
|
||||||
"""Entity Model that represents a single instance of ContainerPatchData"""
|
"""Entity Model that represents a single instance of ContainerPatchData"""
|
||||||
ENTITY_NAME = 'containerpatch'
|
ENTITY_NAME = 'containerpatch'
|
||||||
MODEL_TYPE = ContainerPatchData
|
MODEL_TYPE = ContainerPatchData
|
||||||
|
|
||||||
|
|
||||||
|
class ContainerActionData(base_model.BaseModel):
|
||||||
|
"""Data that encapsulates container action attributes"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ContainerActionEntity(base_model.EntityModel):
|
||||||
|
"""Entity Model that represents a single instance of ContainerActionData"""
|
||||||
|
ENTITY_NAME = 'containeraction'
|
||||||
|
MODEL_TYPE = ContainerActionData
|
||||||
|
|
|
@ -608,6 +608,26 @@ class TestContainer(base.BaseZunTest):
|
||||||
self.assertEqual(202, resp.status)
|
self.assertEqual(202, resp.status)
|
||||||
# TODO(hongbin): wait for reboot to complete and assure it succeeds
|
# TODO(hongbin): wait for reboot to complete and assure it succeeds
|
||||||
|
|
||||||
|
@decorators.idempotent_id('a0c8843f-c32e-4658-b228-eb16c746f495')
|
||||||
|
@utils.requires_microversion('1.33')
|
||||||
|
def test_rebuild_container(self):
|
||||||
|
_, model = self._run_container()
|
||||||
|
|
||||||
|
resp, _ = self.container_client.rebuild_container(model.uuid)
|
||||||
|
self.assertEqual(202, resp.status)
|
||||||
|
request_id = self._get_request_id(resp)
|
||||||
|
# Wait for container to rebuild
|
||||||
|
self.container_client.ensure_action_finished(
|
||||||
|
model.uuid, request_id)
|
||||||
|
|
||||||
|
resp, action = self.container_client.get_container_action(
|
||||||
|
model.uuid, request_id)
|
||||||
|
self.assertEqual(200, resp.status)
|
||||||
|
# if the action succeeds, action.message will be None
|
||||||
|
self.assertIsNone(action.message)
|
||||||
|
self.container_client.ensure_container_in_desired_state(
|
||||||
|
model.uuid, 'Running')
|
||||||
|
|
||||||
@decorators.idempotent_id('8a591ff8-6793-427f-82a6-e3921d8b4f81')
|
@decorators.idempotent_id('8a591ff8-6793-427f-82a6-e3921d8b4f81')
|
||||||
def test_exec_container(self):
|
def test_exec_container(self):
|
||||||
_, model = self._run_container()
|
_, model = self._run_container()
|
||||||
|
|
|
@ -155,3 +155,6 @@ class BaseZunTest(api_version_utils.BaseMicroversionTest,
|
||||||
subnetpool = client.create_subnetpool(**kwargs)['subnetpool']
|
subnetpool = client.create_subnetpool(**kwargs)['subnetpool']
|
||||||
self.addCleanup(client.delete_subnetpool, subnetpool['id'])
|
self.addCleanup(client.delete_subnetpool, subnetpool['id'])
|
||||||
return subnetpool
|
return subnetpool
|
||||||
|
|
||||||
|
def _get_request_id(self, resp):
|
||||||
|
return resp.get('x-openstack-request-id', '')
|
||||||
|
|
Loading…
Reference in New Issue