aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Adding ChainedPathDetector into the GC executor.
Date Thu, 28 May 2015 17:54:49 GMT
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 <maxim@apache.org>
Authored: Thu May 28 10:49:08 2015 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
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)


Mime
View raw message