[ 
https://issues.apache.org/jira/browse/BEAM-8575?focusedWorklogId=359117&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-359117
 ]

ASF GitHub Bot logged work on BEAM-8575:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 13/Dec/19 03:31
            Start Date: 13/Dec/19 03:31
    Worklog Time Spent: 10m 
      Work Description: bumblebee-coming commented on pull request #10190: 
[BEAM-8575] Added two unit tests to CombineTest class to test that Co…
URL: https://github.com/apache/beam/pull/10190#discussion_r357472802
 
 

 ##########
 File path: sdks/python/apache_beam/transforms/combiners_test.py
 ##########
 @@ -399,6 +432,108 @@ def test_global_fanout(self):
           | beam.CombineGlobally(combine.MeanCombineFn()).with_fanout(11))
       assert_that(result, equal_to([49.5]))
 
+  # Test that three different kinds of metrics work with a customized
+  # CounterIncrememtingCombineFn.
+  def test_simple_combine(self):
+    p = TestPipeline()
+    input = (p
+             | beam.Create([('c', 'b'),
+                            ('c', 'be'),
+                            ('c', 'bea'),
+                            ('d', 'beam'),
+                            ('d', 'apache')]))
+
+    # The result of concatenating all values regardless of key.
+    global_concat = (input
+                     | beam.Values()
+                     | beam.CombineGlobally(CounterIncrememtingCombineFn()))
+
+    # The (key, concatenated_string) pairs for all keys.
+    concat_per_key = (input | beam.CombinePerKey(
+        CounterIncrememtingCombineFn()))
+
+    result = p.run()
+    result.wait_until_finish()
+
+    # Verify the concatenated strings are correct.
+    expected_concat_per_key = [('c', 'bbebea'), ('d', 'beamapache')]
+    assert_that(global_concat, equal_to(['bbebeabeamapache']),
+                label='global concat')
+    assert_that(concat_per_key, equal_to(expected_concat_per_key),
+                label='concat per key')
+
+    # Verify the values of metrics are correct.
+    word_counter_filter = MetricsFilter().with_name('word_counter')
+    query_result = result.metrics().query(word_counter_filter)
+    if query_result['counters']:
+      word_counter = query_result['counters'][0]
+      self.assertEqual(word_counter.result, 5)
+
+    word_lengths_filter = MetricsFilter().with_name('word_lengths')
+    query_result = result.metrics().query(word_lengths_filter)
+    if query_result['counters']:
+      word_lengths = query_result['counters'][0]
+      self.assertEqual(word_lengths.result, 16)
+
+    word_len_dist_filter = MetricsFilter().with_name('word_len_dist')
+    query_result = result.metrics().query(word_len_dist_filter)
+    if query_result['distributions']:
+      word_len_dist = query_result['distributions'][0]
+      self.assertEqual(word_len_dist.result.mean, 3.2)
+
+    last_word_len_filter = MetricsFilter().with_name('last_word_len')
+    query_result = result.metrics().query(last_word_len_filter)
+    if query_result['gauges']:
+      last_word_len = query_result['gauges'][0]
+      self.assertEqual(last_word_len.result.value, 6)
 
 Review comment:
   Done. Changed to self.assertIn(last_word_len.result.value, [1, 2, 3, 4, 5])
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 359117)
    Time Spent: 34h 10m  (was: 34h)

> Add more Python validates runner tests
> --------------------------------------
>
>                 Key: BEAM-8575
>                 URL: https://issues.apache.org/jira/browse/BEAM-8575
>             Project: Beam
>          Issue Type: Test
>          Components: sdk-py-core, testing
>            Reporter: wendy liu
>            Assignee: wendy liu
>            Priority: Major
>          Time Spent: 34h 10m
>  Remaining Estimate: 0h
>
> This is the umbrella issue to track the work of adding more Python tests to 
> improve test coverage.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to