You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mx...@apache.org on 2017/02/22 14:26:29 UTC

incubator-ariatosca git commit: minor fixes [Forced Update!]

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-106-Create-sqla-logging-handler 34134d9f4 -> c37f075b5 (forced update)


minor fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/c37f075b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c37f075b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c37f075b

Branch: refs/heads/ARIA-106-Create-sqla-logging-handler
Commit: c37f075b52d834b7ebe7ca462abac00794de8215
Parents: 7cb6fba
Author: mxmrlv <mx...@gmail.com>
Authored: Tue Feb 21 18:34:04 2017 +0200
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Wed Feb 22 16:26:20 2017 +0200

----------------------------------------------------------------------
 aria/.pylintrc                                  |  2 +-
 aria/__init__.py                                | 20 +++++++++-----
 aria/logger.py                                  | 11 ++++----
 aria/orchestrator/context/common.py             | 23 ++++++++++------
 aria/orchestrator/context/operation.py          |  5 ++--
 aria/orchestrator/context/workflow.py           |  3 ++-
 aria/orchestrator/decorators.py                 |  2 +-
 aria/orchestrator/workflows/core/engine.py      |  1 +
 aria/orchestrator/workflows/core/task.py        |  8 ------
 aria/orchestrator/workflows/events_logging.py   |  7 ++---
 aria/orchestrator/workflows/executor/base.py    | 17 ++++++------
 aria/orchestrator/workflows/executor/thread.py  |  2 +-
 aria/storage/modeling/orchestrator_elements.py  |  6 ++---
 aria/utils/imports.py                           | 23 ++++++++++++++++
 tests/conftest.py                               | 24 +++++++++++++++++
 tests/orchestrator/context/test_operation.py    | 28 +++++++++++---------
 tests/orchestrator/execution_plugin/test_ssh.py |  3 ++-
 .../workflows/executor/test_executor.py         |  8 ------
 .../workflows/executor/test_process_executor.py |  3 +--
 tests/test_logger.py                            |  2 +-
 20 files changed, 124 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/.pylintrc
----------------------------------------------------------------------
diff --git a/aria/.pylintrc b/aria/.pylintrc
index b7656a3..589402f 100644
--- a/aria/.pylintrc
+++ b/aria/.pylintrc
@@ -77,7 +77,7 @@ confidence=
 # --enable=similarities". If you want to run only the classes checker, but have
 # no Warning level messages displayed, use"--disable=all --enable=classes
 # --disable=W"
-disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,redefined-builtin,logging-format-interpolation,import-error,redefined-variable-type,broad-except,protected-access,global-statement
+disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,redefined-builtin,logging-format-interpolation,import-error,redefined-variable-type,broad-except,protected-access,global-statement,no-member
 
 [REPORTS]
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/__init__.py
----------------------------------------------------------------------
diff --git a/aria/__init__.py b/aria/__init__.py
index 43529f0..7fd0db9 100644
--- a/aria/__init__.py
+++ b/aria/__init__.py
@@ -17,12 +17,7 @@
 Aria top level package
 """
 
-import pkgutil
-
-try:
-    import pkg_resources
-except ImportError:
-    pkg_resources = None
+import sys
 
 from .VERSION import version as __version__
 
@@ -35,6 +30,17 @@ from . import (
     orchestrator,
     cli
 )
+
+if sys.version_info < (2, 7):
+    from .utils.imports import iter_modules
+else:
+    from pkgutil import iter_modules
+
+try:
+    import pkg_resources
+except ImportError:
+    pkg_resources = None
+
 __all__ = (
     '__version__',
     'workflow',
@@ -48,7 +54,7 @@ def install_aria_extensions():
     :code:`aria_extension` entry points and loads them.
     It then invokes all registered extension functions.
     """
-    for loader, module_name, _ in pkgutil.iter_modules():
+    for loader, module_name, _ in iter_modules():
         if module_name.startswith('aria_extension_'):
             loader.find_module(module_name).load_module(module_name)
     if pkg_resources:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/logger.py
----------------------------------------------------------------------
diff --git a/aria/logger.py b/aria/logger.py
index ae6d4a6..1fcdf03 100644
--- a/aria/logger.py
+++ b/aria/logger.py
@@ -113,9 +113,9 @@ class _DefaultConsoleFormat(logging.Formatter):
     def format(self, record):
         try:
             if hasattr(record, 'prefix'):
-                self._fmt = '%(asctime)s: [%(levelname)s] @%(prefix)s ->%(message)s'
+                self._fmt = '<%(asctime)s: [%(levelname)s] @%(prefix)s> %(message)s'
             else:
