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): give the ownership proxy its own DB pool headroom (#46025)
devin-ai-integration[bot]85b1095f1eac
diff --git a/tests/integration/management/test_project_lifecycle.py b/tests/integration/management/test_project_lifecycle.pyindex d2f45d853a4..fafda579162 100644--- a/tests/integration/management/test_project_lifecycle.py+++ b/tests/integration/management/test_project_lifecycle.py@@ -14,6 +14,7 @@ import httpximport psutilimport psycopgimport pytest+import yamlfrom integration._support.client import (JSON_OBJECT,Gateway,@@ -24,7 +25,7 @@ from integration._support.client import (string_value,)from integration._support.database import read_rows, write_rows-from integration._support.process import group_members, owned_proxy, owned_proxy_process+from integration._support.process import CONFIGURATION, OwnedProxy, group_members, owned_proxy, owned_proxy_processfrom integration._support.wire import Reply, Request, wire_serverfrom pydantic import JsonValue@@ -32,9 +33,26 @@ from litellm.models.user import LiteLLM_UserTablefrom litellm.proxy.auth.auth_checks import ExperimentalUIJWTToken_OWNED_PROXY_SALT_KEY: Final = "sk-integration-salt"+_OWNERSHIP_POOL_LIMIT: Final = 4+_CONNECTION_BUDGET: Final = re.compile(+ r"Postgres connection budget per pod = \d+ worker\(s\) x \(?writer connection_limit (\d+)"+)_OWNERSHIP_MARKER: Final = re.compile(rb"ownership-[0-9a-f]{32}")+def _ownership_config(directory: Path) -> Path:+ source: Final = Path(__file__).resolve().parents[1] / "proxy_config.yaml"+ settings: Final = CONFIGURATION.validate_python(yaml.safe_load(source.read_text()))+ general: Final = CONFIGURATION.validate_python(settings["general_settings"])+ configured: Final = {+ **settings,+ "general_settings": {**general, "database_connection_pool_limit": _OWNERSHIP_POOL_LIMIT},+ }+ destination: Final = directory / "ownership-proxy-config.yaml"+ destination.write_text(yaml.safe_dump(configured, sort_keys=False))+ return destination++def _project_rows(project_id: str) -> list[dict[str, JsonValue]]:return read_rows('SELECT p.project_id, p.project_alias, p.description, p.team_id, p.models, p.blocked, '@@ -806,7 +824,12 @@ def test_ownership_rejections_during_concurrent_traffic_burst(ownership_gateway:assert _project_state_rows(project_a) == project_before-def test_ownership_checks_wait_for_row_locks_without_failing_readiness(ownership_gateway: Gateway) -> None:+def test_ownership_checks_wait_for_row_locks_without_failing_readiness(+ ownership_gateway: Gateway, ownership_proxy: OwnedProxy+) -> None:+ budget: Final = _CONNECTION_BUDGET.search(ownership_proxy.log.read_text())+ assert budget is not None, ownership_proxy.log.read_text()+ assert int(budget.group(1)) == _OWNERSHIP_POOL_LIMITwith ownership_gateway.scenario() as scenario:model: Final = scenario.model()team: Final = scenario.team(models=[model])@@ -986,15 +1009,22 @@ def test_ownership_enforced_after_worker_kill(ownership_gateway: Gateway, tmp_pa@pytest.fixture(scope="module")-def ownership_gateway(tmp_path_factory: pytest.TempPathFactory) -> Iterator[Gateway]:+def ownership_proxy(tmp_path_factory: pytest.TempPathFactory) -> Iterator[OwnedProxy]:+ directory: Final = tmp_path_factory.mktemp("project-team-ownership")with gateway_from_environment() as gateway:- with owned_proxy(+ with owned_proxy_process(gateway,- tmp_path_factory.mktemp("project-team-ownership"),+ directory,{"LITELLM_SALT_KEY": _OWNED_PROXY_SALT_KEY},+ config=_ownership_config(directory),workers=2,- ) as candidate:- yield candidate+ ) as owned:+ yield owned++[email protected](scope="module")+def ownership_gateway(ownership_proxy: OwnedProxy) -> Gateway:+ return ownership_proxy.gateway@pytest.mark.covers("mgmt.project.new.real_route_persists")