Signed-off-by: amy-why-3459 <wuhaiyan17@huawei.com>
This commit is contained in:
1 parent
eb1abbadf8
commit
882bf8bc95
53 files changed
+3438
-633
No files matched your search
@@ -1,3 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import sys
|
||||
@@ -70,7 +73,12 @@ def test_build_app_injects_public_realtime_url():
|
||||
def test_build_app_versions_client_bundle_and_disables_index_cache():
|
||||
client = TestClient(build_app())
|
||||
expected_version_hash = hashlib.sha256()
|
||||
for asset_name in ("app.js", "pcm_worklet.js", "playback_worklet.js"):
|
||||
for asset_name in (
|
||||
"app.js",
|
||||
"pcm_worklet.js",
|
||||
"playback_worklet.js",
|
||||
*[str(p.relative_to(STATIC_DIR)) for p in sorted((STATIC_DIR / "profiles").glob("*.js"))],
|
||||
):
|
||||
expected_version_hash.update((STATIC_DIR / asset_name).read_bytes())
|
||||
expected_version = expected_version_hash.hexdigest()[:12]
|
||||
|
||||
@@ -97,3 +105,41 @@ def test_build_app_exposes_realtime_websocket_and_static_assets():
|
||||
assert client.get("/static/app.js").status_code == 200
|
||||
assert client.get("/static/pcm_worklet.js").status_code == 200
|
||||
assert client.get("/static/playback_worklet.js").status_code == 200
|
||||
|
||||
|
||||
def test_qwen_config_does_not_inject_reference_voice():
|
||||
client = TestClient(build_app(profile="qwen3-turn", adapter="vad", model="Qwen/Qwen3-Omni-30B-A3B-Instruct"))
|
||||
page = client.get("/").text
|
||||
assert '"profile": "qwen3-turn"' in page
|
||||
assert '"adapter": "vad"' in page
|
||||
assert '"refAudio": null' in page
|
||||
for name in ("common", "minicpm_native", "qwen3_turn"):
|
||||
assert client.get(f"/static/profiles/{name}.js").status_code == 200
|
||||
with pytest.raises(ValueError, match="ref-audio"):
|
||||
build_app(profile="qwen3-turn", ref_audio="unused.wav")
|
||||
|
||||
|
||||
def test_config_cannot_close_its_script_element():
|
||||
page = TestClient(build_app(model="</script><script>alert(1)</script>")).get("/").text
|
||||
assert "</script><script>alert(1)" not in page
|
||||
assert "\\u003c/script>" in page
|
||||
|
||||
|
||||
def test_proxy_reports_unreachable_backend(monkeypatch):
|
||||
from examples.online_serving.realtime_web import server as shared_server
|
||||
|
||||
class RefusedConnection:
|
||||
async def __aenter__(self):
|
||||
raise ConnectionRefusedError(111, "Connection refused")
|
||||
|
||||
async def __aexit__(self, *args):
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(shared_server.websockets, "connect", lambda *args, **kwargs: RefusedConnection())
|
||||
client = TestClient(build_app(ws_backend="ws://127.0.0.1:8091"))
|
||||
with client.websocket_connect("/v1/realtime?duplex=0") as ws:
|
||||
event = ws.receive_json()
|
||||
assert event["type"] == "error"
|
||||
assert event["code"] == "backend_unavailable"
|
||||
assert "ws://127.0.0.1:8091" in event["error"]
|
||||
assert "--port" in event["error"]
|
||||
Reference in new issue
Block a user