mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
fix(e2e): start cache CI service and count bypass calls
This commit is contained in:
parent
4587dbeae9
commit
45d5e6b833
3 changed files with 28 additions and 4 deletions
8
.github/workflows/test-provider-cache.yml
vendored
8
.github/workflows/test-provider-cache.yml
vendored
|
|
@ -24,7 +24,7 @@ jobs:
|
|||
ports:
|
||||
- 6379:6379
|
||||
options: >-
|
||||
--health-cmd 'redis-cli ping'
|
||||
--health-cmd "redis-cli ping"
|
||||
--health-interval 5s
|
||||
--health-timeout 3s
|
||||
--health-retries 10
|
||||
|
|
@ -35,10 +35,10 @@ jobs:
|
|||
E2E_PROVIDER_CACHE: '0'
|
||||
E2E_FIXTURE_MODE: live
|
||||
steps:
|
||||
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
|
||||
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
||||
with:
|
||||
python-version: '3.13'
|
||||
- uses: ./.github/actions/setup-uv-with-retries
|
||||
|
|
@ -56,7 +56,7 @@ jobs:
|
|||
-q --junitxml=provider-cache-results.xml
|
||||
- name: Save test results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1
|
||||
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
|
||||
with:
|
||||
name: provider-cache-results
|
||||
path: provider-cache-results.xml
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ from collections.abc import Generator
|
|||
from concurrent.futures import ThreadPoolExecutor
|
||||
from contextlib import contextmanager
|
||||
from dataclasses import dataclass, replace
|
||||
from http.client import HTTPConnection
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from typing import Final
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
import pytest
|
||||
from e2e_http import NetworkError, PreparedForward, RawResponse, StreamChunk, StreamHead, forward, prepare_forward
|
||||
|
|
@ -407,3 +409,24 @@ def test_enabled_environment_reuses_store_across_fresh_backends(
|
|||
assert configured_cache_backend() is None
|
||||
finally:
|
||||
configured_cache.cache_clear()
|
||||
|
||||
|
||||
def test_duplicate_headers_bypass_cache_and_count_live_calls(store: RedisResponseStore, provider: Provider) -> None:
|
||||
cache: Final = CacheEdge(store, SECRET)
|
||||
with edge(cache, provider) as url:
|
||||
parsed: Final = urlsplit(url)
|
||||
for _ in range(2):
|
||||
connection = HTTPConnection(str(parsed.hostname), parsed.port, timeout=5)
|
||||
try:
|
||||
connection.putrequest("POST", parsed.path)
|
||||
connection.putheader("content-length", str(len(BODY)))
|
||||
connection.putheader("content-type", "application/json")
|
||||
connection.putheader("x-duplicate", "first")
|
||||
connection.putheader("x-duplicate", "second")
|
||||
connection.endheaders(BODY)
|
||||
assert connection.getresponse().read() == SUCCESS
|
||||
finally:
|
||||
connection.close()
|
||||
assert len(provider.hits) == 2
|
||||
assert dict(cache.counters.counts)["duplicate_header_bypass"] == 2
|
||||
assert dict(cache.counters.counts)["upstream_attempts"] == 2
|
||||
|
|
|
|||
|
|
@ -891,6 +891,7 @@ class _EdgeHandler(BaseHTTPRequestHandler):
|
|||
)
|
||||
if isinstance(edge_server.backend, CacheEdge) and duplicate_headers:
|
||||
edge_server.backend.counters.increment("duplicate_header_bypass")
|
||||
edge_server.backend.counters.increment("upstream_attempts")
|
||||
outcome: Final = handle_edge_request(
|
||||
selected_backend,
|
||||
edge_server.mounts,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue