Exemple #1
0
 def workflow_context(self, tmpdir):
     workflow_context = mock.context.simple(
         storage.get_sqlite_api_kwargs(str(tmpdir)),
         resources_dir=str(tmpdir.join('resources')))
     workflow_context.states = []
     workflow_context.exception = None
     yield workflow_context
     storage.release_sqlite_storage(workflow_context.model)
Exemple #2
0
def storage():
    api_kwargs = test_storage.get_sqlite_api_kwargs()
    workflow_storage = application_model_storage(SQLAlchemyModelAPI,
                                                 api_kwargs=api_kwargs)
    workflow_storage.blueprint.put(models.get_blueprint())
    blueprint = workflow_storage.blueprint.get_by_name(models.BLUEPRINT_NAME)
    workflow_storage.deployment.put(models.get_deployment(blueprint))
    yield workflow_storage
    test_storage.release_sqlite_storage(workflow_storage)
Exemple #3
0
def ctx():
    """
    Create the following graph in storage:
    dependency_node <------ dependent_node
    :return:
    """
    simple_context = mock.context.simple(storage.get_sqlite_api_kwargs())
    simple_context.model.execution.put(mock.models.get_execution(simple_context.deployment))
    yield simple_context
    storage.release_sqlite_storage(simple_context.model)
Exemple #4
0
def context(tmpdir):
    result = mock.context.simple(storage.get_sqlite_api_kwargs(str(tmpdir)))
    yield result
    storage.release_sqlite_storage(result.model)
Exemple #5
0
def ctx(tmpdir):
    context = mock.context.simple(storage.get_sqlite_api_kwargs(str(tmpdir)))
    yield context
    storage.release_sqlite_storage(context.model)
Exemple #6
0
def _empty_storage():
    return application_model_storage(sql_mapi.SQLAlchemyModelAPI,
                                     api_kwargs=get_sqlite_api_kwargs())
Exemple #7
0
def memory_model_storage():
    result = aria.application_model_storage(
        SQLAlchemyModelAPI, api_kwargs=storage.get_sqlite_api_kwargs())
    yield result
    storage.release_sqlite_storage(result)
Exemple #8
0
def context(tmpdir):
    result = mock.context.simple(storage.get_sqlite_api_kwargs(str(tmpdir)),
                                 resources_dir=str(tmpdir.join('resources')),
                                 workdir=str(tmpdir.join('workdir')))
    yield result
    storage.release_sqlite_storage(result.model)
Exemple #9
0
def test_task_graph_into_execution_graph():
    operation_name = 'tosca.interfaces.node.lifecycle.Standard.create'
    task_context = mock.context.simple(storage.get_sqlite_api_kwargs())
    node_instance = \
        task_context.model.node_instance.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)

    def sub_workflow(name, **_):
        return api.task_graph.TaskGraph(name)

    with context.workflow.current.push(task_context):
        test_task_graph = api.task.WorkflowTask(sub_workflow,
                                                name='test_task_graph')
        simple_before_task = api.task.OperationTask.node_instance(
            instance=node_instance, name=operation_name)
        simple_after_task = api.task.OperationTask.node_instance(
            instance=node_instance, name=operation_name)

        inner_task_graph = api.task.WorkflowTask(sub_workflow,
                                                 name='test_inner_task_graph')
        inner_task = api.task.OperationTask.node_instance(
            instance=node_instance, name=operation_name)
        inner_task_graph.add_tasks(inner_task)

    test_task_graph.add_tasks(simple_before_task)
    test_task_graph.add_tasks(simple_after_task)
    test_task_graph.add_tasks(inner_task_graph)
    test_task_graph.add_dependency(inner_task_graph, simple_before_task)
    test_task_graph.add_dependency(simple_after_task, inner_task_graph)

    # Direct check
    execution_graph = DiGraph()
    core.translation.build_execution_graph(task_graph=test_task_graph,
                                           execution_graph=execution_graph)
    execution_tasks = topological_sort(execution_graph)

    assert len(execution_tasks) == 7

    expected_tasks_names = [
        '{0}-Start'.format(test_task_graph.id), simple_before_task.id,
        '{0}-Start'.format(inner_task_graph.id), inner_task.id,
        '{0}-End'.format(inner_task_graph.id), simple_after_task.id,
        '{0}-End'.format(test_task_graph.id)
    ]

    assert expected_tasks_names == execution_tasks

    assert isinstance(_get_task_by_name(execution_tasks[0], execution_graph),
                      core.task.StartWorkflowTask)

    _assert_execution_is_api_task(
        _get_task_by_name(execution_tasks[1], execution_graph),
        simple_before_task)
    assert isinstance(_get_task_by_name(execution_tasks[2], execution_graph),
                      core.task.StartSubWorkflowTask)

    _assert_execution_is_api_task(
        _get_task_by_name(execution_tasks[3], execution_graph), inner_task)
    assert isinstance(_get_task_by_name(execution_tasks[4], execution_graph),
                      core.task.EndSubWorkflowTask)

    _assert_execution_is_api_task(
        _get_task_by_name(execution_tasks[5], execution_graph),
        simple_after_task)
    assert isinstance(_get_task_by_name(execution_tasks[6], execution_graph),
                      core.task.EndWorkflowTask)
    storage.release_sqlite_storage(task_context.model)
Exemple #10
0
def ctx(tmpdir):
    context = mock.context.simple(storage.get_sqlite_api_kwargs(),
                                  resources_dir=str(tmpdir.join('resources')))
    yield context
    storage.release_sqlite_storage(context.model)