[1/2] incubator-ariatosca git commit: ARIA-278 remove core tasks [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-278-Remove-core-tasks b19ef4e77 -> 3e119df50 (forced update) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3e119df5/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py -- diff --git a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py index 5dd2855..f5fb17a 100644 --- a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py +++ b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py @@ -13,12 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from networkx import topological_sort, DiGraph +from networkx import topological_sort +from aria.modeling import models from aria.orchestrator import context -from aria.orchestrator.workflows import api, core +from aria.orchestrator.workflows import api +from aria.orchestrator.workflows.core import compile from aria.orchestrator.workflows.executor import base - from tests import mock from tests import storage @@ -26,8 +27,8 @@ from tests import storage def test_task_graph_into_execution_graph(tmpdir): interface_name = 'Standard' operation_name = 'create' -task_context = mock.context.simple(str(tmpdir)) -node = task_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) +workflow_context = mock.context.simple(str(tmpdir)) +node = workflow_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) interface = mock.models.create_interface( node.service, interface_name, @@ -35,12 +36,12 @@ def test_task_graph_into_execution_graph(tmpdir): operation_kwargs=dict(function='test') ) node.interfaces[interface.name] = interface -task_context.model.node.update(node) +workflow_context.model.node.update(node) def sub_workflow(name, **_): return api.task_graph.TaskGraph(name) -with context.workflow.current.push(task_context): +with context.workflow.current.push(workflow_context): test_task_graph = api.task.WorkflowTask(sub_workflow, name='test_task_graph') simple_before_task = api.task.OperationTask( node, @@ -64,12 +65,9 @@ def test_task_graph_into_execution_graph(tmpdir): 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, - default_executor=base.StubTaskExecutor()) -execution_tasks = topological_sort(execution_graph) +compile.create_execution_tasks(workflow_context, test_task_graph, base.StubTaskExecutor) + +execution_tasks = topological_sort(workflow_context._graph) assert len(execution_tasks) == 7 @@ -83,30 +81,23 @@ def test_task_graph_into_execution_graph(tmpdir): '{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 expected_tasks_names == [t._api_id for t in execution_tasks] +assert all(isinstance(task, models.Task) for task in execution_tasks) +execution_tasks = iter(execution_tasks) -_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 next(execution_tasks)._stub_type == models.Task.START_WORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_before_task) +assert next(execution_tasks)._stub_type == models.Task.START_SUBWROFKLOW +_assert_execution_is_api_task(next(execution_tasks), inner_task) +assert next(execution_tasks)._stub_type == models.Task.END_SUBWORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_after_task) +assert next(execution_tasks)._stub_type == models.Task.END_WORKFLOW -_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), -
[1/2] incubator-ariatosca git commit: ARIA-278 remove core tasks [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-278-Remove-core-tasks bfae4f39c -> 507796e69 (forced update) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/507796e6/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py -- diff --git a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py index 5dd2855..569e8be 100644 --- a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py +++ b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py @@ -13,12 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from networkx import topological_sort, DiGraph +from networkx import topological_sort +from aria.modeling import models from aria.orchestrator import context -from aria.orchestrator.workflows import api, core +from aria.orchestrator.workflows import ( +api, +core +) from aria.orchestrator.workflows.executor import base - from tests import mock from tests import storage @@ -26,8 +29,8 @@ from tests import storage def test_task_graph_into_execution_graph(tmpdir): interface_name = 'Standard' operation_name = 'create' -task_context = mock.context.simple(str(tmpdir)) -node = task_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) +workflow_context = mock.context.simple(str(tmpdir)) +node = workflow_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) interface = mock.models.create_interface( node.service, interface_name, @@ -35,12 +38,12 @@ def test_task_graph_into_execution_graph(tmpdir): operation_kwargs=dict(function='test') ) node.interfaces[interface.name] = interface -task_context.model.node.update(node) +workflow_context.model.node.update(node) def sub_workflow(name, **_): return api.task_graph.TaskGraph(name) -with context.workflow.current.push(task_context): +with context.workflow.current.push(workflow_context): test_task_graph = api.task.WorkflowTask(sub_workflow, name='test_task_graph') simple_before_task = api.task.OperationTask( node, @@ -65,11 +68,12 @@ def test_task_graph_into_execution_graph(tmpdir): 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, - default_executor=base.StubTaskExecutor()) -execution_tasks = topological_sort(execution_graph) +execution = workflow_context.model.execution.list()[0] + +core.engine.construct_execution_tasks(execution, test_task_graph, base.StubTaskExecutor) +workflow_context.execution = execution + +execution_tasks = topological_sort(workflow_context._graph) assert len(execution_tasks) == 7 @@ -83,30 +87,23 @@ def test_task_graph_into_execution_graph(tmpdir): '{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 expected_tasks_names == [t.api_id for t in execution_tasks] +assert all(isinstance(task, models.Task) for task in execution_tasks) +execution_tasks = iter(execution_tasks) -_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 next(execution_tasks).stub_type == models.Task.START_WORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_before_task) +assert next(execution_tasks).stub_type == models.Task.START_SUBWROFKLOW +_assert_execution_is_api_task(next(execution_tasks), inner_task) +assert next(execution_tasks).stub_type == models.Task.END_SUBWORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_after_task) +assert next(execution_tasks).stub_type == models.Task.END_WORKFLOW -_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), -