Files
awoooi/scripts/backup/tests/test_sync_offsite_active_backup_guard.py
Your Name e614f061f7
Some checks failed
CD Pipeline / select-latest-carrier (push) Successful in 49s
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m28s
CD Pipeline / revalidate-deploy-carrier (push) Successful in 27s
CD Pipeline / build-and-deploy (push) Failing after 17m18s
CD Pipeline / revalidate-post-deploy-carrier (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
E2E Health Check / e2e-health (push) Successful in 48s
AI 技術雷達監控 / ai-technology-watch (push) Successful in 1m4s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 0s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 22s
fix(backup): verify host188 recovery end to end
2026-07-18 19:12:42 +08:00

39 lines
1.0 KiB
Python

from __future__ import annotations
import os
import subprocess
import time
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[3]
SCRIPT = ROOT / "scripts" / "backup" / "sync-offsite-backups.sh"
@pytest.mark.parametrize("name", ["backup-host188-products.sh", "backup-all.sh"])
def test_active_backup_guard_detects_direct_and_aggregate_runs(
tmp_path: Path, name: str
) -> None:
process = subprocess.Popen(
["bash", "-c", f"exec -a /backup/scripts/{name} sleep 30"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
try:
time.sleep(0.1)
env = os.environ.copy()
env["BACKUP_BASE"] = str(tmp_path / "backup")
result = subprocess.run(
["bash", "-c", f'source "{SCRIPT}"; active_backup_processes'],
env=env,
text=True,
capture_output=True,
check=True,
)
assert f"/backup/scripts/{name}" in result.stdout
finally:
process.terminate()
process.wait(timeout=5)