Some checks failed
CD Pipeline / workflow-shape (push) Has been cancelled
CD Pipeline / cancel-stale-cd (push) Has been cancelled
CD Pipeline / tests (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
CD Pipeline / post-deploy-checks (push) Has been cancelled
82 lines
3.0 KiB
Python
82 lines
3.0 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
|
|
|
|
def read(path: str) -> str:
|
|
return (ROOT / path).read_text(encoding="utf-8")
|
|
|
|
|
|
def test_reboot_p0_contract_covers_all_required_hosts_and_vmware_autostart() -> None:
|
|
host_probe = read("scripts/reboot-recovery/reboot-auto-recovery-host-probe.sh")
|
|
windows99 = read("scripts/reboot-recovery/windows99-vmware-autostart.ps1")
|
|
|
|
for host in ["99", "110", "111", "112", "120", "121", "188"]:
|
|
assert host in host_probe
|
|
assert "AWOOOI-Start-VMware-VMs" in windows99
|
|
assert "NoAutoRebootWithLoggedOnUsers" in windows99
|
|
assert "Host110Vmx" in windows99
|
|
assert "Host111Vmx" in windows99
|
|
assert "Host188Vmx" in windows99
|
|
assert "Host120Vmx" in windows99
|
|
assert "Host121Vmx" in windows99
|
|
assert "Host112Vmx" in windows99
|
|
assert "D:\\Documents\\Virtual Machines" in windows99
|
|
assert "D:\\Downloads" in windows99
|
|
assert "HOST111_VMWARE_TARGET=not_required_by_default_missing_no_vmx_found_on_99" in windows99
|
|
assert "VM_ALREADY_RUNNING" in windows99
|
|
|
|
|
|
def test_reboot_p0_contract_has_maintenance_and_telegram_alerts() -> None:
|
|
alerts = read("ops/monitoring/alerts-unified.yml")
|
|
runbook = read("docs/runbooks/PUBLIC-MAINTENANCE-FALLBACK-RUNBOOK.md")
|
|
snippet = read("ops/maintenance/nginx-502-maintenance-snippet.conf")
|
|
|
|
for alert_name in [
|
|
"HostRebootEventDetected",
|
|
"RebootAutoRecoverySLOMissed",
|
|
"PublicRouteServing5xxWithoutMaintenanceFallback",
|
|
"BackupCoverageDomainStale",
|
|
]:
|
|
assert alert_name in alerts
|
|
assert "notification_type: TYPE-3" in alerts
|
|
assert "proxy_intercept_errors on" in snippet
|
|
assert "502" in runbook
|
|
assert "L0" in runbook
|
|
assert "L1" in runbook
|
|
|
|
|
|
def test_backup_exporter_emits_domain_level_backup_coverage() -> None:
|
|
exporter = read("scripts/ops/backup-health-textfile-exporter.py")
|
|
|
|
assert "awoooi_backup_coverage_domain_expected_info" in exporter
|
|
assert "awoooi_backup_coverage_domain_fresh" in exporter
|
|
assert "gitea_repo_mirror_from_110" in exporter
|
|
assert "/home/ollama/backup/110/gitea" in exporter
|
|
for domain in ["host", "database", "website", "service", "package", "tool", "log"]:
|
|
assert f'"{domain}"' in exporter
|
|
|
|
|
|
def test_backup_alerts_cover_188_gitea_mirror_subtree() -> None:
|
|
alerts = read("ops/monitoring/alerts-unified.yml")
|
|
|
|
assert 'awoooi_backup_coverage_domain_expected_info{host="188"}' in alerts
|
|
assert "BackupCoverageDomainMetricMissing188" in alerts
|
|
assert "awoooi_backup_coverage_domain_fresh == 0" in alerts
|
|
|
|
|
|
def test_gitea_repo_bundle_backup_is_non_interactive_and_manifested() -> None:
|
|
script = read("scripts/backup/gitea-repo-bundle-backup.sh")
|
|
|
|
assert "GIT_TERMINAL_PROMPT=0" in script
|
|
assert "bundle create" in script
|
|
assert "bundle verify" in script
|
|
assert ".sha256" in script
|
|
assert "manifest.tsv" in script
|
|
assert "gitea dump" in script
|
|
assert "does not replace `gitea dump`" in script
|
|
assert "tokens or passwords" in script
|