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 BB4D410483 for ; Sat, 14 Feb 2015 01:23:58 +0000 (UTC) Received: (qmail 52359 invoked by uid 500); 14 Feb 2015 01:23:58 -0000 Delivered-To: apmail-aurora-commits-archive@aurora.apache.org Received: (qmail 52325 invoked by uid 500); 14 Feb 2015 01:23:58 -0000 Mailing-List: contact commits-help@aurora.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.incubator.apache.org Delivered-To: mailing list commits@aurora.incubator.apache.org Received: (qmail 52264 invoked by uid 99); 14 Feb 2015 01:23:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Feb 2015 01:23:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 14 Feb 2015 01:23:57 +0000 Received: (qmail 52093 invoked by uid 99); 14 Feb 2015 01:23:37 -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; Sat, 14 Feb 2015 01:23:37 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BA1F1E03A1; Sat, 14 Feb 2015 01:23:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: wickman@apache.org To: commits@aurora.incubator.apache.org Message-Id: <65ecf1d7930d4531b8e119c0598ffa0e@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org 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 Authored: Fri Feb 13 17:22:34 2015 -0800 Committer: Brian Wickman 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