diff --git a/rally-jobs/rally-mistral.yaml b/rally-jobs/rally-mistral.yaml index 69566317..ee02f8ce 100644 --- a/rally-jobs/rally-mistral.yaml +++ b/rally-jobs/rally-mistral.yaml @@ -58,18 +58,40 @@ users_per_tenant: 2 - title: MistralExecutions.create_execution_from_workbook tests - scenario: - MistralExecutions.create_execution_from_workbook: - definition: "~/.rally/extra/mistral_wb.yaml" - workflow_name: "wf1" - params: "~/.rally/extra/mistral_params.json" - wf_input: "~/.rally/extra/mistral_input.json" - do_delete: true - runner: - constant: - times: 50 - concurrency: 10 - contexts: - users: - tenants: 2 - users_per_tenant: 2 + workloads: + - + description: MistralExecutions.create_execution_from_workbook scenario\ + with delete option + scenario: + MistralExecutions.create_execution_from_workbook: + definition: "~/.rally/extra/mistral_wb.yaml" + workflow_name: "wf1" + params: "~/.rally/extra/mistral_params.json" + wf_input: "~/.rally/extra/mistral_input.json" + do_delete: true + runner: + constant: + times: 50 + concurrency: 10 + contexts: + users: + tenants: 2 + users_per_tenant: 2 + - + description: MistralExecutions.create_execution_from_workbook scenario\ + without delete option + scenario: + MistralExecutions.create_execution_from_workbook: + definition: "~/.rally/extra/mistral_wb.yaml" + workflow_name: "wf1" + params: "~/.rally/extra/mistral_params.json" + wf_input: "~/.rally/extra/mistral_input.json" + do_delete: false + runner: + constant: + times: 50 + concurrency: 10 + contexts: + users: + tenants: 2 + users_per_tenant: 2 diff --git a/rally/plugins/openstack/cleanup/resources.py b/rally/plugins/openstack/cleanup/resources.py index fa62cc3b..ed816c4c 100644 --- a/rally/plugins/openstack/cleanup/resources.py +++ b/rally/plugins/openstack/cleanup/resources.py @@ -814,30 +814,28 @@ class SwiftContainer(SwiftMixin): _mistral_order = get_order(1100) -class MistralMixin(SynchronizedDeletion, base.ResourceManager): - - def delete(self): - self._manager().delete(self.raw_resource["id"]) - - @base.resource("mistral", "workbooks", order=next(_mistral_order), tenant_resource=True) -class MistralWorkbooks(MistralMixin): +class MistralWorkbooks(SynchronizedDeletion, base.ResourceManager): def delete(self): - self._manager().delete(self.raw_resource["name"]) + self._manager().delete(self.raw_resource.name) @base.resource("mistral", "workflows", order=next(_mistral_order), tenant_resource=True) -class MistralWorkflows(MistralMixin): +class MistralWorkflows(SynchronizedDeletion, base.ResourceManager): pass @base.resource("mistral", "executions", order=next(_mistral_order), tenant_resource=True) -class MistralExecutions(MistralMixin): - pass +class MistralExecutions(SynchronizedDeletion, base.ResourceManager): + def name(self): + # NOTE(andreykurilin): Mistral Execution doesn't have own name which + # we can use for filtering, but it stores workflow id and name, even + # after workflow deletion. + return self.raw_resource.workflow_name # MURANO diff --git a/tests/unit/plugins/openstack/cleanup/test_resources.py b/tests/unit/plugins/openstack/cleanup/test_resources.py index 4a934186..34b4d7f8 100644 --- a/tests/unit/plugins/openstack/cleanup/test_resources.py +++ b/tests/unit/plugins/openstack/cleanup/test_resources.py @@ -915,36 +915,31 @@ class ManilaSecurityServiceTestCase(test.TestCase): "fake_id") -class MistralMixinTestCase(test.TestCase): - - def test_delete(self): - mistral = resources.MistralMixin() - mistral._service = "mistral" - mistral.user = mock.MagicMock() - mistral._resource = "some_resources" - mistral.raw_resource = {"id": "TEST_ID"} - mistral.user.mistral().some_resources.delete.return_value = None - - mistral.delete() - mistral.user.mistral().some_resources.delete.assert_called_once_with( - "TEST_ID") - - class MistralWorkbookTestCase(test.TestCase): def test_delete(self): - mistral = resources.MistralWorkbooks() - mistral._service = "mistral" - mistral.user = mock.MagicMock() - mistral._resource = "some_resources" - mistral.raw_resource = {"name": "TEST_NAME"} - mistral.user.mistral().some_resources.delete.return_value = None + clients = mock.MagicMock() + resource = mock.Mock() + resource.name = "TEST_NAME" + + mistral = resources.MistralWorkbooks( + user=clients, + resource=resource) mistral.delete() - mistral.user.mistral().some_resources.delete.assert_called_once_with( + + clients.mistral().workbooks.delete.assert_called_once_with( "TEST_NAME") +class MistralExecutionsTestCase(test.TestCase): + + def test_name(self): + execution = mock.MagicMock(workflow_name="bar") + execution.name = "foo" + self.assertEqual("bar", resources.MistralExecutions(execution).name()) + + class SenlinMixinTestCase(test.TestCase): def test_id(self):