llama-stack-mirror/tests/api
ehhuang 07a992ef90
feat: deterministic tools ordering (#1380)
Summary:

1. The `tools` parameter we construct to pass the inference API is
non-deterministic. As a result, our recordable mocks is flaky as the
ordering change sometimes. This PR makes it so that `tools` ordering is
deterministic and aligned with the order user specified.
2. In recordable mock key generation, client tool's parameter type was
'str' and now is 'string' for some reason. I didn't dig into exactly
why, but just regenerated the fixtures.

Test Plan:
Regenerate mocks:
```
LLAMA_STACK_CONFIG=fireworks pytest -s -v tests/client-sdk/agents/test_agents.py --safety-shield meta-llama/Llama-Guard-3-8B --record-responses
```

Rerun tests without  --record-responses:
```
LLAMA_STACK_CONFIG=fireworks pytest -s -v tests/client-sdk/agents/test_agents.py --safety-shield meta-llama/Llama-Guard-3-8B
```
2025-03-03 20:38:07 -08:00
..
agents refactor: move tests/client-sdk to tests/api (#1376) 2025-03-03 17:28:12 -08:00
fixtures feat: deterministic tools ordering (#1380) 2025-03-03 20:38:07 -08:00
inference refactor: move tests/client-sdk to tests/api (#1376) 2025-03-03 17:28:12 -08:00
safety refactor: move tests/client-sdk to tests/api (#1376) 2025-03-03 17:28:12 -08:00
tool_runtime refactor: move tests/client-sdk to tests/api (#1376) 2025-03-03 17:28:12 -08:00
vector_io refactor: move tests/client-sdk to tests/api (#1376) 2025-03-03 17:28:12 -08:00
__init__.py refactor: move tests/client-sdk to tests/api (#1376) 2025-03-03 17:28:12 -08:00
conftest.py fix: fix bugs in relative imports exposed due to dir move 2025-03-03 19:42:45 -08:00
metadata.py refactor: move tests/client-sdk to tests/api (#1376) 2025-03-03 17:28:12 -08:00
README.md refactor: move tests/client-sdk to tests/api (#1376) 2025-03-03 17:28:12 -08:00
report.py fix: fix bugs in relative imports exposed due to dir move 2025-03-03 19:42:45 -08:00

Llama Stack Integration Tests

You can run llama stack integration tests on either a Llama Stack Library or a Llama Stack endpoint.

To test on a Llama Stack library with certain configuration, run

LLAMA_STACK_CONFIG=./llama_stack/templates/cerebras/run.yaml pytest -s -v tests/api/inference/

or just the template name

LLAMA_STACK_CONFIG=together pytest -s -v tests/api/inference/

To test on a Llama Stack endpoint, run

LLAMA_STACK_BASE_URL=http://localhost:8089 pytest -s -v tests/api/inference

Report Generation

To generate a report, run with --report option

LLAMA_STACK_CONFIG=together pytest -s -v report.md tests/api/ --report

Common options

Depending on the API, there are custom options enabled

  • For tests in inference/ and agents/, we support --inference-model(to be used in text inference tests) and--vision-inference-model` (only used in image inference tests) overrides
  • For tests in vector_io/, we support --embedding-model override
  • For tests in safety/, we support --safety-shield override
  • The param can be --report or --report <path> If path is not provided, we do a best effort to infer based on the config / template name. For url endpoints, path is required.