Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BEA78200C22 for ; Tue, 21 Feb 2017 22:59:37 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id BD5A5160B68; Tue, 21 Feb 2017 21:59:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DE208160B4F for ; Tue, 21 Feb 2017 22:59:36 +0100 (CET) Received: (qmail 39606 invoked by uid 500); 21 Feb 2017 21:59:36 -0000 Mailing-List: contact dev-help@ariatosca.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ariatosca.incubator.apache.org Delivered-To: mailing list dev@ariatosca.incubator.apache.org Received: (qmail 39594 invoked by uid 99); 21 Feb 2017 21:59:36 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Feb 2017 21:59:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id AAB64C67DE for ; Tue, 21 Feb 2017 21:59:35 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -2.222 X-Spam-Level: X-Spam-Status: No, score=-2.222 tagged_above=-999 required=6.31 tests=[HK_RANDOM_FROM=0.999, KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id new4_Jp5us3M for ; Tue, 21 Feb 2017 21:59:34 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id E4A1D5F4A8 for ; Tue, 21 Feb 2017 21:59:33 +0000 (UTC) Received: (qmail 39586 invoked by uid 99); 21 Feb 2017 21:59:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Feb 2017 21:59:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1AF5CDFADC; Tue, 21 Feb 2017 21:59:33 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mxmrlv@apache.org To: dev@ariatosca.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-ariatosca git commit: added logger handlers cleanup, and fixed some mock tests Date: Tue, 21 Feb 2017 21:59:33 +0000 (UTC) archived-at: Tue, 21 Feb 2017 21:59:37 -0000 Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-106-Create-sqla-logging-handler ad0c52749 -> 248f1b11b added logger handlers cleanup, and fixed some mock tests Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/248f1b11 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/248f1b11 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/248f1b11 Branch: refs/heads/ARIA-106-Create-sqla-logging-handler Commit: 248f1b11b80b0d3325a2e91b4ab2c838e07ec6fe Parents: ad0c527 Author: mxmrlv Authored: Tue Feb 21 23:59:21 2017 +0200 Committer: mxmrlv Committed: Tue Feb 21 23:59:21 2017 +0200 ---------------------------------------------------------------------- aria/orchestrator/workflows/executor/process.py | 1 - tests/conftest.py | 24 ++++++++++++++++++++ tests/orchestrator/execution_plugin/test_ssh.py | 7 ++++++ .../workflows/executor/test_process_executor.py | 3 +-- 4 files changed, 32 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/248f1b11/aria/orchestrator/workflows/executor/process.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/executor/process.py b/aria/orchestrator/workflows/executor/process.py index ecc8ca4..d999b37 100644 --- a/aria/orchestrator/workflows/executor/process.py +++ b/aria/orchestrator/workflows/executor/process.py @@ -362,7 +362,6 @@ def _patch_session(ctx, messenger, instrument): def _main(): - arguments_json_path = sys.argv[1] with open(arguments_json_path) as f: arguments = pickle.loads(f.read()) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/248f1b11/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/248f1b11/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 0981b61..ad577f0 100644 --- a/tests/orchestrator/execution_plugin/test_ssh.py +++ b/tests/orchestrator/execution_plugin/test_ssh.py @@ -413,6 +413,13 @@ class TestFabricEnvHideGroupsAndRunCommands(object): task.runs_on = Stub logger = logging.getLogger() + @staticmethod + @contextlib.contextmanager + def _mock_self_logging(*args, **kwargs): + yield + _Ctx.logging_handlers = _mock_self_logging + + @pytest.fixture(autouse=True) def _setup(self, mocker): self.default_fabric_env = { http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/248f1b11/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