Skip to content

Migrate linkerd + istio v1 tests off requests_mock#23648

Open
mwdd146980 wants to merge 1 commit intoDataDog:mwdd146980/httpx-migration-basefrom
mwdd146980:mwdd146980/step6-linkerd-istio-requests-mock
Open

Migrate linkerd + istio v1 tests off requests_mock#23648
mwdd146980 wants to merge 1 commit intoDataDog:mwdd146980/httpx-migration-basefrom
mwdd146980:mwdd146980/step6-linkerd-istio-requests-mock

Conversation

@mwdd146980
Copy link
Copy Markdown
Contributor

Motivation

Step 6 PR 6.1 of the httpx test-decoupling migration. Two integrations still mock at the requests layer via requests_mock.Mocker(), which couples test mocks to the underlying HTTP library and blocks the eventual requestshttpx swap.

Plan: https://datadoghq.atlassian.net/wiki/spaces/AI/pages/6692406054

Approach

Replace requests_mock.Mocker() with mock_openmetrics_http (the OpenMetrics v1 mixin fixture that patches OpenMetricsScraperMixin.get_http_handler) and MockHTTPResponse. v2 tests already use mock_http_response and are unchanged.

Pattern A (text response):

def test_X(aggregator, dd_run_check, mock_openmetrics_http):
    mock_openmetrics_http.get.return_value = MockHTTPResponse(
        content=get_response(...), headers={'Content-Type': 'text/plain'},
    )
    ...

Pattern B (exception): set mock_openmetrics_http.get.side_effect.

7 tests across 2 files: linkerd/tests/test_linkerd.py (3 v1 tests), istio/tests/test_unit_istio_v1.py (4 tests).

Verification

  • ddev test -fs linkerd istio — clean.
  • ddev --no-interactive test linkerd — 4 passed, 1 e2e skipped.
  • ddev --no-interactive test istio — 24 passed, 2 e2e skipped.

Stacked on mwdd146980/httpx-migration-base.

@mwdd146980 mwdd146980 requested a review from a team as a code owner May 8, 2026 20:16
@mwdd146980 mwdd146980 marked this pull request as draft May 8, 2026 20:17
@mwdd146980 mwdd146980 self-assigned this May 8, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce89c1420f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread istio/tests/test_unit_istio_v1.py
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.12%. Comparing base (20e464b) to head (ce89c14).

❗ There is a different number of reports uploaded between BASE (20e464b) and HEAD (ce89c14). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (20e464b) HEAD (ce89c14)
2 1
Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mwdd146980 mwdd146980 marked this pull request as ready for review May 8, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant