The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(integration): run the bedrock mantle prompt cache and output limit wire tests on their own proxy (#47152)
yuneng-jiang603ba6fe00be
diff --git a/tests/integration/_support/process.py b/tests/integration/_support/process.pyindex 00b9dca5184..5cbe1309075 100644--- a/tests/integration/_support/process.py+++ b/tests/integration/_support/process.py@@ -17,7 +17,7 @@ from ipaddress import IPv4Addressfrom itertools import accumulatefrom pathlib import Pathfrom types import MappingProxyType-from typing import Final+from typing import TYPE_CHECKING, Finalfrom urllib.parse import urlsplitimport httpx@@ -30,9 +30,13 @@ from cryptography.x509.oid import NameOIDfrom pydantic import TypeAdapterfrom tests.integration._support.budget import import_seconds, readiness_for, readiness_seconds-from tests.integration._support.client import GATEWAY_LIMITS, Gateway+from tests.integration._support.client import GATEWAY_LIMITS, Gateway, gateway_from_environment+from tests.integration._support.database import scratch_databasefrom tests.integration._support.ports import allocate_port+if TYPE_CHECKING:+ import pytest+DB_PUSH: Final = ("--use_prisma_db_push",)MIGRATE_DEPLOY: Final = ()LEGACY_MIGRATE_DEPLOY: Final = ("--use_legacy_migration_resolver",)@@ -379,6 +383,18 @@ def owned_proxy(yield owned.gateway+@contextmanager+def isolated_gateway(directory: Path, environment: "pytest.MonkeyPatch") -> Iterator[Gateway]:+ with gateway_from_environment() as shared, scratch_database() as database:+ environment.setenv("DATABASE_URL", database)+ environment.setenv("INTEGRATION_PROXY_DATABASE_URL", database)+ environment.delenv("INTEGRATION_PROXY_READ_REPLICA_URL", raising=False)+ environment.delenv("DATABASE_URL_READ_REPLICA", raising=False)+ with owned_proxy(shared, directory, {}) as owned:+ owned.post("/config/update", {"router_settings": {"num_retries": 0}})+ yield owned++def _stop(process: subprocess.Popen[bytes]) -> None:try:root_stopped: Final = stop_root_process(process)diff --git a/tests/integration/providers/test_bedrock_mantle_gpt_prompt_cache_breakpoint_wire.py b/tests/integration/providers/test_bedrock_mantle_gpt_prompt_cache_breakpoint_wire.pyindex 2af41c2b683..bc46cf5cde1 100644--- a/tests/integration/providers/test_bedrock_mantle_gpt_prompt_cache_breakpoint_wire.py+++ b/tests/integration/providers/test_bedrock_mantle_gpt_prompt_cache_breakpoint_wire.py@@ -1,10 +1,12 @@import asyncioimport json+from collections.abc import Iteratorfrom typing import Finalfrom urllib.parse import urlsplitimport pytestfrom integration._support.client import Gateway, eventually+from integration._support.process import isolated_gatewayfrom integration._support.wire import Request, wire_serverfrom integration.providers._mantle_gpt_prompt_cache_support import (ANTHROPIC_PATH,@@ -68,6 +70,15 @@ from pydantic import JsonValuepytestmark = pytest.mark.timeout(600)[email protected](scope="module")+def gateway(tmp_path_factory: pytest.TempPathFactory) -> Iterator[Gateway]:+ with (+ pytest.MonkeyPatch.context() as environment,+ isolated_gateway(tmp_path_factory.mktemp("gateway"), environment) as owned,+ ):+ yield owned++@pytest.mark.parametrize("stream", [False, True], ids=["json", "stream"])@pytest.mark.parametrize("endpoint", ENDPOINTS)def test_a_configured_system_point_reaches_mantle_as_a_breakpoint_over_httpx(diff --git a/tests/integration/providers/test_bedrock_mantle_output_limit_wire.py b/tests/integration/providers/test_bedrock_mantle_output_limit_wire.pyindex 343d5253900..9b07cce2f3a 100644--- a/tests/integration/providers/test_bedrock_mantle_output_limit_wire.py+++ b/tests/integration/providers/test_bedrock_mantle_output_limit_wire.py@@ -5,7 +5,7 @@ import osimport reimport threadingimport uuid-from collections.abc import Callable, Mapping+from collections.abc import Callable, Iterator, Mappingfrom dataclasses import dataclassfrom pathlib import Pathfrom queue import SimpleQueue@@ -21,7 +21,7 @@ import pytestimport yamlfrom integration._support.client import Gateway, Scenario, eventually, object_value, string_valuefrom integration._support.database import read_rows-from integration._support.process import graceful_stop_seconds, owned_proxy_process+from integration._support.process import graceful_stop_seconds, isolated_gateway, owned_proxy_processfrom integration._support.wire import Reply, Request, Wire, wire_serverfrom pydantic import JsonValue, TypeAdapter@@ -318,6 +318,15 @@ def _spend_statuses(model: str, expected: int) -> list[JsonValue]:return [row["status"] for row in rows][email protected](scope="module")+def gateway(tmp_path_factory: pytest.TempPathFactory) -> Iterator[Gateway]:+ with (+ pytest.MonkeyPatch.context() as environment,+ isolated_gateway(tmp_path_factory.mktemp("gateway"), environment) as owned,+ ):+ yield owned++def _proxy_url(gateway: Gateway) -> str:return str(gateway.client.base_url).rstrip("/")