57 lines
2.4 KiB
Python
57 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Run the repository's scripted-engine HTTP smokes through the Rust runtime stack.
|
|
|
|
cargo build -p leleka-control-plane --bin leleka-api
|
|
cargo build -p leleka-engine-host --example fake_runtime
|
|
python3 scripts/test-api-over-runtime.py target/debug/leleka-api target/debug/examples/fake_runtime
|
|
|
|
Each smoke keeps its own assertions; only the engine moves. Normally the smoke's scripted `engine.sh` is
|
|
leleka-api's child process speaking token ids on stdio. With STRATA_TEST_FAKE_RUNTIME set (done here) the
|
|
smoke starts `fake_runtime` instead: a real `leleka.runtime.v1` gRPC server (`RuntimeServer`) whose engine
|
|
is the same `engine.sh`, and runs `leleka-api` with a `runtime` block, so the HTTP API is exercised in
|
|
front of text-in/text-out gRPC. Test tooling only; nothing here is part of serving. Not a GPU or model result.
|
|
"""
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
SMOKES = [
|
|
'test-live-responses-replay', # replay driver: SSE verifier, tool episode, corrupted-stream rejection
|
|
'smoke-custom-tools',
|
|
'smoke-chat-completions',
|
|
'smoke-messages',
|
|
'smoke-tool-policy', # 216 tool_choice / parallel_tool_calls / allowed_tools cases
|
|
'smoke-input-tokens',
|
|
'smoke-response-history', # stored responses, previous_response_id, restart of leleka-api
|
|
'smoke-sse-keepalive',
|
|
'smoke-native-drain',
|
|
'smoke-queue-deadline',
|
|
]
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) != 3:
|
|
sys.exit(__doc__)
|
|
binary, fake = (str(Path(arg).resolve()) for arg in sys.argv[1:])
|
|
scripts = Path(__file__).parent
|
|
env = dict(os.environ, STRATA_TEST_FAKE_RUNTIME=fake)
|
|
failed = []
|
|
for name in SMOKES:
|
|
started = time.monotonic()
|
|
result = subprocess.run([sys.executable, str(scripts / f'{name}.py'), binary], env=env,
|
|
capture_output=True, text=True, timeout=900)
|
|
seconds = time.monotonic() - started
|
|
print(f"{'PASS' if result.returncode == 0 else 'FAIL'} {name} ({seconds:.1f}s)", flush=True)
|
|
if result.returncode != 0:
|
|
failed.append(name)
|
|
print(result.stdout[-2000:], result.stderr[-2000:], sep='\n')
|
|
if failed:
|
|
sys.exit(f'{len(failed)} of {len(SMOKES)} failed: {", ".join(failed)}')
|
|
print(f'all {len(SMOKES)} smokes passed through the runtime stack')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|