Skip to content

Commit 32bdb9d

Browse files
committed
[Bugfix] make test_openai_schema.py pass
by filtering out test cases to `POST /tokenize` endpoint that are known to fail with a reply of HTTP 501 Not Implemented. Enable the test in CI. FIX vllm-project#18162 Signed-off-by: David Xia <[email protected]>
1 parent c7852a6 commit 32bdb9d

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

.buildkite/test-pipeline.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ steps:
125125
- pytest -v -s entrypoints/llm/test_generate.py # it needs a clean process
126126
- pytest -v -s entrypoints/llm/test_generate_multiple_loras.py # it needs a clean process
127127
- VLLM_USE_V1=0 pytest -v -s entrypoints/llm/test_guided_generate.py # it needs a clean process
128-
- pytest -v -s entrypoints/openai --ignore=entrypoints/openai/test_oot_registration.py --ignore=entrypoints/openai/test_chat_with_tool_reasoning.py --ignore=entrypoints/openai/correctness/ --ignore=entrypoints/openai/test_openai_schema.py
128+
- pytest -v -s entrypoints/openai --ignore=entrypoints/openai/test_oot_registration.py --ignore=entrypoints/openai/test_chat_with_tool_reasoning.py --ignore=entrypoints/openai/correctness/
129129
- pytest -v -s entrypoints/test_chat_utils.py
130130
- VLLM_USE_V1=0 pytest -v -s entrypoints/offline_mode # Needs to avoid interference with other tests
131131

tests/entrypoints/openai/test_openai_schema.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,51 @@ def get_schema(server):
4242
schema = schemathesis.from_pytest_fixture("get_schema")
4343

4444

45+
@schemathesis.hook
46+
def before_generate_case(context: schemathesis.hooks.HookContext, strategy):
47+
op = context.operation
48+
assert op is not None
49+
50+
def no_file_type(case: schemathesis.models.Case):
51+
"""
52+
This filter skips test cases for the `POST /tokenize` endpoint where the
53+
HTTP request body uses `"type": "file"` in any message's content.
54+
We expect these cases to fail because that type isn't implemented here
55+
https://github.com/vllm-project/vllm/blob/0b34593017953051b3225b1483ce0f4670e3eb0e/vllm/entrypoints/chat_utils.py#L1038-L1095
56+
57+
Example test cases that are skipped:
58+
curl -X POST -H 'Content-Type: application/json' \
59+
-d '{"messages": [{"role": "assistant"}, {"content": [{"file": {}, "type": "file"}], "role": "user"}]}' \
60+
http://localhost:8000/tokenize
61+
62+
curl -X POST -H 'Content-Type: application/json' \
63+
-d '{"messages": [{"content": [{"file": {}, "type": "file"}], "role": "user"}]}' \
64+
http://localhost:8000/tokenize
65+
""" # noqa: E501
66+
if op.method.lower() != "post" or op.path != "/tokenize":
67+
return True
68+
69+
if case.body is not None and isinstance(case.body, dict):
70+
if "messages" not in case.body:
71+
return True
72+
73+
messages = case.body.get("messages", [])
74+
if not isinstance(messages, list) or len(messages) == 0:
75+
return True
76+
77+
for message in messages:
78+
if not isinstance(message, dict):
79+
continue
80+
content = message.get("content", [])
81+
if not isinstance(content, list) or len(content) == 0:
82+
continue
83+
if any(item.get("type") == "file" for item in content):
84+
return False
85+
return True
86+
87+
return strategy.filter(no_file_type)
88+
89+
4590
@schema.parametrize()
4691
@schema.override(headers={"Content-Type": "application/json"})
4792
def test_openapi_stateless(case: schemathesis.Case):

0 commit comments

Comments
 (0)