diff --git a/mistral_tempest_tests/services/base.py b/mistral_tempest_tests/services/base.py index 5ee7d51..50030f2 100644 --- a/mistral_tempest_tests/services/base.py +++ b/mistral_tempest_tests/services/base.py @@ -79,7 +79,19 @@ class MistralClientBase(rest_client.RestClient): return resp, json.loads(body) - def delete_obj(self, obj, name): + def delete_obj(self, obj, name, force=None): + if force: + # TODO(apetrich) This try except is a partial implementation + # to be removed once force deletion lands in mistral + try: + return self.delete('{obj}/{name}?force={force}'.format( + obj=obj, + name=name, + force=bool(force)) + ) + except Exception: + pass + return self.delete('{obj}/{name}'.format(obj=obj, name=name)) def get_object(self, obj, id): diff --git a/mistral_tempest_tests/tests/api/v2/test_executions.py b/mistral_tempest_tests/tests/api/v2/test_executions.py index b577ff2..df50d7b 100644 --- a/mistral_tempest_tests/tests/api/v2/test_executions.py +++ b/mistral_tempest_tests/tests/api/v2/test_executions.py @@ -44,7 +44,7 @@ class ExecutionTestsV2(base.TestCase): self.client.workflows = [] for ex in self.client.executions: - self.client.delete_obj('executions', ex) + self.client.delete_obj('executions', ex, force=True) self.client.executions = [] super(ExecutionTestsV2, self).tearDown() @@ -317,7 +317,11 @@ class ExecutionTestsV2(base.TestCase): def test_delete_execution_by_admin(self): _, body = self.client.create_execution(self.direct_wf_id) exec_id = body['id'] - resp, _ = self.admin_client.delete_obj('executions', exec_id) + resp, _ = self.admin_client.delete_obj( + 'executions', + exec_id, + force=True + ) self.assertEqual(204, resp.status) diff --git a/mistral_tempest_tests/tests/api/v2/test_tasks.py b/mistral_tempest_tests/tests/api/v2/test_tasks.py index 7527824..aa46bb1 100644 --- a/mistral_tempest_tests/tests/api/v2/test_tasks.py +++ b/mistral_tempest_tests/tests/api/v2/test_tasks.py @@ -36,7 +36,7 @@ class TasksTestsV2(base.TestCase): self.client.workflows = [] for wf in self.client.executions: - self.client.delete_obj('executions', wf) + self.client.delete_obj('executions', wf, force=True) self.client.executions = [] super(TasksTestsV2, self).tearDown() diff --git a/mistral_tempest_tests/tests/base.py b/mistral_tempest_tests/tests/base.py index 9a75259..13116bc 100644 --- a/mistral_tempest_tests/tests/base.py +++ b/mistral_tempest_tests/tests/base.py @@ -83,7 +83,7 @@ class TestCaseAdvanced(TestCase): self.client.workbooks = [] for ex in self.client.executions: - self.client.delete_obj('executions', ex) + self.client.delete_obj('executions', ex, force=True) self.client.executions = []