Exemplo n.º 1
0
    def test_convert_tasks_unsupported_attributes(self):
        converter = workflows_base.WorkflowConverter()
        expr_converter = yql.YaqlExpressionConverter()

        with self.assertRaises(NotImplementedError):
            mistral_tasks = self._create_task(('keep-result', True))
            converter.convert_tasks(mistral_tasks, expr_converter, set())

        with self.assertRaises(NotImplementedError):
            mistral_tasks = self._create_task(('pause-before', True))
            converter.convert_tasks(mistral_tasks, expr_converter, set())

        with self.assertRaises(NotImplementedError):
            mistral_tasks = self._create_task(('safe-rerun', True))
            converter.convert_tasks(mistral_tasks, expr_converter, set())

        with self.assertRaises(NotImplementedError):
            mistral_tasks = self._create_task(('target', 'some-node'))
            converter.convert_tasks(mistral_tasks, expr_converter, set())

        with self.assertRaises(NotImplementedError):
            mistral_tasks = self._create_task(('timeout', 60))
            converter.convert_tasks(mistral_tasks, expr_converter, set())

        with self.assertRaises(NotImplementedError):
            mistral_tasks = self._create_task(('wait-after', 60))
            converter.convert_tasks(mistral_tasks, expr_converter, set())

        with self.assertRaises(NotImplementedError):
            mistral_tasks = self._create_task(('wait-before', 60))
            converter.convert_tasks(mistral_tasks, expr_converter, set())

        with self.assertRaises(NotImplementedError):
            mistral_tasks = self._create_task(('workflow', 'someworkflowname'))
            converter.convert_tasks(mistral_tasks, expr_converter, set())
Exemplo n.º 2
0
 def test_convert_tasks_yaql(self):
     converter = workflows_base.WorkflowConverter()
     expr_converter = yql.YaqlExpressionConverter()
     mistral_tasks = OrderedMap([
         ('jinja_task', OrderedMap([
             ('action', 'mypack.actionname'),
             ('input', OrderedMap([
                 ('cmd', '<% $.test %>'),
             ])),
             ('on-success', ['next_task']),
         ]))
     ])
     result = converter.convert_tasks(mistral_tasks, expr_converter, set())
     self.assertEqual(result, OrderedMap([
         ('jinja_task', OrderedMap([
             ('action', 'mypack.actionname'),
             ('input', OrderedMap([
                 ('cmd', '<% ctx().test %>'),
             ])),
             ('next', [
                 OrderedMap([
                     ('when', '<% succeeded() %>'),
                     ('do', [
                         'next_task',
                     ])
                 ]),
             ]),
         ]))
     ]))
Exemplo n.º 3
0
    def test_convert_task_transition_simple_yaql(self):
        converter = workflows_base.WorkflowConverter()
        transitions = ['a', 'b', 'c']
        publish = OrderedMap([('key_plain', 'data'),
                              ('key_expr', '{{ _.test }}')])
        orquesta_expr = 'succeeded()'
        expr_converter = yql.YaqlExpressionConverter()

        result = converter.convert_task_transition_simple(transitions,
                                                          publish,
                                                          orquesta_expr,
                                                          expr_converter)

        # note: only the orquesta_expr is converted using YAQL, the expressions
        #       in the rest are converted independently because they may each
        #       be a different type
        expected = OrderedMap([
            ('when', '<% succeeded() %>'),
            ('publish', [
                {'key_plain': 'data'},
                {'key_expr': '{{ ctx().test }}'}
            ]),
            ('do', ['a', 'b', 'c']),
        ])
        self.assertEqual(result, expected)
Exemplo n.º 4
0
 def test_convert_tasks_join(self):
     converter = workflows_base.WorkflowConverter()
     expr_converter = yql.YaqlExpressionConverter()
     mistral_tasks = OrderedMap([
         ('jinja_task', OrderedMap([
             ('action', 'mypack.actionname'),
             ('join', 'all'),
         ]))
     ])
     result = converter.convert_tasks(mistral_tasks, expr_converter, set())
     self.assertEqual(result, OrderedMap([
         ('jinja_task', OrderedMap([
             ('action', 'mypack.actionname'),
             ('join', 'all'),
         ]))
     ]))
Exemplo n.º 5
0
 def expr_type_converter(self, expr_type):
     if expr_type is None:
         expr_converter = jinja.JinjaExpressionConverter()
     elif isinstance(expr_type, six.string_types):
         expr_type = expr_type.lower()
         if expr_type == 'jinja':
             expr_converter = jinja.JinjaExpressionConverter()
         elif expr_type == 'yaql':
             expr_converter = yql.YaqlExpressionConverter()
         else:
             raise TypeError(
                 "Unknown expression type: {}".format(expr_type))
     elif isinstance(expr_type, expr_base.BaseExpressionConverter):
         expr_converter = expr_type
     else:
         raise TypeError("Unknown expression class type: {}".format(
             type(expr_type)))
     return expr_converter
Exemplo n.º 6
0
 def test_expr_type_converter_class_yaql(self):
     expr_type = yql.YaqlExpressionConverter()
     converter = workflows_base.WorkflowConverter()
     result = converter.expr_type_converter(expr_type)
     self.assertIs(result, expr_type)