Skip to content

test: Add network envelope snapshot tests - #8638

Merged
philprime merged 7 commits into
mainfrom
philprime/e2e-network-tests
Aug 3, 2026
Merged

test: Add network envelope snapshot tests#8638
philprime merged 7 commits into
mainfrom
philprime/e2e-network-tests

Conversation

@philprime

@philprime philprime commented Jul 31, 2026

Copy link
Copy Markdown
Member

Add committed fixture comparisons for envelopes produced by network instrumentation. The server-backed integration suite captures a successful-request transaction envelope and an HTTP 400 failed-request event envelope through the production transport adapter.

The tests round-trip captured envelopes through the SDK serializer and deserializer, then assert the stable fixture fields recursively. Placeholder values accept runtime-generated data such as IDs, timestamps, machine context, and stack traces. Concrete network request data, response context, spans, exception details, SDK metadata, envelope headers, and item headers remain comparison-sensitive.

This addresses the outstanding full-envelope validation discussed in #8502. Existing networking integration tests assert selected fields but do not detect regressions elsewhere in the payload.

Validated with formatting, static analysis, an iOS build, and the complete five-test Sentry_TestServer plan.

#skip-changelog

Closes #8648

Capture complete normalized transaction and failed-request envelopes from the server-backed networking integration suite.
@philprime philprime self-assigned this Jul 31, 2026
@philprime philprime added the run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request label Jul 31, 2026
Use the SDK serializer and deserializer with partial fixture assertions. Remove baseline regeneration and standalone tests for test-only normalization logic.
Account for macOS and SDK V10 payload differences, and filter captured envelopes by item type to avoid unrelated telemetry.
Comment thread Tests/Resources/NetworkEnvelopeBaselines/failed-request-event.json Outdated
Comment thread Tests/Resources/NetworkEnvelopeSnapshots/failed-request-event.json
Use placeholders for SDK and locale-dependent values, and allow repeated expectation fulfillment from task cancellation or matching envelopes.

@philipphofmann philipphofmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding this 😃, LGTM 🚀

Comment thread Tests/SentryTests/Integrations/Performance/Network/NetworkEnvelopeBaseline.swift Outdated
Comment thread Tests/SentryTests/Integrations/Performance/Network/NetworkEnvelopeBaseline.swift Outdated
@github-actions github-actions Bot added approved and removed approved labels Aug 3, 2026
Address review feedback on the network envelope tests.

Rename the helper and fixtures to snapshot terminology, since
that is the established name for this testing concept.

Compare snapshots strictly in both directions. Recursing over
the fixture keys alone never visited keys that only exist in
the envelope, so additive regressions passed silently. This
immediately surfaced four uncovered keys: sdk.features,
sdk.integrations, payload.extra and payload.tags.

Aggregate all mismatches into one failure that lists every
difference and prints the actual envelope JSON, so it is clear
both what changed and how to update the snapshot.

Replace clearTestState with SentrySDK.close, which uninstalls
the integrations and thereby disables the network tracker.

Also serve the test server on port 8081 in the make targets.
The tests and scripts/start-test-server.sh use 8081, but the
targets bound the default 8080, so they could not serve them.
@philprime
philprime enabled auto-merge (squash) August 3, 2026 15:04

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2c06824. Configure here.

Comment thread Tests/Resources/NetworkEnvelopeSnapshots/failed-request-event.json
@sentry

sentry Bot commented Aug 3, 2026

Copy link
Copy Markdown

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.24.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

Bugbot was right: the strict comparison failed on V10 because
failed-request capture assigns cookies to the request and to
contexts.response, and both were absent from the snapshot.

Give V10 its own -v10 snapshot per envelope instead of carving
exceptions into the comparison. Both variants are then compared
just as strictly, and the V10 deltas are visible in one file:
cookies, infer_ip=auto, and no device.locale.

This removes the SDK_V10 special cases for infer_ip and
device.locale, leaving a single conditional for file selection.

Add TEST_PLAN to the macOS test targets, which could not run
the test-server plan at all before.
Comment thread Makefile
@philprime philprime changed the title test: Add network envelope baselines test: Add network envelope snapshot tests Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1226.28 ms 1252.16 ms 25.88 ms
Size 24.14 KiB 1.26 MiB 1.23 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
a8fc1c8 1237.62 ms 1261.57 ms 23.95 ms
07d6099 1224.06 ms 1247.13 ms 23.06 ms
6ae3681 1226.09 ms 1257.47 ms 31.38 ms
871ce4d 1223.43 ms 1257.17 ms 33.75 ms
7087caa 1212.33 ms 1261.69 ms 49.36 ms
d5bcdd8 1224.61 ms 1252.73 ms 28.13 ms
66cfde1 1226.84 ms 1255.50 ms 28.66 ms
b927860 1213.67 ms 1257.94 ms 44.27 ms
821fd52 1225.70 ms 1256.73 ms 31.03 ms
f82ca9b 1227.06 ms 1264.67 ms 37.61 ms

App size

Revision Plain With Sentry Diff
a8fc1c8 24.14 KiB 1.23 MiB 1.20 MiB
07d6099 24.14 KiB 1.17 MiB 1.15 MiB
6ae3681 24.14 KiB 1.19 MiB 1.17 MiB
871ce4d 24.14 KiB 1.22 MiB 1.20 MiB
7087caa 24.14 KiB 1.17 MiB 1.15 MiB
d5bcdd8 24.14 KiB 1.22 MiB 1.20 MiB
66cfde1 24.14 KiB 1.20 MiB 1.17 MiB
b927860 24.14 KiB 1.19 MiB 1.17 MiB
821fd52 24.14 KiB 1.26 MiB 1.23 MiB
f82ca9b 24.14 KiB 1.17 MiB 1.14 MiB

@philprime
philprime merged commit 586d4e0 into main Aug 3, 2026
270 checks passed
@philprime
philprime deleted the philprime/e2e-network-tests branch August 3, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: Add network envelope baselines

2 participants