From 97668bc3c1162db00b7347d1cbf48048774f3dd6 Mon Sep 17 00:00:00 2001 From: Ifat Afek Date: Tue, 5 Mar 2019 14:02:47 +0000 Subject: [PATCH] Add tempest tests for adding a template by a yaml string Change-Id: Ic0acb247e24068d811dc860d272eb166504660de Depends-On: Icf67750226d379c20dbe9d93df18eeabf88aadfa Story: 2004055 Task: 29838 --- .../tests/api/templates/test_template_v2.py | 42 +++++++++++++++++++ .../tests/api/templates/test_template_v3.py | 22 ++++++++++ 2 files changed, 64 insertions(+) diff --git a/vitrage_tempest_plugin/tests/api/templates/test_template_v2.py b/vitrage_tempest_plugin/tests/api/templates/test_template_v2.py index b3e6132..ec3f3a6 100644 --- a/vitrage_tempest_plugin/tests/api/templates/test_template_v2.py +++ b/vitrage_tempest_plugin/tests/api/templates/test_template_v2.py @@ -94,6 +94,45 @@ class TestTemplatesApis(BaseTemplateTest): result = self.vitrage_client.template.add(path=path, params=params) self._assert_add_result(result, LOADING_STATUS, TEMPLATE_VALIDATION_OK) + def _add_by_string(self, template_str): + result = self.vitrage_client.template.add(template_str=template_str) + self._assert_add_result(result, LOADING_STATUS, TEMPLATE_VALIDATION_OK) + + +TEMPLATE_STRING = """ +metadata: + name: host_down_scenarios + description: scenarios triggered by Doctor monitor 'compute.host.down' alarm + version: 2 + type: standard +definitions: + entities: + - entity: + category: ALARM + name: compute.host.down + template_id: host_down_alarm + - entity: + category: RESOURCE + type: nova.host + template_id: host + relationships: + - relationship: + source: host_down_alarm + relationship_type: on + target: host + template_id : host_down_alarm_on_host +scenarios: + - scenario: + condition: host_down_alarm_on_host + actions: + - action: + action_type: set_state + action_target: + target: host + properties: + state: ERROR +""" + class TestTemplatesV2(TestTemplatesApis): @@ -123,3 +162,6 @@ class TestTemplatesV2(TestTemplatesApis): def test_template_add_with_parameters(self): self._add_with_parameters(WITH_PARAMS_TEMPLATE) + + def test_template_add_by_string(self): + self._add_by_string(TEMPLATE_STRING) diff --git a/vitrage_tempest_plugin/tests/api/templates/test_template_v3.py b/vitrage_tempest_plugin/tests/api/templates/test_template_v3.py index fd18cbc..655098a 100644 --- a/vitrage_tempest_plugin/tests/api/templates/test_template_v3.py +++ b/vitrage_tempest_plugin/tests/api/templates/test_template_v3.py @@ -21,6 +21,25 @@ LOG = logging.getLogger(__name__) WITH_PARAMS_TEMPLATE = 'v3_with_params.yaml' +TEMPLATE_STRING = """ +metadata: + version: 3 + name: template1 + description: simple template + type: standard +entities: + alarm: + name: cpu problem + host: + type: nova.host +scenarios: + - condition: alarm [ on ] host + actions: + - set_state: + state: ERROR + target: host +""" + class TestTemplatesV3(TestTemplatesApis): @@ -41,3 +60,6 @@ class TestTemplatesV3(TestTemplatesApis): def test_template_add_with_parameters(self): self._add_with_parameters(WITH_PARAMS_TEMPLATE) + + def test_template_add_by_string(self): + self._add_by_string(TEMPLATE_STRING)