Return-Path: X-Original-To: apmail-aurora-commits-archive@minotaur.apache.org Delivered-To: apmail-aurora-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1CB8C18A6A for ; Thu, 28 May 2015 17:54:56 +0000 (UTC) Received: (qmail 29358 invoked by uid 500); 28 May 2015 17:54:49 -0000 Delivered-To: apmail-aurora-commits-archive@aurora.apache.org Received: (qmail 29324 invoked by uid 500); 28 May 2015 17:54:49 -0000 Mailing-List: contact commits-help@aurora.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.apache.org Delivered-To: mailing list commits@aurora.apache.org Received: (qmail 29313 invoked by uid 99); 28 May 2015 17:54:49 -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; Thu, 28 May 2015 17:54:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ACF73E10A2; Thu, 28 May 2015 17:54:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: maxim@apache.org To: commits@aurora.apache.org Message-Id: <195721b7319648d6970d8ca38211ff08@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: aurora git commit: Adding ChainedPathDetector into the GC executor. Date: Thu, 28 May 2015 17:54:49 +0000 (UTC) Repository: aurora Updated Branches: refs/heads/master b8ffc62b7 -> 827b9abea Adding ChainedPathDetector into the GC executor. Bugs closed: AURORA-1025 Reviewed at https://reviews.apache.org/r/34739/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/827b9abe Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/827b9abe Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/827b9abe Branch: refs/heads/master Commit: 827b9abea48babe53ad5b2c521757c60f04c6dfc Parents: b8ffc62 Author: Maxim Khutornenko Authored: Thu May 28 10:49:08 2015 -0700 Committer: Maxim Khutornenko Committed: Thu May 28 10:49:08 2015 -0700 ---------------------------------------------------------------------- .../python/apache/aurora/executor/bin/BUILD | 1 + .../aurora/executor/bin/gc_executor_main.py | 33 +++++++++++++------- .../python/apache/aurora/executor/bin/BUILD | 1 + .../bin/test_gc_executor_entry_point.py | 24 +++++++++++++- 4 files changed, 47 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/827b9abe/src/main/python/apache/aurora/executor/bin/BUILD ---------------------------------------------------------------------- diff --git a/src/main/python/apache/aurora/executor/bin/BUILD b/src/main/python/apache/aurora/executor/bin/BUILD index 25cc3d0..6ef669d 100644 --- a/src/main/python/apache/aurora/executor/bin/BUILD +++ b/src/main/python/apache/aurora/executor/bin/BUILD @@ -58,6 +58,7 @@ python_library( 'src/main/python/apache/thermos/common:constants', 'src/main/python/apache/thermos/monitoring:detector', 'src/main/python/apache/aurora/executor/common:executor_detector', + 'src/main/python/apache/aurora/executor/common:path_detector', 'src/main/python/apache/aurora/executor:executor_vars', 'src/main/python/apache/aurora/executor:gc_executor', ] http://git-wip-us.apache.org/repos/asf/aurora/blob/827b9abe/src/main/python/apache/aurora/executor/bin/gc_executor_main.py ---------------------------------------------------------------------- diff --git a/src/main/python/apache/aurora/executor/bin/gc_executor_main.py b/src/main/python/apache/aurora/executor/bin/gc_executor_main.py index 9e65084..8093717 100644 --- a/src/main/python/apache/aurora/executor/bin/gc_executor_main.py +++ b/src/main/python/apache/aurora/executor/bin/gc_executor_main.py @@ -29,9 +29,10 @@ from twitter.common.log.options import LogOptions from twitter.common.metrics.sampler import DiskMetricWriter from apache.aurora.executor.common.executor_detector import ExecutorDetector +from apache.aurora.executor.common.path_detector import MesosPathDetector from apache.aurora.executor.gc_executor import ThermosGCExecutor from apache.thermos.common.constants import DEFAULT_CHECKPOINT_ROOT -from apache.thermos.monitoring.detector import FixedPathDetector +from apache.thermos.monitoring.detector import ChainedPathDetector, FixedPathDetector app.configure(debug=True) @@ -42,23 +43,33 @@ LogOptions.set_disk_log_level('DEBUG') LogOptions.set_log_dir(ExecutorDetector.LOG_PATH) +def initialize(): + path_detector = ChainedPathDetector( + FixedPathDetector(DEFAULT_CHECKPOINT_ROOT), + MesosPathDetector(), + ) + + # Create executor stub + thermos_gc_executor = ThermosGCExecutor(path_detector) + + # Create metrics collector + metric_writer = DiskMetricWriter(thermos_gc_executor.metrics, ExecutorDetector.VARS_PATH) + + # Create driver stub + driver = MesosExecutorDriver(thermos_gc_executor) + + return thermos_gc_executor, metric_writer, driver + + def proxy_main(): def main(): if MesosExecutorDriver is None: app.error('Could not load MesosExecutorDriver!') - # Create executor stub - thermos_gc_executor = ThermosGCExecutor(FixedPathDetector(DEFAULT_CHECKPOINT_ROOT)) - thermos_gc_executor.start() + thermos_gc_executor, metric_writer, driver = initialize() - # Start metrics collection - metric_writer = DiskMetricWriter(thermos_gc_executor.metrics, ExecutorDetector.VARS_PATH) + thermos_gc_executor.start() metric_writer.start() - - # Create driver stub - driver = MesosExecutorDriver(thermos_gc_executor) - - # Start GC executor driver.run() log.info('MesosExecutorDriver.run() has finished.') http://git-wip-us.apache.org/repos/asf/aurora/blob/827b9abe/src/test/python/apache/aurora/executor/bin/BUILD ---------------------------------------------------------------------- diff --git a/src/test/python/apache/aurora/executor/bin/BUILD b/src/test/python/apache/aurora/executor/bin/BUILD index 918a769..b1bcfac 100644 --- a/src/test/python/apache/aurora/executor/bin/BUILD +++ b/src/test/python/apache/aurora/executor/bin/BUILD @@ -24,6 +24,7 @@ python_tests( name = 'gc_executor_entry_point', sources = ['test_gc_executor_entry_point.py'], dependencies = [ + '3rdparty/python:mock', 'src/main/python/apache/aurora/executor/bin:gc_executor_source', ], ) http://git-wip-us.apache.org/repos/asf/aurora/blob/827b9abe/src/test/python/apache/aurora/executor/bin/test_gc_executor_entry_point.py ---------------------------------------------------------------------- diff --git a/src/test/python/apache/aurora/executor/bin/test_gc_executor_entry_point.py b/src/test/python/apache/aurora/executor/bin/test_gc_executor_entry_point.py index d699878..d4c1d57 100644 --- a/src/test/python/apache/aurora/executor/bin/test_gc_executor_entry_point.py +++ b/src/test/python/apache/aurora/executor/bin/test_gc_executor_entry_point.py @@ -12,7 +12,29 @@ # limitations under the License. # +import unittest + +from mock import create_autospec, Mock, patch + +from apache.aurora.executor.bin.gc_executor_main import initialize, proxy_main +from apache.aurora.executor.gc_executor import ThermosGCExecutor +from apache.thermos.monitoring.detector import ChainedPathDetector + def test_gc_executor_valid_import_dependencies(): - from apache.aurora.executor.bin.gc_executor_main import proxy_main assert proxy_main is not None + + +class GcExecutorMainTest(unittest.TestCase): + def test_chained_path_detector_initialized(self): + mock_gc_executor = create_autospec(spec=ThermosGCExecutor) + with patch('apache.aurora.executor.bin.gc_executor_main.ThermosGCExecutor', + return_value=mock_gc_executor) as mock: + with patch('apache.aurora.executor.bin.gc_executor_main.MesosExecutorDriver', + return_value=Mock()): + + initialize() + assert len(mock.mock_calls) == 1 + call = mock.mock_calls[0] + _, args, _ = call + assert len(args) == 1 and isinstance(args[0], ChainedPathDetector)