Add SerializerNotSupported error type to nailgun.errors
Now in case when type of task is not known to Nailgun proper error is thrown. Change-Id: I33923c04e3eba0ed8028efac51e36f347296d0ae Closes-Bug: #1506915
This commit is contained in:
@@ -55,6 +55,8 @@ default_messages = {
|
||||
"ControllerInErrorState": ("One of the cluster controllers is in error "
|
||||
"state, please, eliminate the problem prior "
|
||||
"to proceeding further"),
|
||||
"SerializerNotSupported": ("Serialization of the task is not supported "
|
||||
"because of unknown type"),
|
||||
|
||||
# mongo errors
|
||||
"ExtMongoCheckerError": "Mongo nodes shouldn`t be used with external mongo",
|
||||
|
||||
@@ -426,7 +426,7 @@ class TaskSerializers(object):
|
||||
# deployment engine, therefore exception should be raised,
|
||||
# but it should be verified by validation as well
|
||||
raise errors.SerializerNotSupported(
|
||||
'Serialization of type {0} not supported. Task {1}'.format(
|
||||
'Serialization of type {0} is not supported. Task {1}'.format(
|
||||
task['type'], task))
|
||||
|
||||
def get_stage_serializer(self, task):
|
||||
|
||||
@@ -18,6 +18,7 @@ import mock
|
||||
import yaml
|
||||
|
||||
from nailgun import consts
|
||||
from nailgun.errors import errors
|
||||
from nailgun import objects
|
||||
from nailgun.orchestrator.base_serializers import NetworkDeploymentSerializer
|
||||
from nailgun.orchestrator import deployment_graph
|
||||
@@ -535,3 +536,20 @@ class TestConditionalTasksSerializers(BaseTaskSerializationTest):
|
||||
|
||||
tasks = self.graph.pre_tasks_serialize(self.nodes)
|
||||
self.assertEqual(len(tasks), 0)
|
||||
|
||||
|
||||
class TestSerializationIsNotSupportedError(base.BaseTestCase):
|
||||
|
||||
def test_error_is_raised(self):
|
||||
task_type = 'fake_type'
|
||||
task = {'id': 'fake_task', 'type': task_type}
|
||||
|
||||
ts = tasks_serializer.TaskSerializers()
|
||||
|
||||
err_msg = 'Serialization of type {0} is not supported.'\
|
||||
.format(task_type)
|
||||
|
||||
with self.assertRaises(errors.SerializerNotSupported) as exc:
|
||||
ts.get_deploy_serializer(task)
|
||||
|
||||
self.assertIn(err_msg, exc.exception.message)
|
||||
|
||||
Reference in New Issue
Block a user