forked from mtusi2026/mtusi2026lab7
test(pki): measure phase errors and verify revocation before expiry
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import argparse
|
||||
import csv
|
||||
import json
|
||||
import math
|
||||
import socket
|
||||
import ssl
|
||||
import time
|
||||
@@ -165,6 +166,7 @@ def main():
|
||||
raise AssertionError(
|
||||
"Expired server certificate was accepted"
|
||||
)
|
||||
recovery_started_at = time.time()
|
||||
recovery = time.monotonic()
|
||||
operator = Operator()
|
||||
try:
|
||||
@@ -178,6 +180,8 @@ def main():
|
||||
"leaf": leaf,
|
||||
"waited_seconds": round(wait_seconds, 3),
|
||||
"expired_certificate_verified_denied": True,
|
||||
"recovery_started_at": recovery_started_at,
|
||||
"recovery_ready_at": time.time(),
|
||||
"recovery_seconds": round(time.monotonic() - recovery, 3),
|
||||
}
|
||||
|
||||
@@ -202,6 +206,7 @@ def main():
|
||||
)
|
||||
except httpx.HTTPError as error:
|
||||
error_type = type(error).__name__
|
||||
recovery_started_at = time.time()
|
||||
recovery = time.monotonic()
|
||||
pki.recover_bao()
|
||||
bao_sealed = False
|
||||
@@ -210,6 +215,8 @@ def main():
|
||||
"sealed_seconds": 70,
|
||||
"status_after_secret_expiry": status,
|
||||
"tls_transport_failure": error_type,
|
||||
"recovery_started_at": recovery_started_at,
|
||||
"recovery_ready_at": time.time(),
|
||||
"recovery_seconds": round(time.monotonic() - recovery, 3),
|
||||
"explicit_operator_recovery": True,
|
||||
}
|
||||
@@ -325,11 +332,62 @@ def main():
|
||||
)
|
||||
writer.writerows(load.requests)
|
||||
report["uploads"] = load.uploads
|
||||
if load is not None:
|
||||
for entry in report["phases"]:
|
||||
ended = entry.get("ended_at", time.time())
|
||||
rows = [
|
||||
r
|
||||
for r in load.requests
|
||||
if entry["started_at"] <= r[0] < ended
|
||||
]
|
||||
latencies = sorted(r[3] for r in rows if r[2] == 201)
|
||||
entry["measured_requests"] = {
|
||||
"count": len(rows),
|
||||
"statuses": dict(Counter(str(r[2]) for r in rows)),
|
||||
"failed_http_or_transport": sum(
|
||||
r[2] not in {201, -1} for r in rows
|
||||
),
|
||||
"client_backpressure_drops": sum(
|
||||
r[2] == -1 for r in rows
|
||||
),
|
||||
"successful_p95_seconds": latencies[
|
||||
math.ceil(0.95 * len(latencies)) - 1
|
||||
]
|
||||
if latencies
|
||||
else None,
|
||||
}
|
||||
result = entry.get("result")
|
||||
if (
|
||||
isinstance(result, dict)
|
||||
and "recovery_started_at" in result
|
||||
):
|
||||
recovery = result["recovery_started_at"]
|
||||
ends = [
|
||||
r[0] + r[3]
|
||||
for r in load.requests
|
||||
if r[2] == 201 and r[0] >= recovery
|
||||
]
|
||||
result[
|
||||
"first_observed_business_write_after_recovery_start_seconds"
|
||||
] = round(min(ends) - recovery, 6) if ends else None
|
||||
save()
|
||||
if lb_stopped:
|
||||
compose("up", "-d", "--no-deps", "identity-lb")
|
||||
if bao_sealed:
|
||||
pki.recover_bao()
|
||||
try:
|
||||
if bao_sealed:
|
||||
pki.recover_bao()
|
||||
if lb_stopped:
|
||||
operator = Operator()
|
||||
try:
|
||||
repair(operator, "lb")
|
||||
finally:
|
||||
operator.close()
|
||||
compose("up", "-d", "--no-deps", "identity-lb")
|
||||
except Exception as cleanup_error:
|
||||
report["recovery_cleanup_error_type"] = type(
|
||||
cleanup_error
|
||||
).__name__
|
||||
save()
|
||||
if report["complete"]:
|
||||
raise
|
||||
print(
|
||||
"PASS: measured renewal, working-key/leaf rotation, revocation, expiry, seal recovery and CA rollover"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user