llama.cpp/examples/server/tests
Michelle Tan 89d604f2c8
Some checks are pending
flake8 Lint / Lint (push) Waiting to run
Python Type-Check / pyright type-check (push) Waiting to run
server: Fix has_next_line in JSON response (#10818)
* Update server JSON response.

* Add unit test to check `has_new_line` JSON response

* Remove `has_new_line` unit test changes.

* Address code review comment: type check for `has_new_line` in unit test
2024-12-14 23:29:45 +01:00
..
unit server: Fix has_next_line in JSON response (#10818) 2024-12-14 23:29:45 +01:00
.gitignore server : replace behave with pytest (#10416) 2024-11-26 16:20:18 +01:00
conftest.py server : replace behave with pytest (#10416) 2024-11-26 16:20:18 +01:00
README.md server : (refactoring) do not rely on JSON internally (#10643) 2024-12-06 11:14:32 +01:00
requirements.txt server : (tests) don't use thread for capturing stdout/stderr, bump openai client library (#10568) 2024-11-28 19:17:49 +01:00
tests.sh server : (refactoring) do not rely on JSON internally (#10643) 2024-12-06 11:14:32 +01:00
utils.py server : add flag to disable the web-ui (#10762) (#10751) 2024-12-10 18:22:34 +01:00

Server tests

Python based server tests scenario using pytest.

Tests target GitHub workflows job runners with 4 vCPU.

Note: If the host architecture inference speed is faster than GitHub runners one, parallel scenario may randomly fail. To mitigate it, you can increase values in n_predict, kv_size.

Install dependencies

pip install -r requirements.txt

Run tests

  1. Build the server
cd ../../..
cmake -B build -DLLAMA_CURL=ON
cmake --build build --target llama-server
  1. Start the test: ./tests.sh

It's possible to override some scenario steps values with environment variables:

variable description
PORT context.server_port to set the listening port of the server during scenario, default: 8080
LLAMA_SERVER_BIN_PATH to change the server binary path, default: ../../../build/bin/llama-server
DEBUG to enable steps and server verbose mode --verbose
N_GPU_LAYERS number of model layers to offload to VRAM -ngl --n-gpu-layers

To run slow tests:

SLOW_TESTS=1 ./tests.sh

To run with stdout/stderr display in real time (verbose output, but useful for debugging):

DEBUG=1 ./tests.sh -s -v -x

Hint: You can compile and run test in single command, useful for local developement:

cmake --build build -j --target llama-server && ./examples/server/tests/tests.sh

To see all available arguments, please refer to pytest documentation