This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Measure real PostgreSQL/MinIO reconciler traversal at two inventory sizes."""
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
||||
PREFIX = "attachments/reconcile-scale"
|
||||
|
||||
|
||||
def compose(*arguments, capture=False):
|
||||
result = subprocess.run(
|
||||
["docker", "compose", *arguments],
|
||||
check=False,
|
||||
text=True,
|
||||
capture_output=capture,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
raise RuntimeError(result.stderr.strip() if capture else "docker compose command failed")
|
||||
return result.stdout if capture else ""
|
||||
|
||||
|
||||
def object_command(script):
|
||||
compose("run", "--rm", "--entrypoint", "/bin/sh", "minio-bootstrap", "-ec", script)
|
||||
|
||||
|
||||
def clean():
|
||||
object_command(
|
||||
'root_user="$(cat /run/secrets/minio_root_user)"\n'
|
||||
'root_password="$(cat /run/secrets/minio_root_password)"\n'
|
||||
'mc alias set local http://minio:9000 "$root_user" "$root_password" --api S3v4 >/dev/null\n'
|
||||
'mc rm --recursive --force "local/${S3_BUCKET}/' + PREFIX + '/" >/dev/null 2>&1 || true\n'
|
||||
)
|
||||
|
||||
|
||||
def create(count):
|
||||
object_command(
|
||||
'root_user="$(cat /run/secrets/minio_root_user)"\n'
|
||||
'root_password="$(cat /run/secrets/minio_root_password)"\n'
|
||||
'mc alias set local http://minio:9000 "$root_user" "$root_password" --api S3v4 >/dev/null\n'
|
||||
'mkdir -p /tmp/reconcile-scale\n'
|
||||
'index=0\n'
|
||||
'while [ "$index" -lt ' + str(count) + ' ]; do\n'
|
||||
' printf x > "/tmp/reconcile-scale/object-${index}"\n'
|
||||
' index=$((index + 1))\n'
|
||||
'done\n'
|
||||
'mc cp --recursive /tmp/reconcile-scale/ "local/${S3_BUCKET}/' + PREFIX + '/" >/dev/null\n'
|
||||
)
|
||||
|
||||
|
||||
def dry_run():
|
||||
started = time.monotonic()
|
||||
output = compose(
|
||||
"run", "--rm", "--entrypoint", "/app/reconciler", "api",
|
||||
"--grace-period", "1s",
|
||||
capture=True,
|
||||
)
|
||||
elapsed = time.monotonic() - started
|
||||
result = json.loads(output)
|
||||
return {
|
||||
"scanned_attachments": result["scanned_attachments"],
|
||||
"scanned_objects": result["scanned_objects"],
|
||||
"issues": len(result["issues"]),
|
||||
"reconciler_duration_ms": result["duration_ms"],
|
||||
"container_start_and_run_ms": round(elapsed * 1000),
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
measurements = []
|
||||
clean()
|
||||
try:
|
||||
for count in (100, 1000):
|
||||
clean()
|
||||
create(count)
|
||||
time.sleep(2)
|
||||
measurement = dry_run()
|
||||
measurement["injected_orphan_objects"] = count
|
||||
if measurement["issues"] < count:
|
||||
raise RuntimeError("reconciler did not observe all scale fixtures")
|
||||
measurements.append(measurement)
|
||||
print(json.dumps({"measurements": measurements}, ensure_ascii=False))
|
||||
print("PASS: reconciler traversal cost measured on real PostgreSQL/MinIO inventories.")
|
||||
finally:
|
||||
clean()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user