Tie the track tooling to keys, sets and a clean series
reconcile-inject.sh wrote an orphan under a key whose uuid differed from the id it printed, so the demo could only compare counts; it now uses one uuid for both, and the dry-run check compares the found and the injected sets per class. The heal step returns the original bytes under one quarantined key and random bytes of the same length under another, and checks that only the first leaves the quarantine. The load phase sums rechecked over its passes, and a new step stops a pass hanging on a paused S3 with docker stop and checks exit code 143 within seconds and a free lock afterwards. reconcile_track.py cost clears the run files of the previous series and measures 1k, 10k, 30k and 100k with --deep everywhere. The scenarios record date, commit and docker inspect of the replicas or of S3 at the moment they are down. make load-evidence and make clean-clone-evidence rerun the message load and the clean clone block with raw output, and make upload-memory passes ARGS to reproduce the run directories. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3de1dcdc84
commit
f1ee385a1b
@@ -23,6 +23,19 @@ def compose(*args, stdin=None):
|
||||
return subprocess.run(cmd, cwd=ROOT, input=stdin, capture_output=True, text=True, check=False)
|
||||
|
||||
|
||||
def containers(service):
|
||||
ids = compose("ps", "-aq", service).stdout.split()
|
||||
fields = ("hostname", "status", "exit_code", "started_at", "finished_at")
|
||||
template = (
|
||||
"{{.Config.Hostname}} {{.State.Status}} {{.State.ExitCode}}"
|
||||
" {{.State.StartedAt}} {{.State.FinishedAt}}"
|
||||
)
|
||||
out = subprocess.run(
|
||||
["docker", "inspect", "-f", template, *ids], capture_output=True, text=True, check=False
|
||||
)
|
||||
return [dict(zip(fields, line.split())) for line in out.stdout.splitlines()]
|
||||
|
||||
|
||||
def upload(c, actor, chat, expected=201):
|
||||
path = f"/api/v1/chats/{chat['id']}/attachments?filename=sample.png"
|
||||
schema = "Attachment" if expected == 201 else None
|
||||
@@ -89,6 +102,10 @@ def failover_upload(c, args):
|
||||
recovered = time.monotonic() - started
|
||||
served = got["headers"].get("X-Instance-Id")
|
||||
check(served != target, "download served by the stopped replica")
|
||||
during = containers(args.service)
|
||||
states = {item["hostname"]: item["status"] for item in during}
|
||||
check(states.get(target) == "exited", f"target {target} is not exited: {states}")
|
||||
check(states.get(served) == "running", f"neighbour {served} is not running: {states}")
|
||||
digest = hashlib.sha256(got["bytes"]).hexdigest()
|
||||
check(
|
||||
digest == att["sha256"] == hashlib.sha256(FIXTURE).hexdigest(),
|
||||
@@ -103,7 +120,9 @@ def failover_upload(c, args):
|
||||
"sha256_equal": True,
|
||||
"hook_seconds": round(hook_seconds, 3),
|
||||
"download_ok_after_seconds": round(recovered, 3),
|
||||
"replicas_at_download": during,
|
||||
"restored": args.restore,
|
||||
"replicas_after_restore": containers(args.service) if args.restore else None,
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +142,7 @@ def s3_outage(c, args):
|
||||
"text_message": timed(lambda: c.message(alice, chat, "S3 недоступен, текст работает")),
|
||||
"health_ready": timed(lambda: c.call("GET", "/health/ready", [200, 503])),
|
||||
}
|
||||
stopped = containers(args.s3_service)
|
||||
finally:
|
||||
started = time.monotonic()
|
||||
compose("up", "-d", "--wait", "--no-deps", "--no-recreate", args.s3_service)
|
||||
@@ -132,6 +152,7 @@ def s3_outage(c, args):
|
||||
expected = {"upload": 503, "download": 503, "text_message": 201}
|
||||
return {
|
||||
"scenario": "s3-outage",
|
||||
"s3_container_during_outage": stopped,
|
||||
"during_outage": during,
|
||||
"expected": expected,
|
||||
"as_expected": all(during[k]["status"] == v for k, v in expected.items()),
|
||||
@@ -215,10 +236,17 @@ def main():
|
||||
"s3-outage": s3_outage,
|
||||
"abort-upload": abort_upload,
|
||||
}[args.scenario]
|
||||
commit = subprocess.run(
|
||||
["git", "rev-parse", "--short", "HEAD"], cwd=ROOT, capture_output=True, check=False
|
||||
)
|
||||
stamp = {
|
||||
"date": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
||||
"commit": commit.stdout.decode().strip(),
|
||||
}
|
||||
try:
|
||||
report = {"ok": True, **run(c, args)}
|
||||
report = {"ok": True, **stamp, **run(c, args)}
|
||||
except Failure as exc:
|
||||
report = {"scenario": args.scenario, "ok": False, "error": str(exc)}
|
||||
report = {"scenario": args.scenario, "ok": False, **stamp, "error": str(exc)}
|
||||
text = json.dumps(report, ensure_ascii=False, indent=2)
|
||||
if args.output:
|
||||
Path(args.output).write_text(text + "\n")
|
||||
|
||||
Reference in New Issue
Block a user