test(local_testing): point the sub-ms timeout tests at an unroutable api_base

test_openai_embedding_timeouts and test_timeout_streaming dialed real
OpenAI with a sub-millisecond timeout and asserted openai.APITimeoutError.
On an IPv6-less CircleCI runner the AAAA connect fails first as Errno 99,
httpx raises ConnectError and litellm maps it to InternalServerError, so
both tests go red for any PR with no code change involved.

Both tests now call litellm with api_base pointed at 192.0.2.1 (RFC 5737
TEST-NET-1) through a shared unroutable_api_base fixture. The SYN is
dropped, the connect can only time out, and the assertion still proves
litellm maps a client-side connect timeout to openai.APITimeoutError.

Resolves LIT-6670
This commit is contained in:
mateo-berri 2026-09-01 21:58:42 -07:00
parent 92d453373a
commit e17fae7ec5
3 changed files with 9 additions and 2 deletions

View file

@ -259,6 +259,11 @@ def setup_and_teardown():
yield
@pytest.fixture
def unroutable_api_base():
return "http://192.0.2.1"
def pytest_collection_modifyitems(config, items):
apply_vcr_auto_marker_to_items(
items,

View file

@ -266,11 +266,12 @@ def test_openai_azure_embedding_timeouts():
# test_openai_azure_embedding_timeouts()
def test_openai_embedding_timeouts():
def test_openai_embedding_timeouts(unroutable_api_base):
try:
response = embedding(
model="text-embedding-ada-002",
input=["good morning from litellm"],
api_base=unroutable_api_base,
timeout=0.00001,
)
print(response)

View file

@ -211,13 +211,14 @@ def test_hanging_request_openai():
# test_timeout()
def test_timeout_streaming():
def test_timeout_streaming(unroutable_api_base):
# this Will Raise a timeout
litellm.set_verbose = False
try:
response = litellm.completion(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "hello, write a 20 pg essay"}],
api_base=unroutable_api_base,
timeout=0.0001,
stream=True,
)