-                self._fmt = '%(asctime)s: [%(levelname)s] %(message)s'
+                self._fmt = '<%(asctime)s: [%(levelname)s]> %(message)s'
 
         except AttributeError:
             return record.message
@@ -152,15 +152,14 @@ class _SQLAlchemyHandler(logging.Handler):
         # Cyclic dependency
         from aria.storage.modeling.model import Log
         self._cls = Log
+        # This is needed since the engine and session are entirely new
+        self._cls.__table__.create(bind=self._engine, checkfirst=True)
 
     def emit(self, record):
-        # pylint fails to recognize that this class does indeed have __table__
-        self._cls.__table__.create(bind=self._engine, checkfirst=True)                              # pylint: disable=no-member
         created_at = datetime.strptime(logging.Formatter('%(asctime)s').formatTime(record),
                                        '%Y-%m-%d %H:%M:%S,%f')
         log = self._cls(
-            prefix=record.prefix,
-            logger=record.name,
+            actor=record.prefix,
             level=record.levelname,
             msg=record.msg,
             created_at=created_at,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/orchestrator/context/common.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/common.py b/aria/orchestrator/context/common.py
index b908965..4b1730a 100644
--- a/aria/orchestrator/context/common.py
+++ b/aria/orchestrator/context/common.py
@@ -15,18 +15,18 @@
 """
 A common context for both workflow and operation
 """
+import logging
 from contextlib import contextmanager
 from functools import partial
 from uuid import uuid4
 
-import logging
 import jinja2
 
 from aria import logger as aria_logger
 from aria.storage import exceptions
 
 
-class BaseContext(aria_logger.LoggerMixin):
+class BaseContext(object):
     """
     Base context object for workflow and operation
     """
@@ -57,9 +57,19 @@ class BaseContext(aria_logger.LoggerMixin):
         self._resource = resource_storage
         self._service_instance_id = service_instance_id
         self._workdir = workdir
+        self.logger = None
+
+    def _register_logger(self, logger_name=None, level=None):
+        self.logger = self.PrefixedLogger(logging.getLogger(logger_name or self.__class__.__name__),
+                                          self.logging_id)
+        self.logger.addHandler(aria_logger.create_console_log_handler())
+        self.logger.addHandler(self._get_sqla_handler())
+        self.logger.setLevel(level or logging.DEBUG)
 
     def _get_sqla_handler(self):
-        api_kwargs = self._model._initiator(**self._model._initiator_kwargs)
+        api_kwargs = {}
+        if self._model._initiator:
+            api_kwargs.update(self._model._initiator(**self._model._initiator_kwargs))
         api_kwargs.update(**self._model._api_kwargs)
         return aria_logger.create_sqla_log_handler(**api_kwargs)
 
@@ -70,14 +80,11 @@ class BaseContext(aria_logger.LoggerMixin):
             .format(name=self.__class__.__name__, self=self))
 
     @contextmanager
-    def self_logging(self, handlers=None):
-        handlers = set(handlers) if handlers else set()
+    def logging_handlers(self, handlers=None):
+        handlers = handlers or []
         try:
-            handlers.add(aria_logger.create_console_log_handler())
-            handlers.add(self._get_sqla_handler())
             for handler in handlers:
                 self.logger.addHandler(handler)
-            self.logger = self.PrefixedLogger(self.logger, self.logging_id)
             yield self.logger
         finally:
             for handler in handlers:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/orchestrator/context/operation.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/operation.py b/aria/orchestrator/context/operation.py
index 97a09aa..3fb1786 100644
--- a/aria/orchestrator/context/operation.py
+++ b/aria/orchestrator/context/operation.py
@@ -44,6 +44,7 @@ class BaseOperationContext(BaseContext):
         self._task_id = task_id
         self._actor_id = actor_id
         self._task = None
+        self._register_logger()
 
     def __repr__(self):
         details = 'implementation={task.implementation}; ' \
@@ -138,8 +139,8 @@ class RelationshipOperationContext(BaseOperationContext):
 
     @property
     def logging_id(self):
-        return '{0}:{1}'.format(self.source_node.name or self.source_node.id,
-                                self.target_node.name or self.target_node.id)
+        return '{0}->{1}'.format(self.source_node.name or self.source_node.id,
+                                 self.target_node.name or self.target_node.id)
 
     @property
     def source_node_template(self):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/orchestrator/context/workflow.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/workflow.py b/aria/orchestrator/context/workflow.py
