Repository navigation
[YAML] Clean up BigQuery datasets when fixtures fail - #40863
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40863 +/- ##
===========================================
+ Coverage 0 80.08% +80.08%
===========================================
Files 0 494 +494
Lines 0 83582 +83582
===========================================
+ Hits 0 66937 +66937
- Misses 0 16645 +16645
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6ada839 to
f0f3cea
Compare
There was a problem hiding this comment.
📋 Review Summary
This PR properly wraps the optional table setup and yield in temp_bigquery_table with a try...finally block so that temporary BigQuery datasets are always deleted even when table creation fails, a subsequent fixture fails during ExitStack setup, or the pipeline execution fails. It also adds targeted unit tests in integration_tests_test.py covering both failure modes.
🔍 General Feedback
- Other fixtures in
integration_tests.py: Similar totemp_bigquery_table,gcs_temp_dir(lines 89–105) andtemp_bigtable_table(lines 318–357) perform resource cleanup afteryieldwithout atry...finallyblock. Consider wrapping those intry...finallyas well (or in a follow-up) so all YAML test fixtures clean up reliably on failure. - Import-time side effects in
integration_tests.py: Importingapache_beam.yaml.integration_testsinsideintegration_tests_test.py(which matches*_test.pyfor standard unit test discovery) triggers top-level execution ofparse_test_files(...)at the bottom ofintegration_tests.py, parsing all YAML specs intests/*.yamland mutating the root logger level during unit test collection.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @derrickaw for label yaml. 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). |
derrickaw
left a comment
There was a problem hiding this comment.
Fix the gemini comment. LGTM for rest.
YAML integration fixtures use
ExitStack. If a later fixture fails during setup, the exception reaches the BigQuery fixture atyieldand skips its dataset deletion. In this run, datasets were created before Bigtable setup failed, and their cleanup was never reached.Move dataset cleanup into
finallyafter creation, covering both optional table setup and errors from the test or another fixture. The fixture now calls deletion as the stack unwinds, using the existing request to delete the dataset and its contents.Focused regression cases failed against the original helper because deletion was never called, then passed with the fix. They use the real Beam and BigQuery API modules with mocked cloud clients. Formatting and lint checks passed, including a check that missing optional dependencies skip the tests. No live cloud resources were used.