Commit 5a0e101
authored
test(messages): add live Claude Code CLI smoke test against /v1/messages (#5986)
## What
Adds a smoke test that drives the **real** `@anthropic-ai/claude-code`
CLI against a local OGX server, verifying the Messages API works
end-to-end with the actual client. The CLI emits its full system prompt,
tool definitions, and an inline `system`-role message — all of which OGX
must accept and dispatch to the backing provider.
This is the upstream automated coverage for the Claude Code ↔
`/v1/messages` integration (RHAIENG-5376).
## Why live, not replay
The recording/replay system keys recordings on a SHA256 of the request
body. The Claude Code CLI bakes the **working directory, the date, and
the platform** into every request (its system prompt includes all
three), so those hashes are **not reproducible** across runs or
machines:
- random `tmp_path` cwd → different hash every run
- date changes daily → recordings rot
- recorded on macOS, CI runs Linux → platform string differs
So hash-based replay is fundamentally unworkable for the real CLI. The
test runs **live against Ollama** (native passthrough) instead, in a
dedicated workflow that provisions Ollama. OpenAI/translation is
intentionally excluded to avoid live OpenAI calls on every PR.
## What it asserts
Integration health, not answer quality. A small local model driving the
Claude Code harness can't be relied on to produce a specific reply, but
the test confirms via `--output-format json` that:
- the CLI exits 0,
- the session completed with no API error (`is_error: false`, `subtype:
success`),
- the request actually reached the backing model (`modelUsage` contains
the model id).
A regression such as a rejected `system`-role message (cf. #5982)
surfaces as a CLI API error and is caught here. The test self-skips
unless the `claude` binary is on PATH.
> Depends on #5982's fix (merged), which taught `/v1/messages` to accept
inline `system`-role messages.
## Test plan
- Ran live locally against Ollama (`ollama/llama3.2:3b-instruct-fp16`,
native passthrough): **passed**.
```
./scripts/integration-tests.sh --stack-config server:ci-tests \
--setup ollama --suite messages --inference-mode live \
--pattern test_claude_code_cli_smoke
```
- `pre-commit run` — ruff, mypy, generate-ci-docs, SHA-pinned-actions
checks pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: Charlie Doern <cdoern@redhat.com>1 parent 4af4d0a commit 5a0e101
3 files changed
Lines changed: 171 additions & 0 deletions
File tree
- .github/workflows
- tests/integration/messages
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
0 commit comments