diff --git a/zun_tempest_plugin/tests/tempest/api/clients.py b/zun_tempest_plugin/tests/tempest/api/clients.py index eeed357..280a415 100644 --- a/zun_tempest_plugin/tests/tempest/api/clients.py +++ b/zun_tempest_plugin/tests/tempest/api/clients.py @@ -353,6 +353,10 @@ class ZunClient(rest_client.RestClient): return False utils.wait_for_condition(is_capsule_in_desired_state, timeout=120) + def list_capsules(self, **kwargs): + resp, body = self.get(self.capsules_uri(), **kwargs) + return self.deserialize(resp, body, capsule_model.CapsuleEntity) + def get_capsule(self, capsule_id, params=None): resp, body = self.get(self.capsule_uri(capsule_id, params=params)) return self.deserialize(resp, body, capsule_model.CapsuleEntity) @@ -360,6 +364,16 @@ class ZunClient(rest_client.RestClient): def delete_capsule(self, capsule_id, params=None): return self.delete(self.capsule_uri(capsule_id, params=params)) + def ensure_capsule_deleted(self, capsule_id): + def is_capsule_deleted(): + _, model = self.list_capsules() + capsule_ids = [c['uuid'] for c in model.capsules] + if capsule_id in capsule_ids: + return False + else: + return True + utils.wait_for_condition(is_capsule_deleted) + def delete_network(self, network_id, params=None): return self.delete(self.network_uri(network_id, params=params)) diff --git a/zun_tempest_plugin/tests/tempest/api/test_capsules.py b/zun_tempest_plugin/tests/tempest/api/test_capsules.py index 03d7a4a..7966789 100644 --- a/zun_tempest_plugin/tests/tempest/api/test_capsules.py +++ b/zun_tempest_plugin/tests/tempest/api/test_capsules.py @@ -22,7 +22,6 @@ class TestCapsule(base.BaseZunTest): credentials = ['primary', 'admin'] min_microversion = '1.12' - max_microversion = '1.31' @classmethod def get_client_manager(cls, credential_type=None, roles=None, @@ -41,7 +40,7 @@ class TestCapsule(base.BaseZunTest): def _create_capsule(self, **kwargs): gen_model = datagen.capsule_data(**kwargs) resp, model = self.container_client.post_capsule(gen_model) - self.addCleanup(self.container_client.delete_capsule, model.uuid) + self.addCleanup(self._delete_capsule, model.uuid) self.assertEqual(202, resp.status) # Wait for container to finish creation self.container_client.ensure_capsule_in_desired_state( @@ -54,6 +53,10 @@ class TestCapsule(base.BaseZunTest): # TODO(hongbin): verify all containers are running return resp, model + def _delete_capsule(self, uuid): + self.container_client.delete_capsule(uuid) + self.container_client.ensure_capsule_deleted(uuid) + @decorators.idempotent_id('b7e79a0b-c09e-4539-886f-a9f33ae15620') def test_create_capsule_full(self): capsule_data = {