Skip to content

Move 36 check test suites onto the agnostic HTTP doubles - #24831

Draft
mwdd146980 wants to merge 1 commit into
mwdd146980/http-agnostic-base-devfrom
mwdd146980/http-agnostic-test-decoupling
Draft

Move 36 check test suites onto the agnostic HTTP doubles#24831
mwdd146980 wants to merge 1 commit into
mwdd146980/http-agnostic-base-devfrom
mwdd146980/http-agnostic-test-decoupling

Conversation

@mwdd146980

Copy link
Copy Markdown
Contributor

What does this PR do?

Moves 36 check test suites off the requests library and onto the library-agnostic HTTP test doubles that #24815 adds to datadog_checks_dev.

The suites patched requests.Session and built requests.Response objects, so they were written against the HTTP library rather than against the client contract. They now read through the sealed doubles instead:

  • mock_http replaces 66 requests.Session patches.
  • mock_openmetrics_http and mock_prometheus_http cover the OpenMetrics and Prometheus scrapers, 59 call sites.
  • MockHTTPResponse replaces the requests-based MockResponse, 44 call sites.
  • nginx, riak, and azure_iot_edge assert on the agnostic exception types rather than on requests.exceptions.

No check source changes, so no changelog entry and no base-package floor bump.

Harness HTTP stays on requests. The calls in haproxy's dd_environment stand up the test environment rather than intercepting the check, so they cannot break on a backend change.

Motivation

This continues confining requests to the base check. Once a suite reads through the doubles it depends on the client contract rather than on the backend, which is what makes the backend replaceable without touching every test.

Known failure: minimum-base-package

The test-minimum-base-package jobs fail on this PR, and will keep failing until datadog-checks-base 38.1.0 is published. Those jobs run ddev test --compat, which installs each integration's declared floor of >=37.33.0. The doubles and the agnostic exception modules exist only from 38.1.0 onward, so the conftests cannot import them. Reproduced locally:

$ ddev test --compat apache
+ datadog-checks-base==37.33.0
ImportError: cannot import name 'create_http_client' from 'datadog_checks.base.utils.http'

Note that #24815 does not surface this. A PR touching datadog_checks_base/datadog_checks/ or datadog_checks_dev/datadog_checks/dev/*.py matches SKIPPED_PATTERN in ci_matrix.py and is routed to the PR All workflow, which carries no minimum-base-package job. This PR touches only test files, so it gets the standard matrix and the jobs expand.

Resolving it needs a floor bump to >=38.1.0 across the 36 integrations, which can only land once that version is on PyPI. It is deliberately left out here so this diff stays test-only.

Worth flagging separately: the same mechanism hides a wider problem on #24815. ddev test --compat karpenter passes on clean master and fails on that branch with ModuleNotFoundError: No module named 'datadog_checks.base.utils.http_exceptions', raised from MockHTTPResponse.raise_for_status. 69 integrations consume a fixture that now yields MockHTTPResponse, and karpenter is touched by neither PR.

Verification

All 36 suites were run locally. 429 passed, and every non-zero exit was reproduced away from this change.

Result Suites
Clean exit 28
docker compose or connection refused under Colima etcd, impala, ray, riak, scylla, silk, temporal
Pre-existing on master cilium

cilium reports the identical 2 failures on clean origin/master, 2 failed, 30 passed, 5 skipped, and both are marked skip_on_ci. ddev test --lint is clean across all 36.

The 63 files are byte-identical to #22676 at bf01ee0c1f, verified with git diff.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

These suites patched requests.Session and built requests.Response
objects directly, so they were written against the HTTP library
rather than against the client contract. Route them through the
mock_http, mock_openmetrics_http, and mock_prometheus_http doubles
and MockHTTPResponse, so a backend change cannot break them.

Harness HTTP in dd_environment is left on requests. It stands up
the test environment rather than intercepting the check, so it
cannot break on a backend flip.
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Aug 11, 2026

Copy link
Copy Markdown

Pipelines  Tests  Code Coverage

⚠️ Warnings

🚦 46 Pipeline jobs failed

PR | test / test-minimum-base-package (linux, ubuntu-22.04, amazon_msk, Amazon Kafka (py3.13), py3.13) / minimum-base-package-Amazon Kafka (py3.13)-py3.13   View in Datadog   GitHub Actions

🔧 Fix in code. This looks caused by changes in this PR. ImportError: cannot import name 'set_header' from 'datadog_checks.base.utils.headers'.

PR | test / test-minimum-base-package (linux, ubuntu-22.04, apache, Apache (py3.13-2.4.27), py3.13-2.4.27) / minimum-base-package-Apache (py3.13-2.4.27)-py3.13-2.4.27   View in Datadog   GitHub Actions

🔧 Fix in code. This looks caused by changes in this PR. ImportError: cannot import name 'create_http_client' from 'datadog_checks.base.utils.http' during unit tests.