index 63ece3a..0afaa81 100644
--- a/aria/orchestrator/context/workflow.py
+++ b/aria/orchestrator/context/workflow.py
@@ -46,6 +46,7 @@ class WorkflowContext(BaseContext):
         # TODO: execution creation should happen somewhere else
         # should be moved there, when such logical place exists
         self._execution_id = self._create_execution() if execution_id is None else execution_id
+        self._register_logger()
 
     def __repr__(self):
         return (
@@ -66,7 +67,7 @@ class WorkflowContext(BaseContext):
 
     @property
     def logging_id(self):
-        return self._workflow_name
+        return '{0}[{1}]'.format(self._workflow_name, self._execution_id)
 
     @property
     def execution(self):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/orchestrator/decorators.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/decorators.py b/aria/orchestrator/decorators.py
index f915813..1a8ead0 100644
--- a/aria/orchestrator/decorators.py
+++ b/aria/orchestrator/decorators.py
@@ -72,7 +72,7 @@ def operation(func=None, toolbelt=False, suffix_template='', logging_handlers=No
             func_kwargs.setdefault('toolbelt', operation_toolbelt)
         validate_function_arguments(func, func_kwargs)
 
-        with func_kwargs['ctx'].self_logging(handlers=logging_handlers):
+        with func_kwargs['ctx'].logging_handlers(logging_handlers):
             return func(**func_kwargs)
     return _wrapper
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/orchestrator/workflows/core/engine.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/core/engine.py b/aria/orchestrator/workflows/core/engine.py
index 55b4159..c6ac2b3 100644
--- a/aria/orchestrator/workflows/core/engine.py
+++ b/aria/orchestrator/workflows/core/engine.py
@@ -69,6 +69,7 @@ class Engine(logger.LoggerMixin):
             else:
                 events.on_success_workflow_signal.send(self._workflow_context)
         except BaseException as e:
+
             events.on_failure_workflow_signal.send(self._workflow_context, exception=e)
             raise
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/orchestrator/workflows/core/task.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/core/task.py b/aria/orchestrator/workflows/core/task.py
index e9a6d94..f19b1cf 100644
--- a/aria/orchestrator/workflows/core/task.py
+++ b/aria/orchestrator/workflows/core/task.py
@@ -150,14 +150,6 @@ class OperationTask(BaseTask):
         self._task_id = operation_task.id
         self._update_fields = None
 
-    @property
-    def self_logging(self):
-        return self._ctx.self_logging
-
-    @property
-    def logger(self):
-        return self._ctx.logger
-
     @contextmanager
     def _update(self):
         """

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/orchestrator/workflows/events_logging.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/events_logging.py b/aria/orchestrator/workflows/events_logging.py
index 142ef74..73d8994 100644
--- a/aria/orchestrator/workflows/events_logging.py
+++ b/aria/orchestrator/workflows/events_logging.py
@@ -26,18 +26,19 @@ from .. import events
 
 @events.start_task_signal.connect
 def _start_task_handler(task, **kwargs):
-    task.logger.debug('Event: Starting task: {task.name}'.format(task=task))
+    task.context.logger.debug('Event: Starting task: {task.name}'.format(task=task))
 
 
 @events.on_success_task_signal.connect
 def _success_task_handler(task, **kwargs):
-    task.logger.debug('Event: Task success: {task.name}'.format(task=task))
+    task.context.logger.debug('Event: Task success: {task.name}'.format(task=task))
 
 
 @events.on_failure_task_signal.connect
 def _failure_operation_handler(task, exception, **kwargs):
     error = '{0}: {1}'.format(type(exception).__name__, exception)
-    task.logger.error('Event: Task failure: {task.name} [{error}]'.format(task=task, error=error))
+    task.context.logger.error('Event: Task failure: {task.name} [{error}]'.format(
+        task=task, error=error))
 
 
 @events.start_workflow_signal.connect

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/orchestrator/workflows/executor/base.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/base.py b/aria/orchestrator/workflows/executor/base.py
index 4ae046d..cd8e7ee 100644
--- a/aria/orchestrator/workflows/executor/base.py
+++ b/aria/orchestrator/workflows/executor/base.py
@@ -39,14 +39,15 @@ class BaseExecutor(logger.LoggerMixin):
         """
         pass
 
-    @staticmethod
-    def _task_started(task):
-        events.start_task_signal.send(task)
+    def _task_started(self, task):
+        self._signal(events.start_task_signal, task)
 
-    @staticmethod
-    def _task_failed(task, exception):
-        events.on_failure_task_signal.send(task, exception=exception)
+    def _task_failed(self, task, exception):
+        self._signal(events.on_failure_task_signal, task, exception=exception)
+
+    def _task_succeeded(self, task):
+        self._signal(events.on_success_task_signal, task)
 
     @staticmethod
-    def _task_succeeded(task):
-        events.on_success_task_signal.send(task)
+    def _signal(signal, task, **kwargs):
+        signal.send(task, **kwargs)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/orchestrator/workflows/executor/thread.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/thread.py b/aria/orchestrator/workflows/executor/thread.py
index 7ae0217..6c59986 100644
--- a/aria/orchestrator/workflows/executor/thread.py
+++ b/aria/orchestrator/workflows/executor/thread.py
@@ -63,5 +63,5 @@ class ThreadExecutor(BaseExecutor):
                 except BaseException as e:
                     self._task_failed(task, exception=e)
             # Daemon threads
-            except BaseException:
+            except BaseException as e:
                 pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/storage/modeling/orchestrator_elements.py
----------------------------------------------------------------------
diff --git a/aria/storage/modeling/orchestrator_elements.py b/aria/storage/modeling/orchestrator_elements.py
index 47fe49f..854f00b 100644
--- a/aria/storage/modeling/orchestrator_elements.py
+++ b/aria/storage/modeling/orchestrator_elements.py
@@ -471,13 +471,11 @@ class TaskBase(ModelMixin):
 class LogBase(ModelMixin):
     __tablename__ = 'log'
 
-    logger = Column(String)
     level = Column(String)
     msg = Column(String)
     created_at = Column(DateTime, index=True)
-    prefix = Column(String)
-    description = Column(String)
+    actor = Column(String)
 
     def __repr__(self):
-        return "{self.created_at}: [{self.level}] @{self.prefix} ->{msg}".format(
+        return "<{self.created_at}: [{self.level}] @{self.actor}> {msg}".format(
             self=self, msg=self.msg[:50])

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/aria/utils/imports.py
----------------------------------------------------------------------
diff --git a/aria/utils/imports.py b/aria/utils/imports.py
index e9c164e..1782d16 100644
--- a/aria/utils/imports.py
+++ b/aria/utils/imports.py
@@ -18,6 +18,7 @@ Utility methods for dynamically loading python code
 """
 
 import importlib
+import pkgutil
 
 
 def import_fullname(name, paths=None):
@@ -76,3 +77,25 @@ def load_attribute(attribute_path):
     except AttributeError:
         # TODO: handle
         raise
+
+
+class _SafeModuleImporter(object):
+    def __init__(self):
+        self._yielded = {}
+
+    def iter_modules(self):
+        # apparently pkgutil had some issues in python 2.6. Accessing any root level directories
+        # failed. and it got the entire process of importing fail. Since we only need any
+        # aria_extension related loading, in the meantime we could try to import only those
+        # (and assume they are not located at the root level.
+        # [In python 2.7 it does actually ignore any OSError].
+        for importer in pkgutil.iter_importers():
+            try:
+                for module_name, ispkg in pkgutil.iter_importer_modules(importer):
+                    if module_name not in self._yielded:
+                        self._yielded[module_name] = True
+                        yield importer, module_name, ispkg
+            except OSError:
+                pass
+
+iter_modules = _SafeModuleImporter().iter_modules

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/tests/conftest.py
----------------------------------------------------------------------
diff --git a/tests/conftest.py b/tests/conftest.py
index 4b24f18..c501eeb 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import logging
+
 import pytest
 
 import aria
@@ -21,3 +23,25 @@ import aria
 @pytest.fixture(scope='session', autouse=True)
 def install_aria_extensions():
     aria.install_aria_extensions()
+
+
+@pytest.fixture(autouse=True)
+def logging_handler_cleanup(request):
+    """
+    Each time a test runs, the loggers do not clear. we need to manually clear them or we'd have
+    logging overload.
+
+    Since every type of logger (node/relationship/workflow) share the same name, we should
+    clear the logger each test. This should not happen in real world use.
+    :param request:
+    :return:
+    """
+    def clear_logging_handlers():
+        logged_ctx_names = [
+            aria.orchestrator.context.workflow.WorkflowContext.__name__,
+            aria.orchestrator.context.operation.NodeOperationContext.__name__,
+            aria.orchestrator.context.operation.RelationshipOperationContext.__name__
+        ]
+        for logger_name in logged_ctx_names:
+            logging.getLogger(logger_name).handlers = []
+    request.addfinalizer(clear_logging_handlers)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/tests/orchestrator/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py
index c2f5fd0..50e0af4 100644
--- a/tests/orchestrator/context/test_operation.py
+++ b/tests/orchestrator/context/test_operation.py
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 import os
-
+import time
 import logging
 import tempfile
 
@@ -71,16 +71,6 @@ def thread_executor():
         result.close()
 
 
-@pytest.fixture(params=[(thread.ThreadExecutor()),
-                        (process.ProcessExecutor(python_path=tests.ROOT_DIR))])
-def executor(request):
-    ex = request.param
-    try:
-        yield ex
-    finally:
-        ex.close()
-
-
 def test_node_operation_task_execution(ctx, thread_executor):
     operation_name = 'aria.interfaces.lifecycle.create'
 
@@ -236,6 +226,18 @@ def test_plugin_workdir(ctx, thread_executor, tmpdir):
     assert expected_file.read() == content
 
 
+@pytest.fixture(params=[
+    (thread.ThreadExecutor()),
+    (process.ProcessExecutor(python_path=tests.ROOT_DIR))
+])
+def executor(request):
+    ex = request.param
+    try:
+        yield ex
+    finally:
+        ex.close()
+
+
 def test_operation_logging(ctx, executor):
     operation_name = 'aria.interfaces.lifecycle.create'
 
@@ -266,7 +268,7 @@ def test_operation_logging(ctx, executor):
 
     logs = ctx.model.log.list()
 
-    assert len(logs) == 2
+    assert len(logs) == 6
 
     op_start_log = [l for l in logs if inputs['op_start'] in l.msg and l.level.lower() == 'info']
     assert len(op_start_log) == 1
@@ -294,6 +296,8 @@ class MockLogHandler(logging.Handler):
 @operation(logging_handlers=[MockLogHandler()])
 def logged_operation(ctx, **_):
     ctx.logger.info(ctx.task.inputs['op_start'])
+    # enables to check the relation between the created_at field properly
+    time.sleep(1)
     ctx.logger.debug(ctx.task.inputs['op_end'])
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/tests/orchestrator/execution_plugin/test_ssh.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/execution_plugin/test_ssh.py b/tests/orchestrator/execution_plugin/test_ssh.py
index cf4c7e1..ad577f0 100644
--- a/tests/orchestrator/execution_plugin/test_ssh.py
+++ b/tests/orchestrator/execution_plugin/test_ssh.py
@@ -417,7 +417,8 @@ class TestFabricEnvHideGroupsAndRunCommands(object):
     @contextlib.contextmanager
     def _mock_self_logging(*args, **kwargs):
         yield
-    _Ctx.self_logging = _mock_self_logging
+    _Ctx.logging_handlers = _mock_self_logging
+
 
     @pytest.fixture(autouse=True)
     def _setup(self, mocker):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/tests/orchestrator/workflows/executor/test_executor.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_executor.py b/tests/orchestrator/workflows/executor/test_executor.py
index 64dfb66..8da801e 100644
--- a/tests/orchestrator/workflows/executor/test_executor.py
+++ b/tests/orchestrator/workflows/executor/test_executor.py
@@ -95,10 +95,6 @@ class MockContext(object):
     def deserialize_from_dict(cls, **kwargs):
         return cls()
 
-    @contextmanager
-    def self_logging(self):
-        yield self.logger
-
 
 class MockTask(object):
 
@@ -128,10 +124,6 @@ class MockTask(object):
     def _update(self):
         yield self
 
-    @contextmanager
-    def self_logging(self):
-        yield self.logger
-
 
 @pytest.fixture(params=[
     (thread.ThreadExecutor, {'pool_size': 1}),

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/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 1bdc1e4..2d43261 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor.py
@@ -112,7 +112,7 @@ def mock_plugin(plugin_manager, tmpdir):
 class MockContext(object):
 
     def __init__(self, *args, **kwargs):
-        pass
+        self.logger = logging.getLogger('mock_logger')
 
     def __getattr__(self, item):
         if item == 'serialization_dict':
@@ -124,7 +124,6 @@ class MockContext(object):
     def deserialize_from_dict(cls, **kwargs):
         return cls()
 
-
 class MockTask(object):
 
     INFINITE_RETRIES = aria_model.Task.INFINITE_RETRIES

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c37f075b/tests/test_logger.py
----------------------------------------------------------------------
diff --git a/tests/test_logger.py b/tests/test_logger.py
index 1ad055c..6457884 100644
--- a/tests/test_logger.py
+++ b/tests/test_logger.py
@@ -54,7 +54,7 @@ def test_create_console_log_handler(capsys):
     logger.debug(debug_test_string)
     _, err = capsys.readouterr()
 
-    assert err.count('[DEBUG] {test_string}'.format(test_string=debug_test_string))
+    assert '[DEBUG]> {test_string}'.format(test_string=debug_test_string) in err
     assert err.count(info_test_string) == 1
 
     # Custom handler