forked from mtusi2026/mtusi2026lab5
Scope retention fault injection to the synthetic attachment
This commit is contained in:
@@ -602,15 +602,39 @@ class Suite:
|
||||
self.api.final[ident] = {"failed"}
|
||||
kept = self.record(ident)["staging_key"]
|
||||
check(kept is not None, "failed staging was removed before the retention period")
|
||||
try:
|
||||
self.stack.launch(self.args.relay, FAULT_STAGING_RETENTION_SECONDS="1")
|
||||
poll(lambda: self.record(ident)["staging_key"] is None, 30, "failed staging cleanup")
|
||||
finally:
|
||||
self.stack.launch(self.args.relay)
|
||||
retention = int(
|
||||
self.stack.dc("exec", "-T", self.args.relay, "printenv", "STAGING_RETENTION_SECONDS")
|
||||
)
|
||||
aged = self.stack.dc(
|
||||
"exec",
|
||||
"-T",
|
||||
self.args.postgres,
|
||||
"sh",
|
||||
"-c",
|
||||
PSQL,
|
||||
"sh",
|
||||
"-v",
|
||||
"id=" + ident,
|
||||
"-v",
|
||||
"chat=" + self.api.chat["id"],
|
||||
"-v",
|
||||
"age=" + str(retention + 1),
|
||||
stdin="UPDATE attachments SET created_at = created_at - :age * interval '1 second', "
|
||||
"updated_at = updated_at - :age * interval '1 second' "
|
||||
"WHERE id = :'id' AND chat_id = :'chat' AND status = 'failed' RETURNING id;\n",
|
||||
)
|
||||
check(aged.strip() == ident, "did not age exactly the suite's failed attachment")
|
||||
poll(lambda: self.record(ident)["staging_key"] is None, 30, "failed staging cleanup")
|
||||
replay = self.stack.admin("replay", "--attachment-id", ident)
|
||||
check(replay["result"] == "expired", f"replay after retention gave {replay}")
|
||||
check(self.api.get(ident)["status"] == "failed", "expired replay changed the status")
|
||||
return {"attachment_id": ident, "staging_before": "kept", "replay": replay}
|
||||
return {
|
||||
"attachment_id": ident,
|
||||
"staging_before": "kept",
|
||||
"retention_seconds": retention,
|
||||
"aged_only": ident,
|
||||
"replay": replay,
|
||||
}
|
||||
|
||||
def image_matrix(self):
|
||||
folder = Path(self.args.images)
|
||||
|
||||
Reference in New Issue
Block a user