Preserve diagnostic receipts and resume bounded cost experiments
This commit is contained in:
@@ -3,6 +3,7 @@ import concurrent.futures
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import statistics
|
||||
import subprocess
|
||||
@@ -99,7 +100,7 @@ def run_profile(client, profile, repeat):
|
||||
before = telemetry_snapshot(instance_ids)
|
||||
memory_before = cgroups(['api','worker','collector','tempo'])
|
||||
compose('exec','-T','postgres','psql','-U','messenger','-d','messenger','-c',
|
||||
"INSERT INTO test_faults(point,action) VALUES ('after_upload_commit','error'),('after_upload_commit','error')")
|
||||
"DELETE FROM test_faults WHERE point='after_upload_commit' AND reached_at IS NULL; INSERT INTO test_faults(point,action) VALUES ('after_upload_commit','error'),('after_upload_commit','error')")
|
||||
calls = []
|
||||
dropped = 0
|
||||
lock_future = None
|
||||
@@ -132,7 +133,7 @@ def run_profile(client, profile, repeat):
|
||||
for future in ready:
|
||||
calls.append(future.result())
|
||||
pending.remove(future)
|
||||
if len(pending) >= 15:
|
||||
if len(pending) >= 15 and index not in (80,240):
|
||||
dropped += 1
|
||||
else:
|
||||
pending.add(executor.submit(request,index))
|
||||
@@ -141,7 +142,9 @@ def run_profile(client, profile, repeat):
|
||||
if lock_future:
|
||||
lock_future.result()
|
||||
elapsed = time.monotonic()-started
|
||||
assert sum(x['status']==500 for x in calls)==2, 'Expected exactly two controlled upload errors'
|
||||
if sum(x['status']==500 for x in calls)!=2:
|
||||
(ROOT/'evidence/cost-failed-requests.json').write_text(json.dumps({'profile':name,'repeat':repeat,'not_sent':dropped,'requests':calls},indent=2))
|
||||
raise AssertionError('Expected two controlled upload errors; statuses='+str({status:sum(x['status']==status for x in calls) for status in {x['status'] for x in calls}}))
|
||||
assert all(x['status'] in (200,500) for x in calls), 'Unexpected business failure'
|
||||
time.sleep(10)
|
||||
after = telemetry_snapshot(instance_ids)
|
||||
@@ -177,11 +180,19 @@ def main():
|
||||
'baseline':'40 warmup requests at 10/s, then10s silence; direct Collector endpoints avoid Prometheus scrape delay',
|
||||
'post_window':'10s silence before direct Collector counters; bytes include periodic metric exports in observation window',
|
||||
'resources':'same image/CPU/RAM; sequential profiles, all services on one Docker host'}}
|
||||
result_path = ROOT/'evidence/observability-cost.json'
|
||||
if '--resume' in sys.argv and result_path.exists():
|
||||
previous = json.loads(result_path.read_text())
|
||||
assert previous['method']['rare_slow'] == report['method']['rare_slow']
|
||||
report = previous
|
||||
completed = {(row['profile'], row['repeat']) for row in report['runs']}
|
||||
client = Client()
|
||||
try:
|
||||
for repeat in range(1,4):
|
||||
order = PROFILES[repeat-1:]+PROFILES[:repeat-1]
|
||||
for profile in order:
|
||||
if (profile[0],repeat) in completed:
|
||||
continue
|
||||
row = run_profile(client,profile,repeat)
|
||||
report['runs'].append(row)
|
||||
(ROOT/'evidence/observability-cost.json').write_text(json.dumps(report,indent=2))
|
||||
|
||||
Reference in New Issue
Block a user