PR | test / test-minimum-base-package (linux, ubuntu-22.04, azure_iot_edge, Azure IoT Edge (py3.13-tls), py3.... / minimum-base-package-Azure IoT Edge (py3.13-tls)-py3.13-tls   View in Datadog   GitHub Actions

🔧 Fix in code. This looks caused by changes in this PR. ImportError: No module named 'datadog_checks.base.utils.http_exceptions' while importing tests/test_check.py and tests/test_e2e.py.

View all 46 failed jobs.

📋 Copy prompt for your agent
CI on my pull request is failing. Help me find and fix the root cause of each failing job below — they were flagged as caused by changes in this PR, so focus on the diff. For each job, explain the failure and propose a fix.

Branch: mwdd146980/http-agnostic-test-decoupling

PR | test / test-minimum-base-package (linux, ubuntu-22.04, amazon_msk, Amazon Kafka (py3.13), py3.13) / minimum-base-package-Amazon Kafka (py3.13)-py3.13
Commit: 924e4b1e423863f1b3ef8d719bd546f4f7f3a91e
Error (code / build):
ImportError: cannot import name 'set_header' from 'datadog_checks.base.utils.headers'.
CI job: https://github.com/DataDog/integrations-core/actions/runs/31506028953/job/93827897648

PR | test / test-minimum-base-package (linux, ubuntu-22.04, apache, Apache (py3.13-2.4.27), py3.13-2.4.27) / minimum-base-package-Apache (py3.13-2.4.27)-py3.13-2.4.27
Commit: 924e4b1e423863f1b3ef8d719bd546f4f7f3a91e
Error (code / test):
ImportError: cannot import name 'create_http_client' from 'datadog_checks.base.utils.http' during unit tests.
CI job: https://github.com/DataDog/integrations-core/actions/runs/31506028953/job/93827897952

PR | test / test-minimum-base-package (linux, ubuntu-22.04, azure_iot_edge, Azure IoT Edge (py3.13-tls), py3.... / minimum-base-package-Azure IoT Edge (py3.13-tls)-py3.13-tls
Commit: 924e4b1e423863f1b3ef8d719bd546f4f7f3a91e
Error (code / test):
ImportError: No module named 'datadog_checks.base.utils.http_exceptions' while importing tests/test_check.py and tests/test_e2e.py.
CI job: https://github.com/DataDog/integrations-core/actions/runs/31506028953/job/93827897530

Plus 33 more failing jobs not shown here.

🧪 68 Tests failed in 1 job

PR | run   GitHub Actions

test_check from test_cert_manager.py   View in Datadog
cannot import name &#39;set_header&#39; from &#39;datadog_checks.base.utils.headers&#39; (/home/runner/.local/share/hatch/env/virtual/datadog-cert-manager/oFT6DkkL/py3.13/lib/python3.13/site-packages/datadog_checks/base/utils/headers.py)
test_openmetrics_error from test_cert_manager.py   View in Datadog
cannot import name &#39;set_header&#39; from &#39;datadog_checks.base.utils.headers&#39; (/home/runner/.local/share/hatch/env/virtual/datadog-cert-manager/oFT6DkkL/py3.13/lib/python3.13/site-packages/datadog_checks/base/utils/headers.py)

View all failed tests

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 99.42%
Overall Coverage: 90.78% (+2.34%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 99de50d | Docs | Datadog PR Page | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

evalya-impact-summary

evalya impact analysis
Impact analysis: 0 selected, 0 skipped (of 0 test tasks)
Publish tasks:   0 (always emitted)
Diff (140 files):
  amazon_msk/tests/conftest.py
  apache/tests/conftest.py
  appgate_sdp/tests/test_unit.py
  argo_workflows/tests/test_unit.py
  azure_iot_edge/tests/test_check.py
  azure_iot_edge/tests/test_e2e.py
  bentoml/tests/test_unit.py
  celery/tests/test_unit.py
  cert_manager/tests/test_cert_manager.py
  cilium/tests/conftest.py
  citrix_hypervisor/changelog.d/24815.fixed
  citrix_hypervisor/datadog_checks/citrix_hypervisor/check.py
  citrix_hypervisor/tests/conftest.py
  crio/tests/test_crio.py
  datadog_checks_base/changelog.d/24815.added
  datadog_checks_base/datadog_checks/base/checks/base.py
  datadog_checks_base/datadog_checks/base/checks/kubelet_base/base.py
  datadog_checks_base/datadog_checks/base/checks/openmetrics/base_check.py
  datadog_checks_base/datadog_checks/base/checks/openmetrics/mixins.py
  datadog_checks_base/datadog_checks/base/checks/openmetrics/v2/base.py
  ... and 120 more

Debug a specific task: evalya plan impact --path <path> --task <task>

Learn more about CI impact filtering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment