Add tempest tests for adding a template by a yaml string

Change-Id: Ic0acb247e24068d811dc860d272eb166504660de
Depends-On: Icf67750226d379c20dbe9d93df18eeabf88aadfa

Story: 2004055
Task: 29838
This commit is contained in:
Ifat Afek 2019-03-05 14:02:47 +00:00
parent 36fa3966bc
commit 97668bc3c1
2 changed files with 64 additions and 0 deletions

View File

@ -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)

View File

@ -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)