46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Show that broker confirm without outbox confirmation safely republishes."""
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / "tests"))
|
|
from client import Client, arguments, check, run # noqa: E402
|
|
|
|
|
|
def compose(*args, input_data=None):
|
|
return subprocess.run(
|
|
["docker", "compose", "-f", "compose.yaml", "-f", "compose.telemetry.yaml", *args], cwd=ROOT,
|
|
input=input_data, check=True,
|
|
)
|
|
|
|
|
|
def main():
|
|
args = arguments("Lab6 publish/confirm gap")
|
|
client = Client(args.base_url, args.ca_file)
|
|
compose("stop", "worker", "publisher")
|
|
attachment = None
|
|
try:
|
|
alice, bob, _eve, chat = client.bootstrap()
|
|
attachment, _original = client.attachment(alice, chat)
|
|
check(attachment["status"] == "queued", "upload was not queued")
|
|
source = (ROOT / "student-tests/publish_gap_inner.py").read_bytes()
|
|
compose(
|
|
"run", "--rm", "--no-deps", "-T",
|
|
"-e", f"FAULT_ATTACHMENT_ID={attachment['id']}", "publisher", "python", "-",
|
|
input_data=source,
|
|
)
|
|
finally:
|
|
compose("up", "-d", "publisher", "worker")
|
|
ready = client.wait_ready(bob, attachment)
|
|
check(ready["status"] == "ready", "republished job did not finish")
|
|
check(len(ready["variants"]) == 3, "duplicate delivery changed variant set")
|
|
print("PASS: confirmed broker copy republished after lost DB confirm; worker reached ready once")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run(main)
|