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

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

                Author: ASF GitHub Bot
            Created on: 10/May/18 18:38
            Start Date: 10/May/18 18:38
    Worklog Time Spent: 10m 
      Work Description: aaltay commented on a change in pull request #5279: 
[BEAM-3377] Call assert_that per window via windowed (flag)
URL: https://github.com/apache/beam/pull/5279#discussion_r187420587
 
 

 ##########
 File path: sdks/python/apache_beam/testing/util.py
 ##########
 @@ -75,6 +75,25 @@ def __repr__(self):
   return InAnyOrder(iterable)
 
 
+def equal_to_per_window(expected_dict_window_to_its_elements):
+  def matcher(elements):
+    actual_elements_in_window, window = elements
+    if window in expected_dict_window_to_its_elements:
+      expected_elements_in_window = list(
+          expected_dict_window_to_its_elements[window])
+      sorted_expected = sorted(expected_elements_in_window)
+      sorted_actual = sorted(actual_elements_in_window)
+      if sorted_expected != sorted_actual:
+        # Results for the same window don't necessarily come all
+        # at once. Hence the same actual window may contain only
+        # subsets of the expected elements for the window.
+        # For example, in the presence of early triggers.
+        if all(elem in sorted_expected  for elem in sorted_actual) is False:
 
 Review comment:
   <!--new_thread; commit:1d8257d6902c54d33062c23cce99e06fbf42c41d; 
resolved:0-->
   It looks like there is an extra space at `sorted_expected  for`, before 
`for`. I am not sure why lint did not catch it.
   
   Could you remove the extra space?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 100758)

> assert_that not working for streaming
> -------------------------------------
>
>                 Key: BEAM-3377
>                 URL: https://issues.apache.org/jira/browse/BEAM-3377
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-core
>    Affects Versions: 2.2.0
>            Reporter: MarĂ­a GH
>            Priority: Major
>              Labels: starter
>          Time Spent: 2h
>  Remaining Estimate: 0h
>
> assert_that does not work for AfterWatermark timers.
> Easy way to reproduce: modify test_gbk_execution [1] in this form:
>  
> {code:java}
>  def test_this(self):
>     test_stream = (TestStream()
>                    .add_elements(['a', 'b', 'c'])
>                    .advance_watermark_to(20))
>     def fnc(x):
>       print 'fired_elem:', x
>       return x
>     options = PipelineOptions()
>     options.view_as(StandardOptions).streaming = True
>     p = TestPipeline(options=options)
>     records = (p
>                | test_stream
>                | beam.WindowInto(
>                    FixedWindows(15),
>                    
> trigger=trigger.AfterWatermark(early=trigger.AfterCount(2)),
>                    accumulation_mode=trigger.AccumulationMode.ACCUMULATING)
>                | beam.Map(lambda x: ('k', x))
>                | beam.GroupByKey())
>     assert_that(records, equal_to([
>         ('k', ['a', 'b', 'c'])]))
>     p.run()
> {code}
> This test will pass, but if the .advance_watermark_to(20) is removed, the 
> test will fail. However, both cases fire the same elements:
>       fired_elem: ('k', ['a', 'b', 'c'])
>       fired_elem: ('k', ['a', 'b', 'c'])
> In the passing case, they correspond to the sorted_actual inside the 
> assert_that. In the failing case:
>       sorted_actual: [('k', ['a', 'b', 'c']), ('k', ['a', 'b', 'c'])]
>       sorted_actual: []
> [1] 
> https://github.com/mariapython/incubator-beam/blob/direct-timers-show/sdks/python/apache_beam/testing/test_stream_test.py#L120



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to