Skip to content

[YAML] Clean up BigQuery datasets when fixtures fail - #40863

Merged
derrickaw merged 2 commits into
apache:masterfrom
bvolpato:bvolpato/cleanup-yaml-bigquery-datasets
Oct 30, 2026
Merged

derrickaw merged 2 commits into
apache:masterfrom
bvolpato:bvolpato/cleanup-yaml-bigquery-datasets

Conversation

@bvolpato

Copy link
Copy Markdown
Contributor

YAML integration fixtures use ExitStack. If a later fixture fails during setup, the exception reaches the BigQuery fixture at yield and skips its dataset deletion. In this run, datasets were created before Bigtable setup failed, and their cleanup was never reached.

Move dataset cleanup into finally after 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.

@github-actions github-actions Bot added python yaml size/m M: 50-249 lines changed labels Oct 28, 2026
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.11111% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.08%. Comparing base (0f1ac43) to head (2bb7f36).
⚠️ Report is 36 commits behind head on master.

Files with missing lines Patch % Lines
sdks/python/apache_beam/yaml/integration_tests.py 61.11% 7 Missing ⚠️
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     
Flag Coverage Δ
python 80.08% <61.11%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bvolpato
bvolpato force-pushed the bvolpato/cleanup-yaml-bigquery-datasets branch from 6ada839 to f0f3cea Compare October 28, 2026 23:57
@bvolpato
bvolpato marked this pull request as ready for review October 30, 2026 02:46

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 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 to temp_bigquery_table, gcs_temp_dir (lines 89–105) and temp_bigtable_table (lines 318–357) perform resource cleanup after yield without a try...finally block. Consider wrapping those in try...finally as well (or in a follow-up) so all YAML test fixtures clean up reliably on failure.
  • Import-time side effects in integration_tests.py: Importing apache_beam.yaml.integration_tests inside integration_tests_test.py (which matches *_test.py for standard unit test discovery) triggers top-level execution of parse_test_files(...) at the bottom of integration_tests.py, parsing all YAML specs in tests/*.yaml and mutating the root logger level during unit test collection.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @derrickaw for label yaml.
Backup reviewer: chamikaramj (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@derrickaw derrickaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the gemini comment. LGTM for rest.

@derrickaw
derrickaw merged commit f831ff1 into apache:master Oct 30, 2026
86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants