tests: rethrow worker-thread assertion in portable runner test to fix assert_that flake (fixes #35211) - #36355
tests: rethrow worker-thread assertion in portable runner test to fix assert_that flake (fixes #35211)#36355jh1231223 wants to merge 0 commit into
Conversation
Summary of ChangesHello @jh1231223, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical flakiness issue in a specific test by implementing a robust exception propagation mechanism. It ensures that exceptions originating from worker threads during pipeline execution are consistently re-raised on the main thread, thereby converting an intermittently passing test (due to warnings) into a reliably failing one when an assertion condition is not met. This significantly improves the stability and correctness of the test suite. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
7efb3e7 to
08c96f2
Compare
Thanks for reviewing!
It seems the current failures are unrelated to the modifications in this PR. If I’ve overlooked something, please let me know and I’ll address it promptly.
Context / Issue
PortableRunnerTest::test_assert_that, a failingassert_thatraised on a worker thread was only surfaced as aPytestUnhandledThreadExceptionWarning, so the test could pass intermittently.What this change does
threading.excepthookduring the test run.beam.Pipeline.run(...).wait_until_finish()so that any captured worker-thread exception is rethrown on the main thread at the end of the run.test_assert_thatto use this shim and assert the expected failure viaassertRaisesRegex, turning the flaky pass into a deterministic failure for the negative case.Why
Ensures the failure path for
assert_thatis exercised reliably and reported as a proper test failure, rather than a warning emitted from a background thread.Verification
Stress run x200 (no flakes):
Result:
200/200passes; no thread-exception warnings.