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 <[email protected]> Authored: Wed Jan 11 17:55:15 2017 -0800 Committer: Robert Bradshaw <[email protected]> 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)))))
