Tests for add & validate template with params that have default values
Change-Id: I6631effe418df383597d79ef47944838bd88c84e
This commit is contained in:
parent
37a4340a55
commit
2677d2c14d
@ -23,6 +23,7 @@ EQUIVALENCE_TEMPLATE = 'v2_equivalence_templates.yaml'
|
||||
DEFINITION_TEMPLATE = 'v2_definition_template.yaml'
|
||||
NO_TYPE_TEMPLATE = 'v2_no_type_template.yaml'
|
||||
WITH_PARAMS_TEMPLATE = 'v2_with_params.yaml'
|
||||
WITH_DEFAULT_PARAMS_TEMPLATE = 'v2_with_default_params.yaml'
|
||||
|
||||
FAILED_TO_RESOLVE_PARAM = 'Failed to resolve parameter'
|
||||
ERROR_STATUS = 'ERROR'
|
||||
@ -73,6 +74,12 @@ class TestTemplatesApis(BaseTemplateTest):
|
||||
self.vitrage_client.template.validate(path=path, params=params)
|
||||
self._assert_validate_result(validation, path)
|
||||
|
||||
def _validate_with_default_parameters(self, template_name):
|
||||
path = self.TEST_PATH + template_name
|
||||
validation = \
|
||||
self.vitrage_client.template.validate(path=path, params=None)
|
||||
self._assert_validate_result(validation, path)
|
||||
|
||||
def _add_with_missing_parameters(self, template_name):
|
||||
path = self.TEST_PATH + template_name
|
||||
result = self.vitrage_client.template.add(path=path)
|
||||
@ -94,6 +101,11 @@ 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_with_default_parameters(self, template_name):
|
||||
path = self.TEST_PATH + template_name
|
||||
result = self.vitrage_client.template.add(path=path, params=None)
|
||||
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)
|
||||
@ -154,6 +166,9 @@ class TestTemplatesV2(TestTemplatesApis):
|
||||
def test_template_validate_with_parameters(self):
|
||||
self._validate_with_parameters(WITH_PARAMS_TEMPLATE)
|
||||
|
||||
def test_template_validate_with_default_parameters(self):
|
||||
self._validate_with_default_parameters(WITH_DEFAULT_PARAMS_TEMPLATE)
|
||||
|
||||
def test_template_add_with_missing_parameters(self):
|
||||
self._add_with_missing_parameters(WITH_PARAMS_TEMPLATE)
|
||||
|
||||
@ -163,5 +178,8 @@ class TestTemplatesV2(TestTemplatesApis):
|
||||
def test_template_add_with_parameters(self):
|
||||
self._add_with_parameters(WITH_PARAMS_TEMPLATE)
|
||||
|
||||
def test_template_add_with_default_parameters(self):
|
||||
self._add_with_default_parameters(WITH_DEFAULT_PARAMS_TEMPLATE)
|
||||
|
||||
def test_template_add_by_string(self):
|
||||
self._add_by_string(TEMPLATE_STRING)
|
||||
|
@ -20,6 +20,7 @@ from vitrage_tempest_plugin.tests.api.templates.test_template_v2 \
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
WITH_PARAMS_TEMPLATE = 'v3_with_params.yaml'
|
||||
WITH_DEFAULT_PARAMS_TEMPLATE = 'v3_with_default_params.yaml'
|
||||
|
||||
TEMPLATE_STRING = """
|
||||
metadata:
|
||||
@ -52,6 +53,9 @@ class TestTemplatesV3(TestTemplatesApis):
|
||||
def test_template_validate_with_parameters(self):
|
||||
self._validate_with_parameters(WITH_PARAMS_TEMPLATE)
|
||||
|
||||
def test_template_validate_with_default_parameters(self):
|
||||
self._validate_with_default_parameters(WITH_DEFAULT_PARAMS_TEMPLATE)
|
||||
|
||||
def test_template_add_with_missing_parameters(self):
|
||||
self._add_with_missing_parameters(WITH_PARAMS_TEMPLATE)
|
||||
|
||||
@ -61,5 +65,8 @@ class TestTemplatesV3(TestTemplatesApis):
|
||||
def test_template_add_with_parameters(self):
|
||||
self._add_with_parameters(WITH_PARAMS_TEMPLATE)
|
||||
|
||||
def test_template_add_with_default_parameters(self):
|
||||
self._add_with_default_parameters(WITH_DEFAULT_PARAMS_TEMPLATE)
|
||||
|
||||
def test_template_add_by_string(self):
|
||||
self._add_by_string(TEMPLATE_STRING)
|
||||
|
@ -0,0 +1,43 @@
|
||||
metadata:
|
||||
version: 2
|
||||
type: standard
|
||||
name: get_param(template_name)
|
||||
description: template with parameters that have default values
|
||||
parameters:
|
||||
template_name:
|
||||
description: the name of the template
|
||||
default: template_with_default_params
|
||||
alarm_type:
|
||||
description: the type of the alarm
|
||||
default: zabbix
|
||||
alarm_name:
|
||||
default: Alarm1
|
||||
new_state:
|
||||
default: ERROR
|
||||
definitions:
|
||||
entities:
|
||||
- entity:
|
||||
category: ALARM
|
||||
type: get_param(alarm_type)
|
||||
name: get_param(alarm_name)
|
||||
template_id: alarm
|
||||
- entity:
|
||||
category: RESOURCE
|
||||
type: nova.host
|
||||
template_id: resource
|
||||
relationships:
|
||||
- relationship:
|
||||
source: alarm
|
||||
target: resource
|
||||
relationship_type: on
|
||||
template_id : alarm_on_host
|
||||
scenarios:
|
||||
- scenario:
|
||||
condition: alarm_on_host
|
||||
actions:
|
||||
- action:
|
||||
action_type: set_state
|
||||
properties:
|
||||
state: get_param(new_state)
|
||||
action_target:
|
||||
target: resource
|
@ -0,0 +1,30 @@
|
||||
metadata:
|
||||
version: 3
|
||||
type: standard
|
||||
name: get_param(template_name)
|
||||
description: template with parameters that have default values
|
||||
parameters:
|
||||
template_name:
|
||||
description: the name of the template
|
||||
default: template_with_default_params
|
||||
alarm_type:
|
||||
description: the type of the alarm
|
||||
default: zabbix
|
||||
alarm_name:
|
||||
default: Alarm1
|
||||
new_state:
|
||||
default: ERROR
|
||||
entities:
|
||||
alarm:
|
||||
category: ALARM
|
||||
type: get_param(alarm_type)
|
||||
name: get_param(alarm_name)
|
||||
host:
|
||||
category: RESOURCE
|
||||
type: nova.host
|
||||
scenarios:
|
||||
- condition: alarm [on] host
|
||||
actions:
|
||||
- set_state:
|
||||
state: get_param(new_state)
|
||||
target: host
|
Loading…
x
Reference in New Issue
Block a user