server: tests: allow to override the server port before launching tests
This commit is contained in:
parent
70e90558ae
commit
2f756f84df
4 changed files with 12 additions and 2 deletions
2
.github/workflows/server-test.yml
vendored
2
.github/workflows/server-test.yml
vendored
|
@ -50,4 +50,4 @@ jobs:
|
||||||
id: server_integration_test
|
id: server_integration_test
|
||||||
run: |
|
run: |
|
||||||
cd examples/server/tests
|
cd examples/server/tests
|
||||||
./tests.sh
|
PORT=8888 ./tests.sh
|
||||||
|
|
|
@ -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`
|
1. `../../../scripts/hf.sh --repo ggml-org/models --file tinyllamas/stories260K.gguf`
|
||||||
3. Start the test: `./tests.sh`
|
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.
|
To change the server path, use `LLAMA_SERVER_BIN_PATH` environment variable.
|
||||||
|
|
||||||
### Skipped scenario
|
### Skipped scenario
|
||||||
|
|
|
@ -8,7 +8,10 @@ from signal import SIGKILL
|
||||||
|
|
||||||
|
|
||||||
def before_scenario(context, scenario):
|
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"
|
assert False, "Server already started"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,9 @@ from behave.api.async_step import async_run_until_complete
|
||||||
def step_server_config(context, server_fqdn, server_port):
|
def step_server_config(context, server_fqdn, server_port):
|
||||||
context.server_fqdn = server_fqdn
|
context.server_fqdn = server_fqdn
|
||||||
context.server_port = int(server_port)
|
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}'
|
context.base_url = f'http://{context.server_fqdn}:{context.server_port}'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue