Repository navigation
Commit 18fb2b2
fix(tests): Stop test_global_config from leaking option overrides (#128459)
Fixes intermittent master failures of
`tests/relay_integration/test_integration.py::SentryRemoteTest::test_standalone_attachment`
(`assert None` in `post_and_retrieve_attachment`), e.g.
https://github.com/getsentry/sentry/actions/runs/39675570221.
**Cause**
`test_global_config` in
`tests/sentry/api/endpoints/test_relay_globalconfig_v3.py` uses the
`@override_options` decorator together with pytest-django's `settings`
fixture (added in #127378). The decorator's
`override_settings(SENTRY_OPTIONS=...)` exits before the fixture's
override is torn down. The fixture then restores the decorator's
settings holder, so the overridden `SENTRY_OPTIONS` stay in place for
every later test on that worker. After running it,
`options.get("relay.objectstore-attachments.sample-rate")` returns `1.0`
in an unrelated test instead of `0.0`, and the same goes for
`relay.attachment-inline.limit` and `relay.upload-max-chunk.size`. These
values reach the test Relay through the global config.
The leak has existed since Oct 15. It started failing on master after
#128359 added test files, which changed the shard plan. Part 0 of the
split `test_integration.py` moved from shard 14 to shard 10, which also
runs `test_relay_globalconfig_v3.py`. It fails only when xdist
`--dist=loadfile` puts both files on the same worker, which is why it
fails on some runs and not others. All 5 reruns fail because the leaked
state stays for the life of the worker.
**Fix**
Nest `override_settings` inside the test body so the two overrides
unwind in order. The test change is the only change.
**Verification** (local, `-n0`, Kafka/Snuba/Relay via devservices)
- `pytest test_relay_globalconfig_v3.py
test_integration.py::SentryRemoteTest::test_standalone_attachment`:
parent commit fails 1 of 10, fixed commit passes 10 of 10 (run twice)
- `test_standalone_attachment` alone passes on the parent commit
- `prek` is clean on the changed file
<!-- junior-request-attribution:start -->
via **dan**.
<!-- junior-request-attribution:end -->
<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3ACUHS29QJ0%3A1792617789.618129 -->
--
[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3ACUHS29QJ0%3A1792617789.618129)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3ACUHS29QJ0%3A1792617789.618129/?project=4510944073809921)
<!-- junior-session-footer:end -->
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Dan Fuller <dfuller@sentry.io>1 parent d34b312 commit 18fb2b2
1 file changed
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
| |||
0 commit comments