Four probes were written from a blank file and each re-learned the same lessons by losing a run: that a flat run cannot be told from a frozen guest without a stall witness, that results held to the end of a run are destroyed by a turn timeout, that a roster count which is not the stage's member count means a different stage loaded and must be discarded, and that a run's witness state has to be read before its numbers. Writing each lesson down did not stop the next probe repeating it, because each probe started from nothing. probeharness.py makes them structural. Probe(baseline=N) discovers the roster, rescans up to five times and refuses to start if the count never reaches the baseline. The witness is calibrated on construction, sampled by tick() and reported by status() and summary(), so a probe cannot forget it, and when no witness is found it reports UNVALIDATED rather than zero stalls. emit() flushes on every line. craft(), strengths(), alive() and heap() supply the roster-to-craft link, per-record liveness and the raw heap, so a new probe writes only its own logic. Verified rather than asserted: deploy_probe.py reimplements the per-record deployment watch on top of it in about forty lines against wave7_probe's hundred and fifty, and its first live run was clean -- 116 roster records, 32 witnesses at 10/s, zero stalled samples, seven losses tracked, and the TSV written incrementally. Nothing about the result is new, which is the point: the harness reproduces a known-good measurement. The existing probes are deliberately not ported. They work, and rewriting them would risk changing results other documents cite. New probes should use the harness; old ones should be ported when they next need a change.
45 lines
1.7 KiB
Python
Executable File
45 lines
1.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Per-record deployment watch, built on the shared harness.
|
|
|
|
Replaces wave7_probe.py's hand-rolled setup. Everything that used to be
|
|
re-invented per probe -- roster discovery, the baseline discard rule, the craft
|
|
link, the stall witness, incremental output -- comes from `probeharness.Probe`.
|
|
"""
|
|
import collections, sys
|
|
sys.path.insert(0, __file__.rsplit('/', 1)[0])
|
|
from probeharness import Probe
|
|
|
|
def main():
|
|
secs = int(sys.argv[1]) if len(sys.argv) > 1 else 300
|
|
every = int(sys.argv[2]) if len(sys.argv) > 2 else 15
|
|
base = int(sys.argv[3]) if len(sys.argv) > 3 else 116
|
|
|
|
p = Probe(baseline=base, tsv='/tmp/deploy.tsv')
|
|
if not p.ok:
|
|
print(p.why)
|
|
return 3
|
|
print(p.summary(), flush=True)
|
|
p.log('t\tdeployed\tcraft\tstalled')
|
|
|
|
prev = p.strengths()
|
|
print('t= 0s deployed=%d strengths %s'
|
|
% (len(prev), sorted(collections.Counter(prev.values()).items())), flush=True)
|
|
ups = downs = 0
|
|
while p.tick(every, secs):
|
|
cur = p.strengths()
|
|
up = [(o, prev.get(o, 0), cur[o]) for o in cur if cur[o] > prev.get(o, 0)]
|
|
down = [(o, prev[o], cur.get(o, 0)) for o in prev if cur.get(o, 0) < prev[o]]
|
|
ups += len(up); downs += len(down)
|
|
print('t=%4ds deployed=%d up=%d down=%d (cum %d/%d)%s'
|
|
% (p.elapsed, len(cur), len(up), len(down), ups, downs, p.status()),
|
|
flush=True)
|
|
p.emit('%d\t%d\t%d\t%s'
|
|
% (p.elapsed, len(cur), sum(cur.values()), p.status().strip()))
|
|
prev = cur
|
|
print('\n%s' % p.summary())
|
|
print('TOTAL up=%d down=%d' % (ups, downs))
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|