Skip to content

test(relay): Assert rejection outcomes instead of waiting out ingestion - #131170

Merged
joshuarli merged 2 commits into
masterfrom
ci/relay-rejection-outcomes-v2
Nov 18, 2026
Merged

joshuarli merged 2 commits into
masterfrom
ci/relay-rejection-outcomes-v2

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Supersedes #129071. Builds on the outcome-capture idea from #128956, rebased onto current master.

post_and_try_retrieve_event swallowed the AssertionError from the success path. That made every expected Relay rejection wait out the 16s ingest timeout, and let unrelated failures pass as rejections.

post_and_assert_rejected replaces it. It reads the per-worker outcomes topic from the high watermarks captured before the POST, then waits for the outcome Relay emits for the project's org/project/key. It asserts that outcome's type and reason. Relay aggregates outcomes and drops event IDs, so the match uses org/project/key. That's unambiguous because project IDs are snowflakes and each case posts once.

via @joshuarli.

--

View Session [Sentry]

Negative Relay integration tests caught the AssertionError from the
successful-ingestion helper, so every expected rejection waited the full
16s ingest timeout and any unrelated assertion also counted as a rejection.

Read the per-worker outcomes topic from its current high watermarks and
wait for the error outcome Relay emits for the test's org, project, and key,
then assert its outcome type, reason, and quantity.

Co-Authored-By: Joshua Li <[email protected]>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 14, 2026
@sentry-junior sentry-junior Bot added the Trigger: Override Selective Testing Run the full test suite; necessary in cases where selected tests are flaky due to reshuffling label Nov 14, 2026
@sentry-junior

sentry-junior Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Per-file durations from the full backend run on this PR (run 43539688316, Trigger: Override Selective Testing), compared with the three latest green master runs (43535410847, 43533907107, 43532740801). Each value is the sum of setup, call, and teardown from the backend-test-durations-* artifacts.

file master (3 runs) master median this PR
test_integration.py 144.5 / 145.5 / 135.4 144.5 52.0
test_message_filters.py 99.4 / 101.3 / 100.6 100.6 36.3
test_sdk.py (unchanged) 64.8 / 52.4 / 56.9 56.9 43.9
lang/java/test_plugin.py (unchanged) 201.6 / 171.9 / 189.8 189.8 122.5
lang/javascript/test_plugin.py (unchanged) 185.7 / 178.2 / 171.2 178.2 138.8
lang/javascript/test_example.py (unchanged) 11.6 / 13.7 / 11.0 11.6 10.8

Caveat: the runners on this run were faster than usual. Summed over every file, the whole suite took 14,947s here against 18,481 to 19,525s on master, about 0.78x. That explains the drop in the untouched files. After scaling the master medians by 0.78, the change itself saves about 61s in test_integration.py (113 → 52) and about 42s in test_message_filters.py (79 → 36). That matches nine negative cases going from ~16s to ~2.5s.

Locally, against devservices and the real Relay container, running test_message_filters.py and test_integration.py serially took 209.6s on master and 70.4s on this branch. Both files also pass under -n2 --dist=loadfile. Two deliberate breakages both failed: a wrong expected reason, and a filter turned off for an expected rejection (that one failed with "no error outcome", not a pass).

@linear-code

linear-code Bot commented Nov 14, 2026

Copy link
Copy Markdown

DI-2853

@joshuarli joshuarli removed the Trigger: Override Selective Testing Run the full test suite; necessary in cases where selected tests are flaky due to reshuffling label Nov 18, 2026
@joshuarli
joshuarli marked this pull request as ready for review November 18, 2026 18:19
@joshuarli
joshuarli requested review from a team as code owners November 18, 2026 18:19
@sentry-junior
sentry-junior Bot requested a review from joshuarli November 18, 2026 18:19
Add unit tests for post_and_assert_rejected and the outcomes capture: a
wrong outcome, reason, or quantity fails, a missing outcome fails, outcomes
for another org, project, key, or category are ignored, and the capture
skips messages produced before it started.

