Fixing YAQL related errors

* Now Mistral raises YaqlEvaluationException if
   something was wrong with evaluating YAQL.

Closes-Bug: #1449505

Change-Id: Ic6a1592b8424ebdbaaca698b9a894d589def97d2
This commit is contained in:
Nikolay Mahotkin 2015-05-07 14:42:33 +03:00
parent ca8beb200f
commit d55ed99b50
2 changed files with 22 additions and 1 deletions

View File

@ -89,7 +89,7 @@ class YAQLEvaluator(Evaluator):
data=data_context, data=data_context,
context=yaql_utils.create_yaql_context() context=yaql_utils.create_yaql_context()
) )
except (KeyError, yaql_exc.YaqlException) as e: except (yaql_exc.YaqlException, KeyError, ValueError, TypeError) as e:
raise exc.YaqlEvaluationException( raise exc.YaqlEvaluationException(
"Can not evaluate YAQL expression: %s, data = %s; error:" "Can not evaluate YAQL expression: %s, data = %s; error:"
" %s" % (expression, data_context, str(e)) " %s" % (expression, data_context, str(e))

View File

@ -262,6 +262,27 @@ class DirectWorkflowEngineTest(base.EngineTestCase):
"Called with a right exception" "Called with a right exception"
) )
def test_mismatched_yaql_in_first_task(self):
wf_text = """
version: '2.0'
wf:
input:
- var
tasks:
task1:
action: std.echo output=<% $.var + $.var2 %>
"""
wf_service.create_workflows(wf_text)
exception = self.assertRaises(
exc.YaqlEvaluationException,
self.engine.start_workflow, 'wf', {'var': 2}
)
self.assertIn("Can not evaluate YAQL expression", exception.message)
def test_one_line_syntax_in_on_clauses(self): def test_one_line_syntax_in_on_clauses(self):
wf_text = """ wf_text = """
version: '2.0' version: '2.0'