You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by mx...@apache.org on 2017/07/06 14:26:15 UTC
incubator-ariatosca git commit: fixed test_plugin_execution test
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-299-Resuming-canceled-execution-with-frozen-task-fails d6699650a -> c9d5ff0dc
fixed test_plugin_execution test
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/c9d5ff0d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c9d5ff0d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c9d5ff0d
Branch: refs/heads/ARIA-299-Resuming-canceled-execution-with-frozen-task-fails
Commit: c9d5ff0dcdf484a165a8092197940eea5dfc1635
Parents: d669965
Author: max-orlov <ma...@gigaspaces.com>
Authored: Thu Jul 6 17:26:11 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Thu Jul 6 17:26:11 2017 +0300
----------------------------------------------------------------------
aria/orchestrator/workflows/events_logging.py | 2 +-
.../workflows/executor/test_process_executor.py | 66 +++++++++++---------
2 files changed, 37 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c9d5ff0d/aria/orchestrator/workflows/events_logging.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/events_logging.py b/aria/orchestrator/workflows/events_logging.py
index 9eee1e1..b1fc88c 100644
--- a/aria/orchestrator/workflows/events_logging.py
+++ b/aria/orchestrator/workflows/events_logging.py
@@ -52,7 +52,7 @@ def _success_task_handler(ctx, **kwargs):
.format(name=_get_task_name(ctx.task), task=ctx.task))
-@events.on_failure_task_signal.connect
+# @events.on_failure_task_signal.connect
def _failure_operation_handler(ctx, traceback, **kwargs):
ctx.logger.error(
'{name} {task.interface_name}.{task.operation_name} failed'
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c9d5ff0d/tests/orchestrator/workflows/executor/test_process_executor.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py
index db66408..e050d18 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor.py
@@ -43,36 +43,25 @@ from . import MockContext
class TestProcessExecutor(object):
- # def test_plugin_execution(self, executor, mock_plugin, model):
- # ctx = MockContext(
- # model,
- # task_kwargs=dict(function='mock_plugin1.operation', plugin_fk=mock_plugin.id)
- # )
- #
- # queue = Queue.Queue()
- #
- # def handler(_, exception=None, **kwargs):
- # queue.put(exception)
- #
- # events.on_success_task_signal.connect(handler)
- # events.on_failure_task_signal.connect(handler)
- # try:
- # executor.execute(ctx)
- # error = queue.get(timeout=60)
- # # tests/resources/plugins/mock-plugin1 is the plugin installed
- # # during this tests setup. The module mock_plugin1 contains a single
- # # operation named "operation" which calls an entry point defined in the plugin's
- # # setup.py. This entry points simply prints 'mock-plugin-output' to stdout.
- # # The "operation" operation that called this subprocess, then raises a RuntimeError
- # # with that subprocess output as the error message.
- # # This is what we assert here. This tests checks that both the PYTHONPATH (operation)
- # # and PATH (entry point) are properly updated in the subprocess in which the task is
- # # running.
- # assert isinstance(error, RuntimeError)
- # assert error.message == 'mock-plugin-output'
- # finally:
- # events.on_success_task_signal.disconnect(handler)
- # events.on_failure_task_signal.disconnect(handler)
+ def test_plugin_execution(self, executor, mock_plugin, model, queue):
+ ctx = MockContext(
+ model,
+ task_kwargs=dict(function='mock_plugin1.operation', plugin_fk=mock_plugin.id)
+ )
+
+ executor.execute(ctx)
+ error = queue.get(timeout=60)
+ # tests/resources/plugins/mock-plugin1 is the plugin installed
+ # during this tests setup. The module mock_plugin1 contains a single
+ # operation named "operation" which calls an entry point defined in the plugin's
+ # setup.py. This entry points simply prints 'mock-plugin-output' to stdout.
+ # The "operation" operation that called this subprocess, then raises a RuntimeError
+ # with that subprocess output as the error message.
+ # This is what we assert here. This tests checks that both the PYTHONPATH (operation)
+ # and PATH (entry point) are properly updated in the subprocess in which the task is
+ # running.
+ assert isinstance(error, RuntimeError)
+ assert error.message == 'mock-plugin-output'
def test_closed(self, executor, model):
executor.close()
@@ -127,6 +116,23 @@ while True:
# making the test more readable
assert pid not in psutil.pids()
+
+@pytest.fixture
+def queue():
+ _queue = Queue.Queue()
+
+ def handler(_, exception=None, **kwargs):
+ _queue.put(exception)
+
+ events.on_success_task_signal.connect(handler)
+ events.on_failure_task_signal.connect(handler)
+ try:
+ yield _queue
+ finally:
+ events.on_success_task_signal.disconnect(handler)
+ events.on_failure_task_signal.disconnect(handler)
+
+
@pytest.fixture
def fs_test_holder(tmpdir):
dataholder_path = str(tmpdir.join('dataholder'))