Skip to content

test(e2e): rename Gateway to ProxyClient and expose it as a pytest fixture - #33715

Closed
devin-ai-integration[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_e2e_cleanup
Closed

test(e2e): rename Gateway to ProxyClient and expose it as a pytest fixture#33715
devin-ai-integration[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_e2e_cleanup

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Relevant issues

Linear ticket

Resolves LIT-4549

Pre-Submission checklist

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Type

🧹 Refactoring
✅ Test

Changes

Two changes to the e2e harness, no product code touched.

Rename the misnamed shared proxy wrapper. tests/e2e/e2e_gateway.py held Gateway, which is not a gateway server; it is the client every suite uses to talk to the proxy (keys, models, chat/embed/ocr, spend read-backs, poll helpers). The file is now proxy_client.py and the class is ProxyClient, with build_gateway becoming build_proxy_client and GatewayProvider becoming ProxyClientProvider. The .gateway attribute suites hold is now .proxy. Only identifiers changed; renaming was done token-by-token so strings and prose were left alone, then the docstrings/comments and the e2e CLAUDE.md / CONTRIBUTING.md were updated to match.

Make it a pytest fixture. Previously each suite built its own instance through a per-suite build_client() that called build_gateway() inside, so the proxy wiring was duplicated across every suite. There is now one session-scoped proxy fixture in tests/e2e/conftest.py:

@pytest.fixture(scope="session")
def proxy() -> ProxyClient:
    return build_proxy_client()

Each suite's client fixture depends on it and injects it, and each suite factory takes the client instead of constructing its own:

# before
def build_client() -> PassthroughClient:
    return PassthroughClient(gateway=build_gateway())

@pytest.fixture(scope="session")
def client() -> PassthroughClient:
    return build_client()

# after
def build_client(proxy: ProxyClient) -> PassthroughClient:
    return PassthroughClient(proxy=proxy)

@pytest.fixture(scope="session")
def client(proxy: ProxyClient) -> PassthroughClient:
    return build_client(proxy)

Behavior is unchanged: shared transport, data-plane/control-plane split routing, poll budget, typed request/response models, and resource cleanup all go through the same object. claude_code/ keeps calling build_proxy_client(...) directly with its own base URLs (it has its own harness and does not use the shared fixtures).

Also deletes tests/e2e/grafana/status_history_panels.md, prose describing dashboards that nothing in the tree reads.

QA runbook

No test behavior changed; this is a rename plus fixture-wiring refactor of the harness. Validation performed:

  • make lint-e2e-basedpyright reports 0 errors
  • ruff check tests/e2e passes
  • pytest --collect-only over tests/e2e collects every suite with no import/fixture errors
  • python -m coverage_registry.collector still resolves every covers(...) marker (152/384), confirming no marker regressed in the rename

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/fdfd7afe0a954cb6851e76636d53237e
Requested by: @yassin-berriai

…p unused grafana docs

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@yassin-berriai yassin-berriai self-assigned this Jul 17, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR is a purely mechanical harness refactor: tests/e2e/e2e_gateway.py is renamed to proxy_client.py, the Gateway class becomes ProxyClient, GatewayProvider becomes ProxyClientProvider, and a new session-scoped proxy pytest fixture in the top-level conftest.py replaces the per-suite build_gateway() call pattern. No product code is touched.

  • Every suite's client fixture now declares a proxy: ProxyClient dependency, eliminating duplicated build_gateway() wiring across 10+ suites.
  • All client.gateway attribute references are consistently renamed to client.proxy, and the old e2e_gateway.py is deleted.
  • tests/e2e/grafana/status_history_panels.md is removed as dead prose not read by anything in the tree.

Confidence Score: 5/5

This is a rename-and-fixture-wiring refactor of the e2e test harness; no production code is touched and behavior is unchanged.

The rename is mechanically consistent across all 53 files — every client.gateway reference, import, and protocol property has been updated. The new session-scoped proxy fixture correctly eliminates per-suite build_gateway() duplication without altering lifecycle or cleanup semantics. The only rough edge is a single local variable in claude_code/conftest.py that changes type mid-function, which is a readability concern with no runtime impact.

tests/e2e/claude_code/conftest.py — the proxy variable is reused for two different types in the same function scope.

Important Files Changed

Filename Overview
tests/e2e/proxy_client.py New file: renamed from e2e_gateway.py; class renamed from Gateway to ProxyClient, build function from build_gateway to build_proxy_client. Content is otherwise identical.
tests/e2e/conftest.py Adds the new session-scoped proxy fixture; updates resources fixture to use ProxyClientProvider/client.proxy.
tests/e2e/lifecycle.py GatewayProvider → ProxyClientProvider, .gateway property → .proxy; import updated from e2e_gateway to proxy_client.
tests/e2e/claude_code/conftest.py Renamed _build_control_gateway to use build_proxy_client; local variable proxy now reused for both ProxyConfig (from resolve_proxy) and ProxyClient (from _build_control_gateway), shadowing the type mid-function.
tests/e2e/router/conftest.py Renamed Gateway → ProxyClient throughout; client fixture now takes proxy parameter; helper functions updated accordingly.
tests/e2e/quota_management/spend_tracking/conftest.py client fixture now takes proxy parameter; driver_models fixture updated to use client.proxy instead of client.gateway.
tests/e2e/logging/logging_client.py gateway attribute renamed to proxy; all self.gateway references updated to self.proxy; build_logging_client now accepts proxy parameter.
tests/e2e/management/management_client.py gateway attribute renamed to proxy throughout; build_client now accepts proxy parameter.
tests/e2e/grafana/status_history_panels.md Deleted dead-prose file not referenced anywhere in the test tree.

Reviews (1): Last reviewed commit: "test(e2e): rename Gateway->ProxyClient, ..." | Re-trigger Greptile

from requests import RequestException

gateway = _build_control_gateway(proxy)
proxy = _build_control_gateway(proxy)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The proxy variable changes type mid-function: it starts as ProxyConfig (from resolve_proxy()) and is immediately overwritten with a ProxyClient. The original code avoided this by using a distinct name (gateway = _build_control_gateway(proxy)). Using a separate name keeps the two concepts explicit and avoids surprising readers (or a future type-narrowing pass) with a variable whose type silently changes.

Suggested change
proxy = _build_control_gateway(proxy)
proxy_client = _build_control_gateway(proxy)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_e2e_cleanup (db0df1a) with litellm_internal_staging (561b679)

Open in CodSpeed

@yassin-berriai

Copy link
Copy Markdown
Contributor

Superseded by #33750, which carries the same rename plus the session-scoped proxy fixture, re-authored on a current litellm_internal_staging base and rescoped to just the harness change (the grafana panel-doc deletion belongs to its own ticket). Closing this one in favor of #33750

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.

2 participants