[GSoC-273] Feat: Integrate TestPubsubContext to prevent Pub/Sub resource leaks and expand stale cleaner scope - #39826
Conversation
…yond just creating Pub/Sub resources, and preventing resource leaks in the GCP environment. - Deletion redundancy was increased by adding subscription prefixes to `stale_clener.py` that might have remained active had `TestPubSubManager` failed.
|
Assigning reviewers: R: @claudevdm 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). |
…ache-beam-testing tests
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #39826 +/- ##
============================================
+ Coverage 57.10% 57.19% +0.08%
Complexity 3643 3643
============================================
Files 1191 1193 +2
Lines 192542 192979 +437
Branches 3816 3816
============================================
+ Hits 109957 110378 +421
- Misses 79027 79043 +16
Partials 3558 3558
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:
|
|
lgtm |
|
It breaks Python PostCommit: https://github.com/apache/beam/runs/97127657945
E AttributeError: 'PubSubIntegrationTest' object has no attribute 'pubsub_monitor_register_topic' |
|
|
||
| During the execution of the main integration test suite, the standard cleanup mechanism proved insufficient when tests failed or were abruptly aborted. | ||
|
|
||
| ### **Critical findings:** |
There was a problem hiding this comment.
This dairy like log doesn't belong to Beam repo
|
Hi Yi!
thanks for the feedback. I figured it might be useful to keep a record of
the investigation done to make this change. Do you now think that's
reasonable to keep?
…On Sat, Aug 22, 2026 at 7:47 PM Yi Hu ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In sdks/python/apache_beam/testing/README.md
<#39826 (comment)>:
> + total_leaks += 1
+ print(f"{sub_name:<70} | ACTIVE (ORPHAN)")
+
+ print("-" * 90)
+ print(f"Diagnosis: Detected {total_leaks} active orphan 'resource_sub' subscriptions in GCP.")
+
+if __name__ == "__main__":
+ audit_wordcount_subscriptions("apache-beam-testing")
+
+```
+
+## Evidence: Leaks in Pub/Sub Integration Tests (`psit_`)
+
+During the execution of the main integration test suite, the standard cleanup mechanism proved insufficient when tests failed or were abruptly aborted.
+
+### **Critical findings:**
This dairy like log doesn't belong to Beam repo
—
Reply to this email directly, view it on GitHub
<#39826?email_source=notifications&email_token=AAJ5Z3HAIOSBNEMWFPUWMTD5LJLMHA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKMBQGE2TEOBUGQ2KM4TFMFZW63VMON2GC5DFL5RWQYLOM5S2KZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#pullrequestreview-5001528444>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ5Z3FYVDY2SK7D3K3WQZT5LJLMHAVCNFSNUABEKJSXA33TNF2G64TZHM2TAOJQGQZDINJ3JFZXG5LFHM2TCOJZGQ4TOOJYGSQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AAJ5Z3EI2OWMWPVDASME6WD5LJLMHA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKMBQGE2TEOBUGQ2KM4TFMFZW63VMON2GC5DFL5RWQYLOM5S2KZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AAJ5Z3CJJS4DSULDB4CWV3D5LJLMHA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKMBQGE2TEOBUGQ2KM4TFMFZW63VMON2GC5DFL5RWQYLOM5S2KZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
I'm not sure, at least not in Beam Python SDK, which is packaged and released to users. For generic infra doc https://github.com/apache/beam/blob/master/.test-infra/tools/README.md may be a good entry point |
|
good point. I'll ask Hansel to remove.
…On Thu, Aug 27, 2026 at 3:06 PM Yi Hu ***@***.***> wrote:
*Abacn* left a comment (apache/beam#39826)
<#39826 (comment)>
Hi Yi! thanks for the feedback. I figured it might be useful to keep a
record of the investigation done to make this change. Do you now think
that's reasonable to keep?
I'm not sure, at least not in Beam Python SDK, which is packaged and
released to users. For generic infra doc
https://github.com/apache/beam/blob/master/.test-infra/tools/README.md
may be a good entry point
—
Reply to this email directly, view it on GitHub
<#39826?email_source=notifications&email_token=AAJ5Z3EZCCLYUN4K7TI2IUT5MCWH3A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBUGU3TOOBRGI42M4TFMFZW63VMON2GC5DFL5RWQYLOM5S2KZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5445778129>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ5Z3HU3J52GCTHEJ5VVYD5MCWH3AVCNFSNUABEKJSXA33TNF2G64TZHM2TAOJQGQZDINJ3JFZXG5LFHM2TCOJZGQ4TOOJYGSQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AAJ5Z3HXKI7PIQBH3OJN6V35MCWH3A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBUGU3TOOBRGI42M4TFMFZW63VMON2GC5DFL5RWQYLOM5S2KZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AAJ5Z3EG3M4QDBW4LZHOEZD5MCWH3A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBUGU3TOOBRGI42M4TFMFZW63VMON2GC5DFL5RWQYLOM5S2KZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Overview
This pull request improves the lifecycle management of Pub/Sub resources in our integration tests to actively reduce GCP consumption. It replaces manual teardown methods with the robust TestPubsubContext manager and expands the automated garbage collector's scope to catch previously untracked test prefixes.
Key Changes
pubsub_integration_test.py,streaming_wordcount_it_test.py,streaming_wordcount_debugging_it_test.py):test_utils.cleanup_subscriptionsandtest_utils.cleanup_topics) with the TestPubsubContext monitor..test-infra/tools/stale_cleaner.py):wc_topic_*,psit_*,leader_board_*).