Skip to content

Migrate apache mock_hide_server_version fixture to mock_http#23643

Open
mwdd146980 wants to merge 2 commits intoDataDog:mwdd146980/httpx-migration-basefrom
mwdd146980:mwdd146980/step5-apache-e2e
Open

Migrate apache mock_hide_server_version fixture to mock_http#23643
mwdd146980 wants to merge 2 commits intoDataDog:mwdd146980/httpx-migration-basefrom
mwdd146980:mwdd146980/step5-apache-e2e

Conversation

@mwdd146980
Copy link
Copy Markdown
Contributor

@mwdd146980 mwdd146980 commented May 8, 2026

Motivation

Last requests.Session patch in apache test surface. Closes Step 5 conftest cleanup.

Approach

Route version-stripping fixture through mock_http. Side-effect performs real GET against HTTPD container brought up by dd_environment, then returns MockHTTPResponse with ServerVersion filtered out and headers preserved.

Sole consumer is test_metadata_in_header (@pytest.mark.usefixtures("dd_environment"), integration-style). Runs under ddev test apache, not ddev env test.

Verification

  • ddev test -fs apache clean
  • ddev --no-interactive test apache 18 passed, 1 skipped
  • ddev --no-interactive test apache -- -k test_metadata_in_header 1 passed

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

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mwdd146980 mwdd146980 self-assigned this May 8, 2026
@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 95.04%. Comparing base (20e464b) to head (0bbc993).

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 17:56
@mwdd146980 mwdd146980 requested a review from a team as a code owner May 8, 2026 17:56
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: 4bf627bce1

ℹ️ 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 apache/tests/conftest.py Outdated
def filter_server_version(url, *args, **kwargs):
r = requests.get(url, **kwargs)
content = '\n'.join(line for line in r.text.splitlines() if 'ServerVersion' not in line)
return MockHTTPResponse(content=content, headers=dict(r.headers))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve upstream status code in mocked response

This fixture now wraps the real HTTP result in MockHTTPResponse without passing status_code, so it always defaults to 200. In test_metadata_in_header, that means Apache.check() no longer exercises its error path when the status endpoint returns 4xx/5xx, and the test can report success even though production would call raise_for_status() and fail. Propagating r.status_code (and ideally url) keeps the mock behavior aligned with the real response.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

@mwdd146980 mwdd146980 May 8, 2026

Choose a reason for hiding this comment

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

Fixed in 0bbc993 by passing status_code=r.status_code and url=r.url to MockHTTPResponse. Verified with ddev --no-interactive test apache -- -k test_metadata_in_header, which passed.

…version

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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