feat: confirm model readiness during native service installation (#38)
This commit is contained in:
@@ -241,6 +241,13 @@ exit {42 if fail_action else 0}
|
||||
except urllib.error.HTTPError as error:
|
||||
assert error.code == 503
|
||||
error.close()
|
||||
# Installer readiness is bounded and never treats no-worker health as ready.
|
||||
before=ctl('show','--property=MainPID','--value',unit_name).stdout.strip()
|
||||
bad=run(*install_args,'--start-ready','--ready-url',f'http://127.0.0.1:{port}',
|
||||
'--ready-model','service-smoke-env','--ready-timeout-s','1',check=False)
|
||||
assert bad.returncode!=0 and 'retained' in bad.stderr,bad.stderr
|
||||
assert link.read_text()==generated
|
||||
assert ctl('show','--property=MainPID','--value',unit_name).stdout.strip()==before
|
||||
def native_ctl(action):
|
||||
result = run(str(binary), 'service-control', action, *install_args[2:], check=False)
|
||||
assert result.returncode == 0, (action, result.stderr, ctl('show', '--property=NeedDaemonReload', '--property=UnitFileState', unit_name).stdout)
|
||||
@@ -322,10 +329,22 @@ exit {42 if fail_action else 0}
|
||||
value = json.load(response)
|
||||
assert value['status'] == 'completed', value
|
||||
assert value['output'][0]['content'][0]['text'] == 'A', value
|
||||
first = json.loads(ready_control('start-ready').stdout)
|
||||
# Recreate only the stopped owned fixture to prove fresh install+ready.
|
||||
assert native_ctl('status')['manager']['main_pid']==0
|
||||
assert link.read_text()==generated
|
||||
link.unlink();ctl('daemon-reload')
|
||||
bad=run(*install_args,'--start-ready',*ready_args[:4],
|
||||
'--ready-key-file',str(root/'missing-key'),check=False)
|
||||
assert bad.returncode!=0 and not link.exists()
|
||||
first=json.loads(run(*install_args,'--start-ready',*ready_args).stdout)
|
||||
assert first['created'] and first['start_requested']
|
||||
|
||||
pid = first['manager']['main_pid']
|
||||
assert first['model_readiness'] == 'ready' and first['readiness']['server_pid'] == pid
|
||||
inference()
|
||||
repeated=json.loads(run(*install_args,'--start-ready',*ready_args).stdout)
|
||||
assert repeated['reused'] and repeated['manager']['main_pid']==pid
|
||||
assert repeated['readiness']['server_pid']==pid
|
||||
assert json.loads(ready_control('start-ready').stdout)['manager']['main_pid'] == pid
|
||||
for bad_options in [ready_args + ['--ready-timeout-s', '0'],
|
||||
ready_args[:4] + ['--ready-key-file', str(root/'missing-key')]]:
|
||||
@@ -416,6 +435,7 @@ exit {42 if fail_action else 0}
|
||||
assert stopped['manager']['main_pid']==0 and stopped['admission']['drained']
|
||||
print('Managed drain-stop/resume passed: active and queued exact A before stop, new admission blocked, timeout preserves process and work, explicit same-PID resume, idle drain-stop')
|
||||
native_ctl('stop')
|
||||
print('Native install-ready passed: fresh authenticated ready install, same PID/A reuse, invalid key before publication, unconfigured timeout leaves service unchanged')
|
||||
print('Managed start-ready/restart-ready passed: authenticated exact PID, cold/reuse/restart, exact A, invalid inputs before mutation, wrong endpoint refusal, bounded timeout without replay')
|
||||
print('Native systemd install/reuse/conflict/lifecycle passed: literal paths, explicit config, environment, health/readiness plus native status/start/restart/stop/reuse, opt-in enable/disable PID preservation and identity/link refusal')
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user