[ROCm][CI] Stabilize 400 error return code for invalid schema inputs (#43016)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
@@ -26,6 +26,9 @@ _SERVER_STARTUP_TIMEOUT = 120
|
||||
_PROCESS_EXIT_TIMEOUT = 15
|
||||
_SHUTDOWN_DETECTION_TIMEOUT = 10
|
||||
_CHILD_CLEANUP_TIMEOUT = 10
|
||||
_INFLIGHT_REQUEST_START_TIMEOUT = 5
|
||||
_INFLIGHT_REQUEST_POLL_INTERVAL = 0.1
|
||||
_ABORT_CLIENT_TIMEOUT = 3
|
||||
|
||||
|
||||
def _get_child_pids(parent_pid: int) -> list[int]:
|
||||
@@ -71,6 +74,7 @@ class ShutdownState:
|
||||
requests_after_sigterm: int = 0
|
||||
aborted_requests: int = 0
|
||||
connection_errors: int = 0
|
||||
inflight_requests: int = 0
|
||||
stop_requesting: bool = False
|
||||
errors: list[str] = field(default_factory=list)
|
||||
|
||||
@@ -86,6 +90,7 @@ async def _concurrent_request_loop(
|
||||
async def single_request():
|
||||
while not state.stop_requesting:
|
||||
try:
|
||||
state.inflight_requests += 1
|
||||
response = await client.completions.create(
|
||||
model=MODEL_NAME,
|
||||
prompt="Write a story: ",
|
||||
@@ -110,6 +115,8 @@ async def _concurrent_request_loop(
|
||||
except Exception as e:
|
||||
state.errors.append(f"Unexpected error: {e}")
|
||||
break
|
||||
finally:
|
||||
state.inflight_requests -= 1
|
||||
await asyncio.sleep(0.01)
|
||||
|
||||
tasks = [asyncio.create_task(single_request()) for _ in range(concurrency)]
|
||||
@@ -392,7 +399,7 @@ async def test_abort_timeout_fails_inflight_requests():
|
||||
]
|
||||
|
||||
with RemoteOpenAIServer(MODEL_NAME, server_args) as remote_server:
|
||||
client = remote_server.get_async_client()
|
||||
client = remote_server.get_async_client(timeout=_ABORT_CLIENT_TIMEOUT)
|
||||
proc = remote_server.proc
|
||||
child_pids = _get_child_pids(proc.pid)
|
||||
|
||||
@@ -403,7 +410,10 @@ async def test_abort_timeout_fails_inflight_requests():
|
||||
_concurrent_request_loop(client, state, sigterm_sent, concurrency=10)
|
||||
)
|
||||
|
||||
await asyncio.sleep(0.5)
|
||||
deadline = time.time() + _INFLIGHT_REQUEST_START_TIMEOUT
|
||||
while state.inflight_requests == 0 and time.time() < deadline:
|
||||
await asyncio.sleep(_INFLIGHT_REQUEST_POLL_INTERVAL)
|
||||
assert state.inflight_requests > 0
|
||||
|
||||
proc.send_signal(signal.SIGTERM)
|
||||
sigterm_sent.set()
|
||||
|
||||
@@ -118,7 +118,9 @@ def before_generate_case(context: schemathesis.hooks.HookContext, strategy):
|
||||
# the default filtered-vs-good ratio. The filter is intentional, so
|
||||
# suppress the health check rather than drop the filter — dropping it
|
||||
# exposes pre-existing server bugs out of scope here.
|
||||
suppress_health_check=[HealthCheck.filter_too_much],
|
||||
# The same nested schema can also trip Hypothesis' entropy budget while
|
||||
# generating large-but-valid request bodies before vLLM is called.
|
||||
suppress_health_check=[HealthCheck.filter_too_much, HealthCheck.data_too_large],
|
||||
)
|
||||
def test_openapi_stateless(case: Case):
|
||||
key = (
|
||||
|
||||
@@ -69,10 +69,16 @@ class MockParallelConfig:
|
||||
_api_process_rank: int = 0
|
||||
|
||||
|
||||
@dataclass
|
||||
class MockSchedulerConfig:
|
||||
max_num_seqs: int = 128
|
||||
|
||||
|
||||
@dataclass
|
||||
class MockVllmConfig:
|
||||
model_config: MockModelConfig
|
||||
parallel_config: MockParallelConfig
|
||||
scheduler_config: MockSchedulerConfig = field(default_factory=MockSchedulerConfig)
|
||||
|
||||
|
||||
def _build_renderer(model_config: MockModelConfig):
|
||||
@@ -149,6 +155,9 @@ def _mock_engine() -> MagicMock:
|
||||
engine = MagicMock(spec=AsyncLLM)
|
||||
engine.errored = False
|
||||
engine.model_config = MockModelConfig()
|
||||
engine.vllm_config = MockVllmConfig(
|
||||
engine.model_config, parallel_config=MockParallelConfig()
|
||||
)
|
||||
engine.input_processor = MagicMock()
|
||||
engine.renderer = _build_renderer(engine.model_config)
|
||||
return engine
|
||||
|
||||
@@ -63,8 +63,8 @@ class MockWeightTransferEngine(WeightTransferEngine[MockInitInfo, MockUpdateInfo
|
||||
last_init_info: MockInitInfo | None = None
|
||||
last_update_info: MockUpdateInfo | None = None
|
||||
|
||||
def __init__(self, config, parallel_config):
|
||||
super().__init__(config, parallel_config)
|
||||
def __init__(self, config, parallel_config, model):
|
||||
super().__init__(config, parallel_config, model)
|
||||
# Reset tracking on init
|
||||
MockWeightTransferEngine.init_transfer_engine_called = False
|
||||
MockWeightTransferEngine.receive_weights_called = False
|
||||
@@ -95,9 +95,9 @@ class MockWeightTransferEngine(WeightTransferEngine[MockInitInfo, MockUpdateInfo
|
||||
pass
|
||||
|
||||
|
||||
def mock_create_engine(config, parallel_config):
|
||||
def mock_create_engine(config, parallel_config, model):
|
||||
"""Mock factory function that returns our mock engine."""
|
||||
return MockWeightTransferEngine(config, parallel_config)
|
||||
return MockWeightTransferEngine(config, parallel_config, model)
|
||||
|
||||
|
||||
# --- Tests ---
|
||||
|
||||
Reference in New Issue
Block a user