diff --git a/.github/workflows/server-test.yml b/.github/workflows/server-test.yml index a4242ea12..7c56ebb8d 100644 --- a/.github/workflows/server-test.yml +++ b/.github/workflows/server-test.yml @@ -50,4 +50,4 @@ jobs: id: server_integration_test run: | cd examples/server/tests - ./tests.sh + PORT=8888 ./tests.sh diff --git a/examples/server/tests/README.md b/examples/server/tests/README.md index 5e5da6ff8..1892bafc9 100644 --- a/examples/server/tests/README.md +++ b/examples/server/tests/README.md @@ -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 diff --git a/examples/server/tests/features/environment.py b/examples/server/tests/features/environment.py index e84acfe77..652b4f30c 100644 --- a/examples/server/tests/features/environment.py +++ b/examples/server/tests/features/environment.py @@ -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" diff --git a/examples/server/tests/features/steps/steps.py b/examples/server/tests/features/steps/steps.py index adb7a0119..a5a516252 100644 --- a/examples/server/tests/features/steps/steps.py +++ b/examples/server/tests/features/steps/steps.py @@ -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}'