noqt commited on
Commit
0decc67
·
1 Parent(s): 8235aa5

test: reset lockdown between offline repetitions

Browse files
scripts/qualify_offline_boundary_integration.py CHANGED
@@ -41,6 +41,40 @@ def call(operator: str, args: list[str], *, check: bool = True) -> dict[str, Any
41
  return value
42
 
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  def wait_state(operator: str, name: str, expected: str, timeout: float = 20.0) -> dict[str, Any]:
45
  deadline = time.monotonic() + timeout
46
  latest: dict[str, Any] = {}
@@ -144,6 +178,7 @@ def main() -> int:
144
  raise RuntimeError("installed supervisor doctor failed")
145
  for index in range(args.boundary_repetitions):
146
  name = f"boundary-{token}-{index}"
 
147
  canary = subprocess.Popen(
148
  ["/usr/sbin/runuser", "-u", workload, "--", "/bin/sleep", "60"],
149
  start_new_session=True,
@@ -182,6 +217,7 @@ def main() -> int:
182
  latencies.append(latency)
183
  results["boundary"].append(latency)
184
  finally:
 
185
  stop_canary(canary)
186
  for index in range(args.benign_repetitions):
187
  name = f"benign-{token}-{index}"
 
41
  return value
42
 
43
 
44
+ def root_call(args: list[str]) -> dict[str, Any]:
45
+ result = run([CLI, *args])
46
+ if not result.stdout.strip():
47
+ return {}
48
+ value = json.loads(result.stdout)
49
+ if not isinstance(value, dict):
50
+ raise TypeError("Eggcracker root response is not an object")
51
+ return value
52
+
53
+
54
+ def incident_ids() -> set[str]:
55
+ value = root_call(["incidents"])
56
+ incidents = value.get("incidents", [])
57
+ if not isinstance(incidents, list):
58
+ raise TypeError("Eggcracker incident response is invalid")
59
+ return {
60
+ item["incident_id"]
61
+ for item in incidents
62
+ if isinstance(item, dict) and isinstance(item.get("incident_id"), str)
63
+ }
64
+
65
+
66
+ def clear_new_incidents(previous: set[str]) -> None:
67
+ """Reset each independent boundary repetition after its kill proof."""
68
+ for item in root_call(["incidents"]).get("incidents", []):
69
+ if (
70
+ isinstance(item, dict)
71
+ and item.get("state") == "ACTIVE"
72
+ and isinstance(item.get("incident_id"), str)
73
+ and item["incident_id"] not in previous
74
+ ):
75
+ root_call(["incident", "clear", item["incident_id"]])
76
+
77
+
78
  def wait_state(operator: str, name: str, expected: str, timeout: float = 20.0) -> dict[str, Any]:
79
  deadline = time.monotonic() + timeout
80
  latest: dict[str, Any] = {}
 
178
  raise RuntimeError("installed supervisor doctor failed")
179
  for index in range(args.boundary_repetitions):
180
  name = f"boundary-{token}-{index}"
181
+ before_incidents = incident_ids()
182
  canary = subprocess.Popen(
183
  ["/usr/sbin/runuser", "-u", workload, "--", "/bin/sleep", "60"],
184
  start_new_session=True,
 
217
  latencies.append(latency)
218
  results["boundary"].append(latency)
219
  finally:
220
+ clear_new_incidents(before_incidents)
221
  stop_canary(canary)
222
  for index in range(args.benign_repetitions):
223
  name = f"benign-{token}-{index}"