Role * supported for deployment tasks
JSON schema for role changed. We support '*' or list of tasks names in role field. Duplication of test 'test_check_group_type_deployment_task' removed. Change-Id: I32321826e5e8b45ea0e5d6cc2e1361fba9cbce14 Closes-Bug: #1492167
This commit is contained in:
parent
5b7e4e32c8
commit
bffcc793b0
|
@ -74,12 +74,12 @@ class TestValidatorV3(BaseValidator):
|
|||
}
|
||||
]
|
||||
|
||||
with mock.patch.object(self.validator, '_parse_tasks') as \
|
||||
parse_tasks_mock:
|
||||
with mock.patch('fuel_plugin_builder.validators.validator_v3.utils') \
|
||||
as mock_utils:
|
||||
for data in data_sets:
|
||||
parse_tasks_mock.return_value = [data]
|
||||
mock_utils.parse_yaml.return_value = [data]
|
||||
self.assertRaises(errors.ValidationError,
|
||||
self.validator.check_tasks)
|
||||
self.validator.check_deployment_tasks)
|
||||
|
||||
def test_check_tasks_schema_validation_passed(self):
|
||||
data_sets = [
|
||||
|
@ -117,9 +117,10 @@ class TestValidatorV3(BaseValidator):
|
|||
],
|
||||
[
|
||||
{
|
||||
'type': 'reboot',
|
||||
'type': 'shell',
|
||||
'parameters': {
|
||||
'timeout': 3,
|
||||
'cmd': 'reboot'
|
||||
},
|
||||
'stage': 'post_deployment',
|
||||
'role': '*'
|
||||
|
@ -146,20 +147,21 @@ class TestValidatorV3(BaseValidator):
|
|||
],
|
||||
[
|
||||
{
|
||||
'type': 'reboot',
|
||||
'type': 'shell',
|
||||
'parameters': {
|
||||
'timeout': 3,
|
||||
'cmd': 'xx'
|
||||
'cmd': 'reboot'
|
||||
},
|
||||
'stage': 'post_deployment',
|
||||
'role': '*'
|
||||
},
|
||||
{
|
||||
'type': 'reboot',
|
||||
'type': 'shell',
|
||||
'parameters': {
|
||||
'timeout': 3,
|
||||
'puppet_manifest': 'xx',
|
||||
'puppet_modules': 'yy',
|
||||
'cmd': 'reboot'
|
||||
},
|
||||
'stage': 'post_deployment',
|
||||
'role': '*'
|
||||
|
@ -167,18 +169,19 @@ class TestValidatorV3(BaseValidator):
|
|||
]
|
||||
]
|
||||
|
||||
with mock.patch.object(self.validator, '_parse_tasks') as \
|
||||
parse_tasks_mock:
|
||||
with mock.patch('fuel_plugin_builder.validators.validator_v3.utils') \
|
||||
as mock_utils:
|
||||
for data in data_sets:
|
||||
parse_tasks_mock.return_value = data
|
||||
self.validator.check_tasks()
|
||||
mock_utils.parse_yaml.return_value = data
|
||||
self.validator.check_deployment_tasks()
|
||||
|
||||
@mock.patch('fuel_plugin_builder.validators.validator_v3.utils')
|
||||
@mock.patch('fuel_plugin_builder.validators.base.utils.exists')
|
||||
def test_check_tasks_no_file(self, exists_mock):
|
||||
def test_check_tasks_no_file(self, exists_mock, utils_mock):
|
||||
mocked_methods = ['validate_schema']
|
||||
self.mock_methods(self.validator, mocked_methods)
|
||||
exists_mock.return_value = False
|
||||
self.validator.check_tasks()
|
||||
self.validator.check_deployment_tasks()
|
||||
self.assertFalse(self.validator.validate_schema.called)
|
||||
|
||||
def test_check_schemas(self):
|
||||
|
@ -255,19 +258,6 @@ class TestValidatorV3(BaseValidator):
|
|||
|
||||
self.validator.check_deployment_tasks()
|
||||
|
||||
@mock.patch('fuel_plugin_builder.validators.validator_v3.utils')
|
||||
def test_check_shell_type_deployment_task(self, utils_mock):
|
||||
utils_mock.parse_yaml.return_value = [{
|
||||
'id': 'plugin_name',
|
||||
'type': 'group',
|
||||
'groups': ['plugin_name']}]
|
||||
|
||||
with self.assertRaisesRegexp(
|
||||
errors.ValidationError,
|
||||
"File '/tmp/plugin_path/deployment_tasks.yaml', "
|
||||
"'role' is a required property, value path '0'"):
|
||||
self.validator.check_deployment_tasks()
|
||||
|
||||
@mock.patch('fuel_plugin_builder.validators.validator_v3.utils')
|
||||
def test_check_skipped_type_deployment_task(self, utils_mock):
|
||||
utils_mock.parse_yaml.return_value = [{
|
||||
|
@ -288,7 +278,7 @@ class TestValidatorV3(BaseValidator):
|
|||
self.validator.check_deployment_tasks()
|
||||
|
||||
@mock.patch('fuel_plugin_builder.validators.validator_v3.utils')
|
||||
def test_check_deployment_task_role(self, utils_mock):
|
||||
def test_check_deployment_task_role_failed(self, utils_mock):
|
||||
utils_mock.parse_yaml.return_value = [{
|
||||
'id': 'plugin_name',
|
||||
'type': 'group',
|
||||
|
@ -300,6 +290,25 @@ class TestValidatorV3(BaseValidator):
|
|||
" 'plugin_n@me' does not match"):
|
||||
self.validator.check_deployment_tasks()
|
||||
|
||||
@mock.patch('fuel_plugin_builder.validators.validator_v3.utils')
|
||||
def test_check_deployment_task_role(self, utils_mock):
|
||||
utils_mock.parse_yaml.return_value = [
|
||||
{'id': 'plugin_name', 'type': 'group', 'role': []},
|
||||
{'id': 'plugin_name', 'type': 'group', 'role': ['a', 'b']},
|
||||
{'id': 'plugin_name', 'type': 'group', 'role': '*'},
|
||||
{'id': 'plugin_name', 'type': 'puppet', 'role': []},
|
||||
{'id': 'plugin_name', 'type': 'puppet', 'role': ['a', 'b']},
|
||||
{'id': 'plugin_name', 'type': 'puppet', 'role': '*'},
|
||||
{'id': 'plugin_name', 'type': 'shell', 'role': []},
|
||||
{'id': 'plugin_name', 'type': 'shell', 'role': ['a', 'b']},
|
||||
{'id': 'plugin_name', 'type': 'shell', 'role': '*'},
|
||||
{'id': 'plugin_name', 'type': 'skipped', 'role': []},
|
||||
{'id': 'plugin_name', 'type': 'skipped', 'role': ['a', 'b']},
|
||||
{'id': 'plugin_name', 'type': 'skipped', 'role': '*'},
|
||||
]
|
||||
|
||||
self.validator.check_deployment_tasks()
|
||||
|
||||
@mock.patch('fuel_plugin_builder.validators.base.utils')
|
||||
def test_check_deployment_task_id(self, utils_mock):
|
||||
utils_mock.parse_yaml.return_value = [{
|
||||
|
|
|
@ -23,6 +23,15 @@ NETWORK_ROLE_PATTERN = '^[0-9a-z_-]+$'
|
|||
|
||||
class SchemaV3(SchemaV2):
|
||||
|
||||
@property
|
||||
def task_role(self):
|
||||
return {
|
||||
'oneOf': [
|
||||
self.task_group,
|
||||
{'enum': ['*']}
|
||||
]
|
||||
}
|
||||
|
||||
@property
|
||||
def task_group(self):
|
||||
return {
|
||||
|
@ -89,7 +98,7 @@ class SchemaV3(SchemaV2):
|
|||
'properties': {
|
||||
'type': {'enum': ['puppet']},
|
||||
'groups': self.task_group,
|
||||
'role': self.task_group,
|
||||
'role': self.task_role,
|
||||
'parameters': {
|
||||
'type': 'object',
|
||||
'required': [
|
||||
|
@ -110,7 +119,7 @@ class SchemaV3(SchemaV2):
|
|||
'required': ['role'],
|
||||
'properties': {
|
||||
'type': {'enum': ['shell']},
|
||||
'role': self.task_group,
|
||||
'role': self.task_role,
|
||||
'parameters': {
|
||||
'type': 'object',
|
||||
'required': ['cmd'],
|
||||
|
@ -132,7 +141,7 @@ class SchemaV3(SchemaV2):
|
|||
'required': ['role'],
|
||||
'properties': {
|
||||
'type': {'enum': ['group']},
|
||||
'role': self.task_group,
|
||||
'role': self.task_role,
|
||||
'parameters': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
|
|
Loading…
Reference in New Issue