Skip to content
Closed
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
55 changes: 55 additions & 0 deletions tests/integration/endpoint_client/test_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,51 @@ def test_drain_is_non_blocking(self, http_client):
assert elapsed < 1.0


class TestInit:
"""Test initialization behavior."""

def test_missing_zmq_context_raises(self):
"""HTTPEndpointClient raises ValueError without zmq_context."""
config = HTTPClientConfig(
endpoint_urls=["http://localhost:8080/v1/chat/completions"],
num_workers=1,
max_connections=10,
warmup_connections=0,
)
with pytest.raises(ValueError, match="zmq_context is required"):
HTTPEndpointClient(config)

def test_external_loop_used(self, mock_http_echo_server):
"""HTTPEndpointClient uses provided external loop."""
from inference_endpoint.async_utils.loop_manager import LoopManager

manager = LoopManager()
loop = manager.create_loop(
name="test-external-loop",
backend="uvloop",
task_factory_mode="eager",
)
try:
with ManagedZMQContext.scoped() as zmq_ctx:
client = HTTPEndpointClient(
HTTPClientConfig(
endpoint_urls=[
f"{mock_http_echo_server.url}/v1/chat/completions"
],
num_workers=1,
max_connections=10,
warmup_connections=0,
),
loop=loop,
zmq_context=zmq_ctx,
)
assert client.loop is loop
assert not client._owns_loop # Didn't create it, doesn't own it
client.shutdown()
finally:
manager.stop_loop("test-external-loop")


class TestShutdown:
"""Test shutdown behavior."""

Expand All @@ -583,3 +628,13 @@ def test_issue_after_shutdown_drops(self, mock_http_echo_server):
)
client.shutdown()
client.issue(_make_query("post-shutdown"))

def test_shutdown_logs_dropped_requests(self, mock_http_echo_server):
"""Shutdown logs count of dropped requests when > 0."""
with ManagedZMQContext.scoped() as zmq_ctx:
client = _create_client(
f"{mock_http_echo_server.url}/v1/chat/completions",
zmq_context=zmq_ctx,
)
client._dropped_requests = 3
client.shutdown()
Comment on lines +632 to +640
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is named/documented as verifying that shutdown logs dropped requests, but it doesn't assert on any emitted log output (no caplog/logger patching). As a result it will pass even if nothing is logged. Please capture logs and assert the expected message/level when _dropped_requests > 0, or rename the test to reflect what it actually verifies.

Copilot uses AI. Check for mistakes.
Loading
Loading