51 lines
2.1 KiB
Python
51 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Exercise the actual CLI-only scratch image; never starts an inference worker."""
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
import time
|
|
import uuid
|
|
import subprocess
|
|
from docker_smoke_http import ISOLATION, docker, prepare_probe, request
|
|
|
|
|
|
def main(image):
|
|
name = 'strata-cli-smoke-' + uuid.uuid4().hex
|
|
common = ['--name', name, *ISOLATION]
|
|
root = Path(__file__).resolve().parents[1]
|
|
prepare_probe()
|
|
|
|
try:
|
|
version = docker('run', '--rm', *common, '--network', 'none', image, '--version').stdout
|
|
assert version.startswith('strata-next '), version
|
|
license_text = docker('run', '--rm', *common, '--network', 'none', image,
|
|
'--engine-license').stdout
|
|
assert license_text == (root / 'engine/strata/LICENSE').read_text()
|
|
info = json.loads(docker('run', '--rm', *common, '--network', 'none', image,
|
|
'engine-info').stdout)
|
|
assert info['embedded'] is False and info['model_bundled'] is False, info
|
|
docker('run', '-d', *common, '--network', 'none',
|
|
'-e', 'STRATA_BIND=127.0.0.1:8081', image, 'serve')
|
|
deadline = time.monotonic() + 15
|
|
while True:
|
|
try:
|
|
assert request(name, '/health') == (200, {'status': 'ok'})
|
|
break
|
|
except (OSError, AssertionError, subprocess.CalledProcessError):
|
|
if time.monotonic() >= deadline:
|
|
raise
|
|
time.sleep(0.1)
|
|
status, ready = request(name, '/ready')
|
|
assert status == 503 and ready['ready'] is False, (status, ready)
|
|
docker('stop', '--time', '10', name)
|
|
state = json.loads(docker('inspect', '--format', '{{json .State}}', name).stdout)
|
|
assert state['ExitCode'] == 0 and not state['OOMKilled'], state
|
|
print('CLI OCI passed: actual image, exact upstream license, no embedded engine/model, '
|
|
'non-root read-only health200/ready503, graceful stop. No GPU inference qualified.')
|
|
finally:
|
|
docker('rm', '-f', name, check=False)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv[1])
|