Document scaling experiment, measured database boundary and verified failure recovery
This commit is contained in:
+37
-14
@@ -1,4 +1,5 @@
|
||||
"""Sequential real image replacement under message traffic."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
@@ -13,7 +14,9 @@ from client import Client, Failure
|
||||
|
||||
|
||||
def snapshots():
|
||||
ids = subprocess.check_output(["docker", "compose", "ps", "-q", "api"], cwd=ROOT, text=True).split()
|
||||
ids = subprocess.check_output(
|
||||
["docker", "compose", "ps", "-q", "api"], cwd=ROOT, text=True
|
||||
).split()
|
||||
rows = []
|
||||
for cid in ids:
|
||||
raw = json.loads(subprocess.check_output(["docker", "inspect", cid], text=True))[0]
|
||||
@@ -22,28 +25,43 @@ def snapshots():
|
||||
|
||||
|
||||
def main():
|
||||
subprocess.run(["docker", "build", "-t", "mtusi-vasilev:lab3-rolling", "-"],
|
||||
input="FROM mtusi-vasilev:lab3\nLABEL org.mtusi.rolling-proof=revision-2\n", text=True, check=True)
|
||||
subprocess.run(
|
||||
["docker", "build", "-t", "mtusi-vasilev:lab3-rolling", "-"],
|
||||
input="FROM mtusi-vasilev:lab3\nLABEL org.mtusi.rolling-proof=revision-2\n",
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
before = snapshots()
|
||||
c = Client("http://127.0.0.1:8083")
|
||||
actor, _, _, chat = c.bootstrap()
|
||||
stop = threading.Event()
|
||||
successes, errors = [], []
|
||||
|
||||
def traffic():
|
||||
while not stop.is_set():
|
||||
try:
|
||||
response = c.message(actor, chat, "rolling-proof")
|
||||
successes.append({"id": response["json"]["id"], "at": time.monotonic(),
|
||||
"instance": response["headers"]["X-Instance-Id"]})
|
||||
successes.append(
|
||||
{
|
||||
"id": response["json"]["id"],
|
||||
"at": time.monotonic(),
|
||||
"instance": response["headers"]["X-Instance-Id"],
|
||||
}
|
||||
)
|
||||
except Failure:
|
||||
errors.append(time.monotonic())
|
||||
|
||||
started = time.monotonic()
|
||||
thread = threading.Thread(target=traffic)
|
||||
thread.start()
|
||||
try:
|
||||
time.sleep(1)
|
||||
subprocess.run(["scripts/rolling-update.sh"], cwd=ROOT,
|
||||
env={**os.environ, "API_IMAGE": "mtusi-vasilev:lab3-rolling"}, check=True)
|
||||
subprocess.run(
|
||||
["scripts/rolling-update.sh"],
|
||||
cwd=ROOT,
|
||||
env={**os.environ, "API_IMAGE": "mtusi-vasilev:lab3-rolling"},
|
||||
check=True,
|
||||
)
|
||||
time.sleep(2)
|
||||
finally:
|
||||
stop.set()
|
||||
@@ -64,13 +82,18 @@ def main():
|
||||
break
|
||||
assert {x["id"] for x in successes} <= {x["id"] for x in items}
|
||||
times = [started, *[x["at"] for x in successes], started + elapsed]
|
||||
result = {"before": before, "after": after, "successful_writes": len(successes),
|
||||
"failed_attempts": len(errors), "elapsed_seconds": elapsed,
|
||||
"successful_rps": len(successes) / elapsed,
|
||||
"observed_instances": sorted({x["instance"] for x in successes}),
|
||||
"largest_success_gap_seconds": max(b-a for a,b in zip(times,times[1:])),
|
||||
"all_confirmed_present": True,
|
||||
"note": "Target image differs by revision label; same API/schema. This verifies sequential replacement, not arbitrary schema compatibility."}
|
||||
result = {
|
||||
"before": before,
|
||||
"after": after,
|
||||
"successful_writes": len(successes),
|
||||
"failed_attempts": len(errors),
|
||||
"elapsed_seconds": elapsed,
|
||||
"successful_rps": len(successes) / elapsed,
|
||||
"observed_instances": sorted({x["instance"] for x in successes}),
|
||||
"largest_success_gap_seconds": max(b - a for a, b in zip(times, times[1:])),
|
||||
"all_confirmed_present": True,
|
||||
"note": "Target image differs by revision label; same API/schema. This verifies sequential replacement, not arbitrary schema compatibility.",
|
||||
}
|
||||
(ROOT / "evidence/rolling-update.json").write_text(json.dumps(result, indent=2) + "\n")
|
||||
print(json.dumps(result, indent=2))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user