-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Fix flakiness in fuzzy tests and support TimestampTypes in PeriodicImpulse. #35470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Looks like
beam/sdks/python/apache_beam/examples/snippets/snippets_test.py Lines 1452 to 1454 in 4d58e6d
beam/sdks/python/apache_beam/examples/snippets/snippets.py Lines 1432 to 1433 in 4d58e6d
I suggest we support all
@damccorm, WDYT? |
|
remind me after tests pass |
|
Ok - I'll remind @shunping after tests pass |
|
All checks have passed: @shunping |
|
Assigning reviewers: R: @liferoad for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
damccorm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this LGTM
…pulse. (apache#35470) * Support TimestampTypes in PeriodicImpulse. Fix flakiness in fuzzy tests. * Fix lints. * Add tests for different timestamp input types. * Use an identity function in map after ImpulseSeqGenDoFn
…pulse. (apache#35470) * Support TimestampTypes in PeriodicImpulse. Fix flakiness in fuzzy tests. * Fix lints. * Add tests for different timestamp input types. * Use an identity function in map after ImpulseSeqGenDoFn
A follow-up on #35412.
I've identified a flaky test in the test_fuzzy_interval for periodic impulse, which you can see in this failed test run. The test fails intermittently because the periodic impulse output is either missing an element or has an extra one.
I can reproduce this failure about once every 50-100 runs. The failure rate increases significantly if the interval is set to 1 microsecond.
Here's a comparison of a normal and a failed run after I added some debugging logs:
Normal run:
Failed run:
The root cause is a loss of precision with 64-bit floating-point numbers. As noted in the Wikipedia article on floating-point arithmetic, the precision is limited to about 15-17 decimal digits.
In the failing example, the start time is
1751056301.35949(16 digits). However, the calculated end time is1751056301.3595698(17 digits). When converting the end time to microseconds (round(end * 1000000)), we get1751056301359569instead of the expected1751056301359570. This rounding error causesdelta_microsto be off by one, leading to the test failure.This shows we can't rely on floating-point representations of start, end, and interval to accurately determine the number of elements to emit.
To fix this, I propose using integer-based timestamp arithmetic for all calculations. By performing these operations on microseconds directly, we can avoid floating-point inaccuracies and ensure the test's stability.