]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
tests : speed-up server test suite 3x (#26734)
authorGeorgi Gerganov <redacted>
Fri, 7 Aug 2026 18:38:32 +0000 (21:38 +0300)
committerGitHub <redacted>
Fri, 7 Aug 2026 18:38:32 +0000 (21:38 +0300)
* tests : speed-up test suite 3x

* cont : print 30 slowest tests

tools/server/tests/conftest.py
tools/server/tests/tests.sh
tools/server/tests/unit/test_router.py
tools/server/tests/utils.py

index c7ed775968bdd9b66fdf1c654bc435a90afcaf03..5dfde4079678bd218ae0d0ce9586c0c3154b790d 100644 (file)
@@ -15,7 +15,7 @@ def stop_server_after_each_test():
         server.stop()
 
 
-@pytest.fixture(scope="module", autouse=True)
-def do_something():
+@pytest.fixture(scope="session", autouse=True)
+def load_server_presets():
     # this will be run once per test session, before any tests
     ServerPreset.load_all()
index 709b5841aa49b1d8ac4fcf2e5b52f0a68564c23a..8d6681193db39a219fe14ddf72c40df094bea2f7 100755 (executable)
@@ -14,10 +14,10 @@ fi
 if [ $# -lt 1 ]
 then
     if [[ "${SLOW_TESTS:-0}" == 1 ]]; then
-        pytest -v -x
+        pytest --durations=30 -v -x
     else
-        pytest -v -x -m "not slow"
+        pytest --durations=30 -v -x -m "not slow"
     fi
 else
-    pytest "$@"
+    pytest --durations=30 "$@"
 fi
index c503ee342047b3d590fadbe3eabea6139993850e..5ab62666ce18fd5f470f24c25f0509c234ff7ef4 100644 (file)
@@ -85,7 +85,7 @@ def _wait_for_model_status(model_id: str, desired: set[str], timeout: int = 60)
         last_status = _get_model_status(model_id)
         if last_status in desired:
             return last_status
-        time.sleep(1)
+        time.sleep(0.01)
     raise AssertionError(
         f"Timed out waiting for {model_id} to reach {desired}, last status: {last_status}"
     )
@@ -460,7 +460,7 @@ def _wait_for_sse_event(collected: list, event_type: str, model: str, timeout: i
     while time.time() < deadline:
         if any(e.get("event") == event_type and e.get("model") == model for e in collected):
             return True
-        time.sleep(0.5)
+        time.sleep(0.01)
     return False
 
 
index 8f3a98642478c3da51b13cf7f5c5863f161cbf36..3416f0bfde4236a2865d0c46774100950efa2832 100644 (file)
@@ -306,6 +306,7 @@ class ServerProcess:
 
         # wait for server to start
         start_time = time.time()
+        last_print_time = start_time
         while time.time() - start_time < timeout_seconds:
             try:
                 response = self.make_request("GET", "/health", headers={
@@ -320,8 +321,10 @@ class ServerProcess:
             if self.process.poll() is not None:
                 raise RuntimeError(f"Server process died with return code {self.process.returncode}")
 
-            print(f"Waiting for server to start...")
-            time.sleep(0.5)
+            if time.time() - last_print_time >= 1.0:
+                print(f"Waiting for server to start...")
+                last_print_time = time.time()
+            time.sleep(0.01)
         raise TimeoutError(f"Server did not start within {timeout_seconds} seconds")
 
     def stop(self) -> None: