Migrate kube_apiserver_metrics, kube_dns, kube_metrics_server, kube_proxy tests to mock_openmetrics_http#23781
Conversation
Migrate kube_apiserver_metrics, kube_dns, kube_metrics_server, and kube_proxy off requests.Session.get patches to mock_openmetrics_http + MockHTTPResponse. Test-only changes, no production code touched. Adds shared make_mock_metrics helpers in each integration's tests/common.py and opt-in mock_healthcheck_wrapper fixtures in kube_dns, kube_metrics_server, kube_proxy conftests to neutralize _healthcheck_http_handler's separate RequestsWrapper instances. Replaces test_service_check_ok in three integrations with a parametrized test_service_check that exercises both the OK branch and the requests.HTTPError branch against the production except requests.exceptions.RequestException handler.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
… into mwdd146980/step6-kube-small-batch
Validation ReportAll 21 validations passed. Show details
|
f14a5ce
into
mwdd146980/httpx-migration-base
Motivation
Migrates the
kube_apiserver_metrics,kube_dns,kube_metrics_server, andkube_proxytest suites offmock.patch('requests.Session.get', ...)tomock_openmetrics_http. Removingrequests-library-level patches is a precondition for the upcoming httpx swap. Test-only, no production changes.Approach
make_mock_metricshelper in each integration'stests/common.py.mock_healthcheck_wrapperfixture in kube_dns, kube_metrics_server, and kube_proxy conftests. These three checks build a separateRequestsWrapperinside_healthcheck_http_handler, outsideself.http, somock_openmetrics_httpdoes not cover the healthcheck path. The fixture patches the integration-localRequestsWrappersymbol. kube_apiserver_metrics has no healthcheck path and does not need it.test_service_checkraisesrequests.HTTPErrordirectly to exercise the liveexcept requests.exceptions.RequestExceptionbranch.tests/__init__.pyso the newtests/common.pyis importable.Verification
ddev test -fsclean andddev --no-interactive testgreen for all four integrations (32 tests pass).Review checklist (to be filled by reviewers)
qa/skip-qalabel if the PR doesn't need to be tested during QA.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged