29 lines
821 B
Python
29 lines
821 B
Python
"""Terminate acceptance at a durable publication boundary for recovery tests."""
|
|||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import os
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
from gewu.domain.contracts import ProposalRevision
|
||
|
|
from tests.application.test_acceptance import ACTOR, _service
|
||
|
|
|
||
|
|
|
||
|
|
def main() -> None:
|
||
|
|
data_root = Path(sys.argv[1])
|
||
|
|
proposal_path = Path(sys.argv[2])
|
||
|
|
crash_stage = sys.argv[3]
|
||
|
|
proposal = ProposalRevision.model_validate_json(proposal_path.read_bytes(), strict=True)
|
||
|
|
|
||
|
|
def terminate(stage: str) -> None:
|
||
|
|
if stage == crash_stage:
|
||
|
|
os._exit(73)
|
||
|
|
|
||
|
|
service, *_ = _service(data_root, hook=terminate)
|
||
|
|
service.submit(proposal, actor=ACTOR)
|
||
|
|
raise RuntimeError(f"Acceptance completed without reaching crash stage {crash_stage}")
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|