Skip to content

Remove forked from test_transport, separate gevent tests and generalize capturing_server to be module level #4577

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

Merged
merged 1 commit into from
Jul 17, 2025

Conversation

sl0thentr0py
Copy link
Member

@sl0thentr0py sl0thentr0py commented Jul 11, 2025

  • Move CapturingServer to conftest for reuse
  • Make capturing_server in original non-forked transport tests to be module level for faster tests
  • Move gevent based transport tests to separate file since they still need to be forked because of the global monkeypatch

As a result, test_transport now takes 13 seconds instead of almost 3 minutes.

BEFORE

 235 passed, 384 skipped in 173.78s (0:02:53)

AFTER

235 passed in 12.69s 

part of #4538

@sl0thentr0py sl0thentr0py requested a review from a team as a code owner July 11, 2025 12:22
@sl0thentr0py sl0thentr0py force-pushed the neel/forked/transport branch from 6dddfe7 to b4977f6 Compare July 11, 2025 12:23
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.72%. Comparing base (2ccab61) to head (6d65e0d).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4577      +/-   ##
==========================================
+ Coverage   80.71%   80.72%   +0.01%     
==========================================
  Files         156      156              
  Lines       16507    16507              
  Branches     2806     2806              
==========================================
+ Hits        13323    13325       +2     
+ Misses       2300     2295       -5     
- Partials      884      887       +3     

see 8 files with indirect coverage changes

@sl0thentr0py sl0thentr0py force-pushed the neel/forked/transport branch 4 times, most recently from 5e916da to 65f431b Compare July 15, 2025 14:53
@sl0thentr0py sl0thentr0py changed the title Remove forked from test_transport and generalize capturing_server to be module level Remove forked from test_transport, separate gevent tests and generalize capturing_server to be module level Jul 15, 2025
@sl0thentr0py sl0thentr0py force-pushed the neel/forked/transport branch from 65f431b to 9876504 Compare July 15, 2025 14:57
Copy link
Member Author

@sl0thentr0py sl0thentr0py Jul 15, 2025

Choose a reason for hiding this comment

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

ultimately, I want to isolate all gevent tests here so they don't leak into the rest of the codebase

@sl0thentr0py sl0thentr0py force-pushed the neel/forked/transport branch from 9876504 to 5c1da2f Compare July 15, 2025 14:59
@sl0thentr0py sl0thentr0py force-pushed the neel/forked/transport branch from 5c1da2f to 6d65e0d Compare July 15, 2025 15:03
@sl0thentr0py
Copy link
Member Author

sl0thentr0py commented Jul 15, 2025

as a side, I also really tried to make the gevent test not forked, but the shutdown in pytest-localserver doesn't seem to be compatible with gevent and throws ... we can revisit this later once all gevent stuff is isolated

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

😍

@sl0thentr0py sl0thentr0py merged commit 9b66f3b into master Jul 17, 2025
137 checks passed
@sl0thentr0py sl0thentr0py deleted the neel/forked/transport branch July 17, 2025 11:53
sl0thentr0py added a commit that referenced this pull request Jul 17, 2025
The changes in #4577 introduced a bit of flakiness on pre-3.10 due to a
weird interaction of `capsys`, `stderr` logging and our object
lifecycles.

In this PR, I'm removing all the explicit `__del__` `kill`s since we
[call them all explicitly in
`client.close`](https://github.com/getsentry/sentry-python/blob/09c2e32cc7a618e49f5d8ae59e22d8b12f253687/sentry_sdk/client.py#L1001-L1021)
anyway and that's already cleaner. Having logic in `__del__` causes
non-deterministic GC behavior, especially with threaded code.

Stacktrace is linked in a comment below where you can see the
`transport.__del__` method is causing the weird `reentrant` logging bug
to `stderr`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants