You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by zm...@apache.org on 2015/11/23 22:57:16 UTC

aurora git commit: Cleanup thermos_executor test pexes.

Repository: aurora
Updated Branches:
  refs/heads/master 3fbea09e5 -> fe028ad99


Cleanup thermos_executor test pexes.

Previously these were built to the standard `dist/` dir, now they are
dumped to a tmp dir that's cleaned up.

Testing Done:
Green locally:
```
$ rm -rf dist/ && \
  ./pants test.pytest --no-fast src/test/python/apache/aurora/executor:
```

And no `dist/` created.

Bugs closed: AURORA-547

Reviewed at https://reviews.apache.org/r/40201/


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

Branch: refs/heads/master
Commit: fe028ad9999c5d247f1a41bbedda957adba27fad
Parents: 3fbea09
Author: John Sirois <jo...@gmail.com>
Authored: Mon Nov 23 13:56:45 2015 -0800
Committer: Zameer Manji <zm...@apache.org>
Committed: Mon Nov 23 13:56:45 2015 -0800

----------------------------------------------------------------------
 .../aurora/executor/test_thermos_executor.py    | 24 ++++++++++++++++----
 .../aurora/executor/test_thermos_task_runner.py | 15 ++++++++----
 2 files changed, 29 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/fe028ad9/src/test/python/apache/aurora/executor/test_thermos_executor.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/test_thermos_executor.py b/src/test/python/apache/aurora/executor/test_thermos_executor.py
index d24c611..32e8b9b 100644
--- a/src/test/python/apache/aurora/executor/test_thermos_executor.py
+++ b/src/test/python/apache/aurora/executor/test_thermos_executor.py
@@ -170,9 +170,21 @@ MESOS_JOB = MesosJob(
 )
 
 
+def thermos_runner_path(build=True):
+  if not build:
+    return getattr(thermos_runner_path, 'value', None)
+
+  if not hasattr(thermos_runner_path, 'value'):
+    pex_dir = safe_mkdtemp()
+    assert subprocess.call(["./pants", "--pants-distdir=%s" % pex_dir, "binary",
+      "src/main/python/apache/thermos/runner:thermos_runner"]) == 0
+    thermos_runner_path.value = os.path.join(pex_dir, 'thermos_runner.pex')
+  return thermos_runner_path.value
+
+
 def make_provider(checkpoint_root, runner_class=ThermosTaskRunner):
   return DefaultThermosTaskRunnerProvider(
-      pex_location=os.path.join('dist', 'thermos_runner.pex'),
+      pex_location=thermos_runner_path(),
       checkpoint_root=checkpoint_root,
       task_runner_class=runner_class,
   )
@@ -266,17 +278,19 @@ class TestThermosExecutor(object):
     LogOptions.set_log_dir(cls.LOG_DIR)
     LogOptions.set_disk_log_level('DEBUG')
     log.init('executor_logger')
-    if not cls.PANTS_BUILT and 'SKIP_PANTS_BUILD' not in os.environ:
-      assert subprocess.call(["./pants", "binary",
-          "src/main/python/apache/thermos/runner:thermos_runner"]) == 0
-      cls.PANTS_BUILT = True
 
   @classmethod
   def teardown_class(cls):
     if 'THERMOS_DEBUG' not in os.environ:
       safe_rmtree(cls.LOG_DIR)
+      thermos_path = thermos_runner_path(build=False)
+      if thermos_path:
+        safe_rmtree(os.path.dirname(thermos_path))
     else:
       print('Saving executor logs in %s' % cls.LOG_DIR)
+      thermos_path = thermos_runner_path(build=False)
+      if thermos_path:
+        print('Saved thermos executor at %s' % thermos_path)
 
   def test_basic(self):
     proxy_driver = ProxyDriver()

http://git-wip-us.apache.org/repos/asf/aurora/blob/fe028ad9/src/test/python/apache/aurora/executor/test_thermos_task_runner.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/test_thermos_task_runner.py b/src/test/python/apache/aurora/executor/test_thermos_task_runner.py
index bb998c0..789d2bf 100644
--- a/src/test/python/apache/aurora/executor/test_thermos_task_runner.py
+++ b/src/test/python/apache/aurora/executor/test_thermos_task_runner.py
@@ -58,7 +58,7 @@ TASK = MesosTaskInstance(
 
 
 class TestThermosTaskRunnerIntegration(object):
-  PANTS_BUILT = False
+  PEX_PATH = None
   LOG_DIR = None
 
   @classmethod
@@ -67,17 +67,22 @@ class TestThermosTaskRunnerIntegration(object):
     LogOptions.set_log_dir(cls.LOG_DIR)
     LogOptions.set_disk_log_level('DEBUG')
     log.init('executor_logger')
-    if not cls.PANTS_BUILT and 'SKIP_PANTS_BUILD' not in os.environ:
-      assert subprocess.call(["./pants", "binary",
+    if not cls.PEX_PATH:
+      pex_dir = tempfile.mkdtemp()
+      assert subprocess.call(["./pants", "--pants-distdir=%s" % pex_dir, "binary",
           "src/main/python/apache/thermos/runner:thermos_runner"]) == 0
-      cls.PANTS_BUILT = True
+      cls.PEX_PATH = os.path.join(pex_dir, 'thermos_runner.pex')
 
   @classmethod
   def teardown_class(cls):
     if 'THERMOS_DEBUG' not in os.environ:
       safe_rmtree(cls.LOG_DIR)
+      if cls.PEX_PATH:
+        safe_rmtree(os.path.dirname(cls.PEX_PATH))
     else:
       print('Saving executor logs in %s' % cls.LOG_DIR)
+      if cls.PEX_PATH:
+        print('Saved thermos executor at %s' % cls.PEX_PATH)
 
   @contextlib.contextmanager
   def yield_runner(self, runner_class, portmap=None, clock=time, **bindings):
@@ -88,7 +93,7 @@ class TestThermosTaskRunnerIntegration(object):
         portmap = {}
 
       task_runner = runner_class(
-          runner_pex=os.path.join('dist', 'thermos_runner.pex'),
+          runner_pex=self.PEX_PATH,
           task_id='hello_world',
           task=TASK.bind(**bindings).task(),
           role=getpass.getuser(),