Relay aggregates outcomes without event IDs, so the helper can only match by
org, project, and key. Document that, and fail a second rejection for the
same key in one test instead of letting it pick up a late outcome.

Co-Authored-By: Joshua Li <[email protected]>
@sentry-junior sentry-junior Bot added the Trigger: Override Selective Testing Run the full test suite; necessary in cases where selected tests are flaky due to reshuffling label Nov 18, 2026
@joshuarli
joshuarli merged commit 60413c5 into master Nov 18, 2026
105 of 125 checks passed
@joshuarli
joshuarli deleted the ci/relay-rejection-outcomes-v2 branch November 18, 2026 18:41
joshuarli added a commit that referenced this pull request Nov 24, 2026
…132105)

Refreshes `.github/workflows/scripts/backend-test-durations.json` from
recent master runs, following #129569.

**Source data:** the per-file median of the `backend-test-durations-*`
artifacts from three green full-suite master `backend.yml` runs:
[45447921880](https://github.com/getsentry/sentry/actions/runs/45447921880),
[45445395411](https://github.com/getsentry/sentry/actions/runs/45445395411)
and
[45442363055](https://github.com/getsentry/sentry/actions/runs/45442363055)
(master `712e106928c` through `6a3df08320e`). All three ran 30 shards
with 4 workers on `ubuntu-26.04`. The file is the unedited output of the
`merge` then `median` commands in the `backend-test-durations.py`
docstring.

**What changed vs master** (last resync: #131174)
- **25 test files added, 6 removed** (the drift trigger). The added
files are all under 11s, the largest being
`integrations/supabase/test_integration.py` (10.1s) and
`integrations/supabase/test_client.py` (9.3s). The removed files, such
as the three `api/endpoints/release_thresholds/*` tests, no longer exist
on master.
- **`seconds_per_test`:** 0.400 → 0.451 (+12.7%), the other drift
trigger.
- **Files in both versions:** total time +12.9% (19,640s → 22,178s).
Four files moved by more than 25% and 30s:
- `tests/sentry/seer/endpoints/test_organization_agent_token.py` 493.8s
→ 748.5s, +52% (runs: 748.5 / 761.8 / 657.2). This crosses the
regression bar. Recent commits touching it include
#129239, #131473 and
#131113.
- `tests/snuba/api/endpoints/test_organization_events_span_indexed.py`
208.8s → 262.2s (+26%)
- `tests/relay_integration/test_integration.py` 136.7s → 65.3s and
`tests/relay_integration/test_message_filters.py` 111.3s → 49.2s. Both
drops line up with #131170.

**Acceptance durations aren't refreshed here.**
`acceptance-test-durations.json` (#132407) gets
refreshed from the median of 3 full master `acceptance.yml` runs that
upload `acceptance-test-durations-*`. No such run has finished yet, so
the coverage-instrumented seed stays in place. The weekly resync
replaces it once three exist.

**Not changed:** `WORKER_SECONDS_PER_SHARD` and `TESTS_PER_SHARD`.
Shared files shifted +12.9%, under the 15% bar for retuning the budget.

Opened by the weekly backend test durations resync.

<!-- junior-request-attribution:start -->
via [automation
`sched_24013c871420a6cbab8d518dae1de4ae`](https://junior-prod.sentry.dev/automations/sched_24013c871420a6cbab8d518dae1de4ae)
· Run ID `sched_24013c871420a6cbab8d518dae1de4ae:1795248000000`,
@joshuarli.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!--
junior-conversation-id:agent-dispatch%3Adispatch_6819e6c570f111d16716e7c099e1d6bc
-->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent-dispatch%3Adispatch_6819e6c570f111d16716e7c099e1d6bc)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent-dispatch%3Adispatch_6819e6c570f111d16716e7c099e1d6bc/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Joshua Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Trigger: Override Selective Testing Run the full test suite; necessary in cases where selected tests are flaky due to reshuffling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant