Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Dec 10, 2024
1 parent 023baf8 commit 7747225
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/server/tests/unit/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import requests
from utils import *

server = ServerPreset.tinyllama2()
Expand Down Expand Up @@ -76,3 +77,19 @@ def test_load_split_model():
})
assert res.status_code == 200
assert match_regex("(little|girl)+", res.body["content"])


def test_no_webui():
global server
# default: webui enabled
server.start()
url = f"http://{server.server_host}:{server.server_port}"
res = requests.get(url)
assert res.status_code == 200
assert "<html>" in res.text

# with --no-webui
server.no_webui = True
server.start()
res = requests.get(url)
assert res.status_code == 404
3 changes: 3 additions & 0 deletions examples/server/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ServerProcess:
disable_ctx_shift: int | None = False
draft_min: int | None = None
draft_max: int | None = None
no_webui: bool | None = None

# session variables
process: subprocess.Popen | None = None
Expand Down Expand Up @@ -158,6 +159,8 @@ def start(self, timeout_seconds: int = 10) -> None:
server_args.extend(["--draft-max", self.draft_max])
if self.draft_min:
server_args.extend(["--draft-min", self.draft_min])
if self.no_webui:
server_args.append("--no-webui")

args = [str(arg) for arg in [server_path, *server_args]]
print(f"bench: starting server with: {' '.join(args)}")
Expand Down

0 comments on commit 7747225

Please sign in to comment.