[ https://issues.apache.org/jira/browse/BEAM-8575?focusedWorklogId=361289&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-361289 ]
ASF GitHub Bot logged work on BEAM-8575: ---------------------------------------- Author: ASF GitHub Bot Created on: 18/Dec/19 04:38 Start Date: 18/Dec/19 04:38 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_r357487258 ########## 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) Review comment: Done. After using different words as input, the mean is now 3. self.assertEqual(word_len_dist.result.mean, 3) ---------------------------------------------------------------- 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: 361289) Time Spent: 38h (was: 37h 50m) > 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: 38h > 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)