From e17fae7ec558e298aed9ac321d8eb7325b572372 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 1 Sep 2026 21:58:42 -0700 Subject: [PATCH] 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 --- tests/local_testing/conftest.py | 5 +++++ tests/local_testing/test_embedding.py | 3 ++- tests/local_testing/test_timeout.py | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/local_testing/conftest.py b/tests/local_testing/conftest.py index 5535a62bb81..dce367aa915 100644 --- a/tests/local_testing/conftest.py +++ b/tests/local_testing/conftest.py @@ -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, diff --git a/tests/local_testing/test_embedding.py b/tests/local_testing/test_embedding.py index ee2ac14f498..6e09e46d6f9 100644 --- a/tests/local_testing/test_embedding.py +++ b/tests/local_testing/test_embedding.py @@ -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) diff --git a/tests/local_testing/test_timeout.py b/tests/local_testing/test_timeout.py index 66054a0930a..217a71dec16 100644 --- a/tests/local_testing/test_timeout.py +++ b/tests/local_testing/test_timeout.py @@ -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, )