@@ -1613,7 +1613,10 @@ def _capture_stdout_log(request, capsys):
16131613 ])
16141614 | beam .WindowInto (FixedWindows (60 ))
16151615 | util .LogElements (
1616- prefix = 'prefix_' , with_window = True , with_timestamp = True ))
1616+ prefix = 'prefix_' ,
1617+ with_window = True ,
1618+ with_timestamp = True ,
1619+ with_pane_info = True ))
16171620
16181621 request .captured_stdout = capsys .readouterr ().out
16191622 return result
@@ -1622,9 +1625,46 @@ def _capture_stdout_log(request, capsys):
16221625 def test_stdout_logs (self ):
16231626 assert self .captured_stdout == \
16241627 ("prefix_event, timestamp='2022-10-01T00:00:00Z', "
1625- "window(start=2022-10-01T00:00:00Z, end=2022-10-01T00:01:00Z)\n "
1628+ "window(start=2022-10-01T00:00:00Z, end=2022-10-01T00:01:00Z), "
1629+ "pane_info=PaneInfo(first: True, last: True, timing: UNKNOWN, "
1630+ "index: 0, nonspeculative_index: 0)\n "
16261631 "prefix_event, timestamp='2022-10-02T00:00:00Z', "
1627- "window(start=2022-10-02T00:00:00Z, end=2022-10-02T00:01:00Z)\n " ), \
1632+ "window(start=2022-10-02T00:00:00Z, end=2022-10-02T00:01:00Z), "
1633+ "pane_info=PaneInfo(first: True, last: True, timing: UNKNOWN, "
1634+ "index: 0, nonspeculative_index: 0)\n " ), \
1635+ f'Received from stdout: { self .captured_stdout } '
1636+
1637+ @pytest .fixture (scope = "function" )
1638+ def _capture_stdout_log_without_rfc3339 (request , capsys ):
1639+ with TestPipeline () as p :
1640+ result = (
1641+ p | beam .Create ([
1642+ TimestampedValue (
1643+ "event" ,
1644+ datetime (2022 , 10 , 1 , 0 , 0 , 0 , 0 ,
1645+ tzinfo = pytz .UTC ).timestamp ()),
1646+ TimestampedValue (
1647+ "event" ,
1648+ datetime (2022 , 10 , 2 , 0 , 0 , 0 , 0 ,
1649+ tzinfo = pytz .UTC ).timestamp ()),
1650+ ])
1651+ | beam .WindowInto (FixedWindows (60 ))
1652+ | util .LogElements (
1653+ prefix = 'prefix_' ,
1654+ with_window = True ,
1655+ with_timestamp = True ,
1656+ use_epoch_time = True ))
1657+
1658+ request .captured_stdout = capsys .readouterr ().out
1659+ return result
1660+
1661+ @pytest .mark .usefixtures ("_capture_stdout_log_without_rfc3339" )
1662+ def test_stdout_logs_without_rfc3339 (self ):
1663+ assert self .captured_stdout == \
1664+ ("prefix_event, timestamp=1664582400, "
1665+ "window(start=1664582400, end=1664582460)\n "
1666+ "prefix_event, timestamp=1664668800, "
1667+ "window(start=1664668800, end=1664668860)\n " ), \
16281668 f'Received from stdout: { self .captured_stdout } '
16291669
16301670 def test_ptransform_output (self ):
0 commit comments