server: tests: allow to override the server port before launching tests

This commit is contained in:
Pierrick HYMBERT 2024-02-23 01:59:29 +01:00
parent 70e90558ae
commit 2f756f84df
4 changed files with 12 additions and 2 deletions

View file

@ -50,4 +50,4 @@ jobs:
id: server_integration_test
run: |
cd examples/server/tests
./tests.sh
PORT=8888 ./tests.sh

View file

@ -11,6 +11,10 @@ Server tests scenario using [BDD](https://en.wikipedia.org/wiki/Behavior-driven_
1. `../../../scripts/hf.sh --repo ggml-org/models --file tinyllamas/stories260K.gguf`
3. Start the test: `./tests.sh`
It's possible to override some scenario steps values with environment variables:
- `$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/server`
To change the server path, use `LLAMA_SERVER_BIN_PATH` environment variable.
### Skipped scenario

View file

@ -8,7 +8,10 @@ from signal import SIGKILL
def before_scenario(context, scenario):
if is_server_listening("localhost", 8080):
port = 8080
if 'PORT' in os.environ:
port = int(os.environ['PORT'])
if is_server_listening("localhost", port):
assert False, "Server already started"

View file

@ -19,6 +19,9 @@ from behave.api.async_step import async_run_until_complete
def step_server_config(context, server_fqdn, server_port):
context.server_fqdn = server_fqdn
context.server_port = int(server_port)
if 'PORT' in os.environ:
context.server_port = int(os.environ['PORT'])
print(f"$PORT set, overriding server port with to {context.server_port}")
context.base_url = f'http://{context.server_fqdn}:{context.server_port}'