Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions tests/e2e/batches/test_batches_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import pytest

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker

from batch_client import (
UPLOAD_FILENAME,
Expand Down Expand Up @@ -702,14 +702,7 @@ class TestBedrockBatchAssumeRole:
def test_unified_batch_create_with_assume_role(
self, client: BatchClient, resources: ResourceManager
) -> None:
(role_arn,) = require_env("AWS_ROLE_NAME")
require_env(
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"AWS_REGION",
"AWS_BATCH_S3_BUCKET",
"AWS_BATCH_ROLE_ARN",
)
role_arn = os.environ["AWS_ROLE_NAME"]
session_name = f"e2e-batch-sts-{unique_marker()}"[:64]
model_name = batch_model_name("bedrock-sts-batch")

Expand Down Expand Up @@ -819,7 +812,7 @@ class TestHostedVllmBatch:
def test_unified_file_and_batch_create(
self, client: BatchClient, resources: ResourceManager
) -> None:
(api_base,) = require_env("HOSTED_VLLM_API_BASE")
api_base = os.environ["HOSTED_VLLM_API_BASE"]
api_key = (os.environ.get("HOSTED_VLLM_API_KEY") or "").strip() or None
model_id = (
os.environ.get("HOSTED_VLLM_MODEL") or "meta-llama/Llama-3.2-3B-Instruct"
Expand Down
16 changes: 0 additions & 16 deletions tests/e2e/e2e_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,6 @@
)


def require_env(*names: str) -> tuple[str, ...]:
"""Return the non-empty values for each env name, or hard-fail naming which are missing.

Live e2e never skips for missing credentials: a missing key is a red run so
ops knows the suite cannot prove the product path.
"""
missing = tuple(name for name in names if not (os.environ.get(name) or "").strip())
if missing:
joined = ", ".join(missing)
raise AssertionError(
f"missing required env for e2e: {joined}. "
"Add them to tests/e2e/.env locally and to litellm ops for stage/CI."
)
return tuple((os.environ.get(name) or "").strip() for name in names)


def datadog_mcp_url(*, toolsets: str = "core") -> str:
"""Regional Datadog remote MCP endpoint for this process's DD_SITE.

Expand Down
11 changes: 5 additions & 6 deletions tests/e2e/guardrails/test_bedrock_guardrail_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

from __future__ import annotations

import os

import pytest

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import UnknownApiError
from guardrails_client import GuardrailsClient
from lifecycle import ResourceManager
Expand All @@ -33,11 +35,8 @@ class TestBedrockGuardrail:
def test_bedrock_pre_call_blocks_harmful_prompt(
self, client: GuardrailsClient, resources: ResourceManager, scoped_key: str
) -> None:
(identifier, version) = require_env(
"BEDROCK_GUARDRAIL_IDENTIFIER",
"BEDROCK_GUARDRAIL_VERSION",
)
require_env("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION")
identifier = os.environ["BEDROCK_GUARDRAIL_IDENTIFIER"]
version = os.environ["BEDROCK_GUARDRAIL_VERSION"]

name = f"e2e-bedrock-guard-{unique_marker()}"
guardrail_id = client.create_bedrock_guardrail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import pytest

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import unwrap
from guardrails_client import BlockCodeExecutionParamsBody, GuardrailsClient
from lifecycle import ResourceManager
Expand Down Expand Up @@ -46,7 +46,6 @@ class TestBlockCodeExecutionGuardrail:
def test_blocks_execution_request_but_allows_explanation(
self, client: GuardrailsClient, resources: ResourceManager, scoped_key: str
) -> None:
require_env("GEMINI_API_KEY")
model = client.create_backend_model(resources, prefix="e2e-blockcode-backend")

name = f"e2e-block-code-{unique_marker()}"
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/guardrails/test_openai_moderation_guardrail_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import pytest

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import UnknownApiError, unwrap
from guardrails_client import GuardrailsClient, OpenAIModerationParamsBody
from lifecycle import ResourceManager
Expand All @@ -34,7 +34,6 @@ class TestOpenAIModerationGuardrail:
def test_moderation_blocks_flagged_input(
self, client: GuardrailsClient, resources: ResourceManager, scoped_key: str
) -> None:
require_env("OPENAI_API_KEY", "GEMINI_API_KEY")
model = client.create_backend_model(resources, prefix="e2e-moderation-backend")

name = f"e2e-openai-moderation-{unique_marker()}"
Expand Down
11 changes: 4 additions & 7 deletions tests/e2e/guardrails/test_presidio_guardrail_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@

from __future__ import annotations

import os
import time

import pytest

from e2e_config import POLL_INTERVAL, POLL_TIMEOUT, require_env, unique_marker
from e2e_config import POLL_INTERVAL, POLL_TIMEOUT, unique_marker
from e2e_http import NoBody, require_successful_call, unwrap
from guardrails_client import GuardrailMode, GuardrailsClient, PresidioParamsBody
from lifecycle import ResourceManager
Expand Down Expand Up @@ -88,9 +89,8 @@ def _poll_logged_prompt(reader: OtelReader, *, call_id: str, genai_span: str) ->
def _presidio_params(
mode: GuardrailMode, *, apply_to_output: bool = False, logging_only: bool = False
) -> PresidioParamsBody:
analyzer, anonymizer = require_env(
"PRESIDIO_ANALYZER_API_BASE", "PRESIDIO_ANONYMIZER_API_BASE"
)
analyzer = os.environ["PRESIDIO_ANALYZER_API_BASE"]
anonymizer = os.environ["PRESIDIO_ANONYMIZER_API_BASE"]
return PresidioParamsBody(
mode=mode,
default_on=False,
Expand Down Expand Up @@ -124,7 +124,6 @@ class TestPresidioGuardrail:
def test_pre_call_masks_pii_before_the_model_sees_it(
self, client: GuardrailsClient, resources: ResourceManager, scoped_key: str
) -> None:
require_env("GEMINI_API_KEY")
model = client.create_backend_model(resources, prefix="e2e-presidio-pre")
name = f"e2e-presidio-pre-{unique_marker()}"
guardrail_id = client.register(name, _presidio_params("pre_call"))
Expand All @@ -149,7 +148,6 @@ def test_pre_call_masks_pii_before_the_model_sees_it(
def test_post_call_masks_pii_in_model_output(
self, client: GuardrailsClient, resources: ResourceManager, scoped_key: str
) -> None:
require_env("GEMINI_API_KEY")
model = client.create_backend_model(resources, prefix="e2e-presidio-post")
name = f"e2e-presidio-post-{unique_marker()}"
guardrail_id = client.register(name, _presidio_params("post_call", apply_to_output=True))
Expand All @@ -173,7 +171,6 @@ def test_post_call_masks_pii_in_model_output(
def test_logging_only_masks_the_logged_prompt(
self, client: GuardrailsClient, resources: ResourceManager, scoped_key: str
) -> None:
require_env("GEMINI_API_KEY")
_require_otel_v2_active(client)
reader = build_otel_reader()

Expand Down
15 changes: 3 additions & 12 deletions tests/e2e/llm_translation/test_chat_completions_regression_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pytest
from pydantic import BaseModel

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import StreamingResponse, unwrap
from lifecycle import ResourceManager
from models import (
Expand Down Expand Up @@ -250,7 +250,7 @@ class TestCohereChat:
def test_cohere_chat_returns_content(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
(cohere_key,) = require_env("COHERE_API_KEY")
cohere_key = os.environ["COHERE_API_KEY"]
model = f"e2e-cohere-chat-{unique_marker()}"
model_id = client.proxy.create_model(
model,
Expand Down Expand Up @@ -343,7 +343,7 @@ class TestHostedVllmChat:
def test_hosted_vllm_chat_returns_content(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
(api_base,) = require_env("HOSTED_VLLM_API_BASE")
api_base = os.environ["HOSTED_VLLM_API_BASE"]
api_key = (os.environ.get("HOSTED_VLLM_API_KEY") or "").strip() or None
backend = (
os.environ.get("HOSTED_VLLM_MODEL") or "meta-llama/Llama-3.2-3B-Instruct"
Expand Down Expand Up @@ -395,7 +395,6 @@ class TestOpenAIChatCompletions:
def test_openai_chat_streams_real_content(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
require_env("OPENAI_API_KEY")
model = f"e2e-openai-chat-{unique_marker()}"
model_id = client.proxy.create_model(
model, LiteLLMParamsBody(model=OPENAI_BACKEND, api_key="os.environ/OPENAI_API_KEY")
Expand Down Expand Up @@ -423,7 +422,6 @@ def test_openai_chat_streams_real_content(
def test_openai_chat_logs_cost(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
require_env("OPENAI_API_KEY")
model = f"e2e-openai-cost-{unique_marker()}"
model_id = client.proxy.create_model(
model, LiteLLMParamsBody(model=OPENAI_BACKEND, api_key="os.environ/OPENAI_API_KEY")
Expand Down Expand Up @@ -457,7 +455,6 @@ def test_openai_chat_logs_cost(
def test_openai_chat_returns_tool_call(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
require_env("OPENAI_API_KEY")
model = f"e2e-openai-tool-{unique_marker()}"
model_id = client.proxy.create_model(
model, LiteLLMParamsBody(model=OPENAI_BACKEND, api_key="os.environ/OPENAI_API_KEY")
Expand Down Expand Up @@ -488,7 +485,6 @@ def test_openai_chat_returns_tool_call(
def test_openai_chat_structured_output_conforms_to_schema(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
require_env("OPENAI_API_KEY")
model = f"e2e-openai-schema-{unique_marker()}"
model_id = client.proxy.create_model(
model, LiteLLMParamsBody(model=OPENAI_BACKEND, api_key="os.environ/OPENAI_API_KEY")
Expand Down Expand Up @@ -522,7 +518,6 @@ def test_openai_chat_structured_output_conforms_to_schema(
def test_openai_chat_reasoning_reports_reasoning_tokens(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
require_env("OPENAI_API_KEY")
model = f"e2e-openai-reasoning-{unique_marker()}"
model_id = client.proxy.create_model(
model, LiteLLMParamsBody(model=OPENAI_BACKEND, api_key="os.environ/OPENAI_API_KEY")
Expand Down Expand Up @@ -561,7 +556,6 @@ def test_openai_chat_reasoning_reports_reasoning_tokens(
def test_openai_chat_vision_describes_image(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
require_env("OPENAI_API_KEY")
model = f"e2e-openai-vision-{unique_marker()}"
model_id = client.proxy.create_model(
model, LiteLLMParamsBody(model=OPENAI_VISION_BACKEND, api_key="os.environ/OPENAI_API_KEY")
Expand All @@ -579,7 +573,6 @@ def test_openai_chat_vision_describes_image(
def test_openai_chat_prompt_cache_hits_on_repeat(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
require_env("OPENAI_API_KEY")
model = f"e2e-openai-cache-{unique_marker()}"
model_id = client.proxy.create_model(
model, LiteLLMParamsBody(model=OPENAI_BACKEND, api_key="os.environ/OPENAI_API_KEY")
Expand Down Expand Up @@ -610,7 +603,6 @@ def test_openai_chat_prompt_cache_hits_on_repeat(
def test_openai_chat_streams_tool_call(
self, client: PassthroughClient, resources: ResourceManager
) -> None:
require_env("OPENAI_API_KEY")
model = f"e2e-openai-tool-stream-{unique_marker()}"
model_id = client.proxy.create_model(
model, LiteLLMParamsBody(model=OPENAI_BACKEND, api_key="os.environ/OPENAI_API_KEY")
Expand Down Expand Up @@ -645,7 +637,6 @@ class TestBedrockConverseChatCompletions:
"""

def _register(self, client: PassthroughClient, resources: ResourceManager, prefix: str) -> str:
require_env("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION")
model = f"{prefix}-{unique_marker()}"
model_id = client.proxy.create_model(model, _bedrock_params())
resources.defer(lambda: client.proxy.delete_model(model_id))
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/llm_translation/test_image_generation_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import pytest

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import require_successful_call
from endpoints_client import EndpointsClient, ImagesResult
from lifecycle import ResourceManager
Expand Down Expand Up @@ -50,7 +50,6 @@ def test_image_generation_returns_image(
def test_bedrock_image_generation_returns_image(
self, endpoints_client: EndpointsClient, resources: ResourceManager
) -> None:
require_env("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION")
model = f"e2e-bedrock-image-{unique_marker()}"
model_id = endpoints_client.create_model(
model,
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/llm_translation/test_messages_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pytest

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import require_successful_call, unwrap
from endpoints_client import EndpointsClient, MessagesResult
from lifecycle import ResourceManager
Expand Down Expand Up @@ -73,7 +73,6 @@ def test_messages_returns_completion(
def test_messages_logs_cost_matching_the_response_header(
self, endpoints_client: EndpointsClient, resources: ResourceManager
) -> None:
require_env("ANTHROPIC_API_KEY")
model = f"e2e-messages-cost-{unique_marker()}"
model_id = endpoints_client.create_model(
model,
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/llm_translation/test_rerank_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import pytest

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import require_successful_call
from endpoints_client import EndpointsClient, RerankResult
from lifecycle import ResourceManager
Expand Down Expand Up @@ -56,7 +56,6 @@ def test_rerank_scores_top_n(
def test_bedrock_rerank_scores_top_n(
self, endpoints_client: EndpointsClient, resources: ResourceManager
) -> None:
require_env("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION")
model = f"e2e-bedrock-rerank-{unique_marker()}"
model_id = endpoints_client.create_model(
model,
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/llm_translation/test_responses_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pytest
from pydantic import BaseModel, ValidationError

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import require_successful_call
from endpoints_client import (
EndpointsClient,
Expand Down Expand Up @@ -255,7 +255,6 @@ def test_responses_anthropic_returns_function_call(
def test_responses_bedrock_returns_completion(
self, endpoints_client: EndpointsClient, resources: ResourceManager
) -> None:
require_env("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION")
model = f"e2e-responses-{unique_marker()}"
model_id = endpoints_client.create_model(model, _bedrock_params())
resources.defer(lambda: endpoints_client.delete_model(model_id))
Expand All @@ -270,7 +269,6 @@ def test_responses_bedrock_returns_completion(
def test_responses_bedrock_returns_function_call(
self, endpoints_client: EndpointsClient, resources: ResourceManager
) -> None:
require_env("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION")
model = f"e2e-responses-{unique_marker()}"
model_id = endpoints_client.create_model(model, _bedrock_params())
resources.defer(lambda: endpoints_client.delete_model(model_id))
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/llm_translation/test_responses_metadata_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pytest
from pydantic import BaseModel, ConfigDict

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import require_successful_call
from endpoints_client import EndpointsClient, ResponsesResult
from lifecycle import ResourceManager
Expand Down Expand Up @@ -42,7 +42,7 @@ class RedisKeyInfo(BaseModel):
def _redis_scan(marker: str) -> tuple[RedisKeyInfo, ...]:
import redis

(host,) = require_env("REDIS_HOST")
host = os.environ["REDIS_HOST"]
port = int((os.environ.get("REDIS_PORT") or "6379").strip() or "6379")
try:
with socket.create_connection((host, port), timeout=3):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import pytest

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import require_successful_call
from lifecycle import ResourceManager
from models import KeyGenerateBody, LiteLLMParamsBody
Expand All @@ -23,7 +23,7 @@


def _require_redis_reachable() -> None:
(host,) = require_env("REDIS_HOST")
host = os.environ["REDIS_HOST"]
port = int((os.environ.get("REDIS_PORT") or "6379").strip() or "6379")
try:
with socket.create_connection((host, port), timeout=3):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import pytest

from e2e_config import require_env, unique_marker
from e2e_config import unique_marker
from e2e_http import require_successful_call
from lifecycle import ResourceManager
from models import KeyGenerateBody, LiteLLMParamsBody
Expand All @@ -28,7 +28,7 @@


def _require_redis() -> None:
(host,) = require_env("REDIS_HOST")
host = os.environ["REDIS_HOST"]
port = int((os.environ.get("REDIS_PORT") or "6379").strip() or "6379")
try:
with socket.create_connection((host, port), timeout=3):
Expand Down
Loading