Repository navigation
ci(tests): Add an outbound network guard in report mode on master - #131165
Draft
sentry-junior[bot] wants to merge 1 commit into
Draft
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
Re-lands the network guard plugin from #127944 on current master. It records tests that reach hosts outside the CI runner. CI runs it in report mode on master pushes and manual runs only, uploads the JSON report, and writes new offenders to the job summary. Nothing fails. tests/network_guard_known_offenders.txt lists tests that still reach the network, so the report separates them from new ones and a later strict mode can exempt them per test. Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This re-lands the network guard from #127944 on current master, in a mode that can't break anything. #127945, #127946, #127947, getsentry/getsentry#22583 and getsentry/getsentry#22585 fixed what it found last time. Without a guard, real network calls in tests will creep back in.
Merge order: this PR first, then getsentry/getsentry#23239, which turns the guard on for getsentry.
What it does
sentry.testutils.pytest.network_guardis the same plugin as in #127944. It patches the Python socket connect and resolver entry points and records each attempt to reach a host outside the runner, per test, with the target and a short origin stack. xdist workers send their records to the controller. The allowlist (loopback, the unspecified address, the local hostname, the live server bridge IP, the reporting DSN hosts), the low-overhead design, and the native-client gap (libpq, librdkafka, grpc core) are unchanged. #127944 has the measurements.Changes from #127944:
backend.ymlsetsreporton master pushes and manual runs only. Pull requests run with the guard off and pay nothing.network-guard-<run>-<shard>, and the upload step iscontinue-on-error.tests/network_guard_known_offenders.txt(relative to the pytest rootdir) takes test files, classes, or test nodeids. Their attempts are still recorded but listed separately, andstrictmode doesn't block them, so strict can be turned on with the remaining debt exempted per test. The summary also lists entries that ran clean, so the file shrinks as tests get fixed. It starts empty.Offenders on master today
20 tests in 9 files reach 8 hostnames. None of them are known offenders yet.
slack.com: 9test_on_agent_update_*tests intests/sentry/seer/entrypoints/slack/test_slack.py. These make real HTTPS connections throughslack_sdk.api.github.comandcontrolserver: 6 tests intests/sentry/tasks/test_post_process.py(4),tests/sentry/tasks/test_commit_context.pyandtests/sentry/issues/auto_source_code_config/test_process_event.py. These are lookups only, fromsafe_create_connectionandget_control_silo_ip_address.example.com,new.comandother.com: 3 tests intests/sentry/sentry_apps/api/endpoints/test_project_legacy_webhooks.py.is_safe_hostnamelooks these up while validating webhook URLs.abc: 1 test intests/sentry/integrations/perforce/test_integration.py, a lookup fromis_safe_hostname.testserver: 1 test intests/sentry/middleware/test_notification_tracking.py, a lookup fromproxy_cell_request.Open decisions
strict. Proposal: after a week or two of master runs with no new offenders. Also whether pull requests should run it then, since the guard has no measurable cost.via @joshuarli.
--
View Session [Sentry]