Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B25A9200C00 for ; Wed, 18 Jan 2017 23:01:10 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B0F08160B44; Wed, 18 Jan 2017 22:01:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0A7EF160B22 for ; Wed, 18 Jan 2017 23:01:09 +0100 (CET) Received: (qmail 1144 invoked by uid 500); 18 Jan 2017 22:01:09 -0000 Mailing-List: contact commits-help@beam.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@beam.apache.org Delivered-To: mailing list commits@beam.apache.org Received: (qmail 1131 invoked by uid 99); 18 Jan 2017 22:01:09 -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; Wed, 18 Jan 2017 22:01:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0E868F1736; Wed, 18 Jan 2017 22:01:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: robertwb@apache.org To: commits@beam.apache.org Date: Wed, 18 Jan 2017 22:01:09 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] beam git commit: Metrics test in start/end_bundle for ParDos archived-at: Wed, 18 Jan 2017 22:01:10 -0000 Repository: beam Updated Branches: refs/heads/python-sdk b737ba907 -> b9cb29c83 Metrics test in start/end_bundle for ParDos Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/18179a1f Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/18179a1f Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/18179a1f Branch: refs/heads/python-sdk Commit: 18179a1f76fddf76466d8cb6b7e1236f1c894edd Parents: b737ba9 Author: Pablo Authored: Wed Jan 11 17:55:15 2017 -0800 Committer: Robert Bradshaw Committed: Wed Jan 18 14:00:57 2017 -0800 ---------------------------------------------------------------------- sdks/python/apache_beam/runners/runner_test.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/18179a1f/sdks/python/apache_beam/runners/runner_test.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/runners/runner_test.py b/sdks/python/apache_beam/runners/runner_test.py index 2b6c316..89a6fdc 100644 --- a/sdks/python/apache_beam/runners/runner_test.py +++ b/sdks/python/apache_beam/runners/runner_test.py @@ -147,10 +147,18 @@ class RunnerTest(unittest.TestCase): from apache_beam.metrics.metric import Metrics class MyDoFn(beam.DoFn): + def start_bundle(self, context): + count = Metrics.counter(self.__class__, 'bundles') + count.inc() + + def finish_bundle(self, context): + count = Metrics.counter(self.__class__, 'finished_bundles') + count.inc() + def process(self, context): count = Metrics.counter(self.__class__, 'elements') count.inc() - distro = Metrics.distribution(self.__class__, 'element-dist') + distro = Metrics.distribution(self.__class__, 'element_dist') distro.update(context.element) return [context.element] @@ -165,17 +173,24 @@ class RunnerTest(unittest.TestCase): metrics = result.metrics().query() namespace = '{}.{}'.format(MyDoFn.__module__, MyDoFn.__name__) + hc.assert_that( metrics['counters'], hc.contains_inanyorder( MetricResult( MetricKey('do', MetricName(namespace, 'elements')), - 5, 5))) + 5, 5), + MetricResult( + MetricKey('do', MetricName(namespace, 'bundles')), + 1, 1), + MetricResult( + MetricKey('do', MetricName(namespace, 'finished_bundles')), + 1, 1))) hc.assert_that( metrics['distributions'], hc.contains_inanyorder( MetricResult( - MetricKey('do', MetricName(namespace, 'element-dist')), + MetricKey('do', MetricName(namespace, 'element_dist')), DistributionResult(DistributionData(15, 5, 1, 5)), DistributionResult(DistributionData(15, 5, 1, 5)))))