Files
leleka/scripts/smoke-cli-container.py
T
Pavlo Ratushnyi 4013e0c9bd
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
Import tracked Strata Next source snapshot
2026-10-05 18:15:08 +02:00

68 lines
2.8 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 subprocess
import sys
import time
import urllib.error
import urllib.request
import uuid
def docker(*args, check=True):
return subprocess.run(['docker', *args], check=check, capture_output=True,
text=True, timeout=30)
def main(image):
name = 'strata-cli-smoke-' + uuid.uuid4().hex
common = ['--name', name, '--read-only', '--user', '65532:65532',
'--cap-drop', 'ALL', '--security-opt', 'no-new-privileges']
root = Path(__file__).resolve().parents[1]
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
def get(port, route):
try:
with opener.open(f'http://127.0.0.1:{port}{route}', timeout=2) as response:
return response.status, json.load(response)
except urllib.error.HTTPError as error:
return error.code, json.load(error)
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, '-p', '127.0.0.1::8081',
'-e', 'STRATA_BIND=0.0.0.0:8081', image, 'serve')
binding = docker('port', name, '8081/tcp').stdout.strip()
assert binding.startswith('127.0.0.1:'), binding
port = int(binding.rsplit(':', 1)[1])
deadline = time.monotonic() + 15
while True:
try:
assert get(port, '/health') == (200, {'status': 'ok'})
break
except (OSError, AssertionError):
if time.monotonic() >= deadline:
raise
time.sleep(0.1)
status, ready = get(port, '/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])