Merge "Friendlier error message with empty task file"
This commit is contained in:
commit
47fbf92d47
@ -185,6 +185,11 @@ class TaskEngine(object):
|
||||
:param abort_on_sla_failure: True if the execution should be stopped
|
||||
when some SLA check fails
|
||||
"""
|
||||
if config is None:
|
||||
msg = _("Input task is empty")
|
||||
task.set_failed(log=msg)
|
||||
raise exceptions.InvalidTaskException(msg)
|
||||
|
||||
try:
|
||||
self.config = TaskConfig(config)
|
||||
except Exception as e:
|
||||
|
@ -44,6 +44,15 @@ class TaskEngineTestCase(test.TestCase):
|
||||
self.assertEqual(eng.config, fake_task_instance)
|
||||
self.assertEqual(eng.task, task)
|
||||
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
def test_init_empty_config(self, mock_task_config):
|
||||
config = None
|
||||
task = mock.Mock()
|
||||
exception = self.assertRaises(exceptions.InvalidTaskException,
|
||||
engine.TaskEngine, config, task)
|
||||
self.assertIn("Input task is empty", str(exception))
|
||||
self.assertTrue(task.set_failed.called)
|
||||
|
||||
@mock.patch("rally.task.engine.TaskConfig")
|
||||
@mock.patch("jsonschema.validate")
|
||||
def test_validate(self, mock_validate, mock_task_config):
|
||||
|
Loading…
Reference in New Issue
Block a user