aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wick...@apache.org
Subject incubator-aurora git commit: Fix test_executor_vars so that it doesn't attempt to get a real PEX-INFO.
Date Sat, 14 Feb 2015 01:23:36 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master d4553110b -> c599e0c49


Fix test_executor_vars so that it doesn't attempt to get a real PEX-INFO.

Testing Done:
./pants src/test/python/apache/aurora/executor:executor_vars -v

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


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

Branch: refs/heads/master
Commit: c599e0c492ee44b16f4b89bd005c62f0bfd7486a
Parents: d455311
Author: Brian Wickman <wickman@apache.org>
Authored: Fri Feb 13 17:22:34 2015 -0800
Committer: Brian Wickman <wickman@apache.org>
Committed: Fri Feb 13 17:22:34 2015 -0800

----------------------------------------------------------------------
 .../apache/aurora/executor/executor_vars.py     | 33 --------------------
 src/test/python/apache/aurora/executor/BUILD    |  1 +
 .../aurora/executor/test_executor_vars.py       | 27 ----------------
 3 files changed, 1 insertion(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c599e0c4/src/main/python/apache/aurora/executor/executor_vars.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/executor_vars.py b/src/main/python/apache/aurora/executor/executor_vars.py
index dfa1a66..283b624 100644
--- a/src/main/python/apache/aurora/executor/executor_vars.py
+++ b/src/main/python/apache/aurora/executor/executor_vars.py
@@ -32,44 +32,11 @@ class ExecutorVars(Observable, ExceptionalThread):
     pending MESOS-433.
   """
   MUTATOR_METRICS = ('rss', 'cpu', 'thermos_pss', 'thermos_cpu')
-  RELEASE_TAG_FORMAT = ScanfParser('%(project)s_R%(release)d')
-  DEPLOY_TAG_FORMAT = ScanfParser('%(project)s_%(environment)s_%(release)d_R%(deploy)d')
-  PROJECT_NAMES = ('thermos', 'thermos_executor')
   COLLECTION_INTERVAL = Amount(1, Time.MINUTES)
 
-  @classmethod
-  def get_release_from_tag(cls, tag):
-    def parse_from(parser):
-      try:
-        scanf = parser.parse(tag)
-        if scanf and scanf.project in cls.PROJECT_NAMES:
-          return scanf.release
-      except ScanfParser.ParseError:
-        pass
-    release = parse_from(cls.RELEASE_TAG_FORMAT)
-    if release is None:
-      release = parse_from(cls.DEPLOY_TAG_FORMAT)
-    if release is None:
-      release = 'UNKNOWN'
-    return release
-
-  @classmethod
-  def get_release_from_binary(cls, binary):
-    try:
-      pex_info = PexInfo.from_pex(binary)
-      return cls.get_release_from_tag(pex_info.build_properties.get('tag', ''))
-    except (BadZipfile, IOError, OSError):
-      return 'UNKNOWN'
-
   def __init__(self, clock=time):
     self._clock = clock
     self._self = psutil.Process(os.getpid())
-    try:
-      self._version = self.get_release_from_binary(
-        os.path.join(self._self.cwd(), self._self.cmdline()[1]))
-    except (IndexError, psutil.Error):
-      self._version = 'UNKNOWN'
-    self.metrics.register(NamedGauge('version', self._version))
     self._orphan = False
     self.metrics.register(LambdaGauge('orphan', lambda: int(self._orphan)))
     self._metrics = dict((metric, MutatorGauge(metric, 0)) for metric in self.MUTATOR_METRICS)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c599e0c4/src/test/python/apache/aurora/executor/BUILD
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/BUILD b/src/test/python/apache/aurora/executor/BUILD
index ec73285..2ee9b12 100644
--- a/src/test/python/apache/aurora/executor/BUILD
+++ b/src/test/python/apache/aurora/executor/BUILD
@@ -116,6 +116,7 @@ python_tests(name = 'status_manager',
 python_tests(name = 'executor_vars',
   sources = ['test_executor_vars.py'],
   dependencies = [
+    '3rdparty/python:mock',
     '3rdparty/python:twitter.common.contextutil',
     'src/main/python/apache/aurora/executor:executor_vars',
   ]

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c599e0c4/src/test/python/apache/aurora/executor/test_executor_vars.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/test_executor_vars.py b/src/test/python/apache/aurora/executor/test_executor_vars.py
index af1c7b7..fa1bf8d 100644
--- a/src/test/python/apache/aurora/executor/test_executor_vars.py
+++ b/src/test/python/apache/aurora/executor/test_executor_vars.py
@@ -12,40 +12,13 @@
 # limitations under the License.
 #
 
-from twitter.common.contextutil import open_zip, temporary_file
-
 from apache.aurora.executor.executor_vars import ExecutorVars
 
 
-def test_release_from_tag():
-  unknown_tags = (
-    '', 'thermos_0', 'thermos_executor_0', 'thermos_0.2.3', 'wat', 'asdfasdfasdf',
-    'thermos-r32', 'thermos_r32')
-  for tag in unknown_tags:
-    assert ExecutorVars.get_release_from_tag(tag) == 'UNKNOWN'
-  assert ExecutorVars.get_release_from_tag('thermos_R0') == 0
-  assert ExecutorVars.get_release_from_tag('thermos_R32') == 32
-  assert ExecutorVars.get_release_from_tag('thermos_executor_R12') == 12
-  assert ExecutorVars.get_release_from_tag('thermos_smf1-test_16_R32') == 16
-  assert ExecutorVars.get_release_from_tag('thermos_executor_smf1-test_23_R10') == 23
-
-
-def test_extract_pexinfo():
-  filename = None
-  with temporary_file() as fp:
-    filename = fp.name
-    with open_zip(filename, 'w') as zf:
-      zf.writestr('PEX-INFO', '{"build_properties":{"tag":"thermos_R31337"}}')
-    assert ExecutorVars.get_release_from_binary(filename) == 31337
-  assert ExecutorVars.get_release_from_binary(filename) == 'UNKNOWN'
-  assert ExecutorVars.get_release_from_binary('lololololo') == 'UNKNOWN'
-
-
 def test_init():
   self = ExecutorVars()
   assert self._orphan is False
   samples = self.metrics.sample()
-  assert samples['version'] == 'UNKNOWN'
   assert samples['orphan'] == 0
 
 


Mime
View raw message