fix(regression): bad-restore uses custom-html-bkp-bad + ops.py+test_restore.py
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
backup-bot-two ignores backupbot.backup.path labels and always backs up the full volume, making path-based restore-RED infeasible. New approach: custom-html-bkp-bad has no pre_backup → marker never seeded → backup snapshot has no ci-marker.txt. pre_restore writes 'mutated'. After restore: marker is MISSING or 'mutated' → test_restore_returns_state FAILS. upgrade=skip (no version tags) is acceptable since passing_tiers_before=[install,backup]. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
19
tests/custom-html-bkp-bad/ops.py
Normal file
19
tests/custom-html-bkp-bad/ops.py
Normal file
@ -0,0 +1,19 @@
|
||||
"""custom-html-bkp-bad — lifecycle ops for bad-backup/bad-restore RED canaries.
|
||||
|
||||
Intentionally has NO pre_backup hook: the marker is never seeded before backup,
|
||||
so the backup snapshot has no ci-marker.txt. pre_restore writes "mutated" so that if
|
||||
restore DOES bring back the snapshot, the marker is gone/still-mutated → test fails.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from harness import lifecycle
|
||||
|
||||
MARKER_PATH = "/usr/share/nginx/html/ci-marker.txt"
|
||||
|
||||
|
||||
def pre_restore(domain: str, meta: dict) -> None:
|
||||
"""Write 'mutated' to the marker before restore runs. If restore brings back the
|
||||
snapshot (which has no marker — never seeded by pre_backup), the marker ends up
|
||||
MISSING or 'mutated' after restore → test_restore_returns_state FAILS → restore=RED."""
|
||||
lifecycle.exec_in_app(domain, ["sh", "-c", f"echo mutated > {MARKER_PATH}"])
|
||||
25
tests/custom-html-bkp-bad/test_restore.py
Normal file
25
tests/custom-html-bkp-bad/test_restore.py
Normal file
@ -0,0 +1,25 @@
|
||||
"""custom-html-bkp-bad — RESTORE assertion (bad-restore RED canary).
|
||||
|
||||
pre_restore seeds 'mutated' to ci-marker.txt. The backup snapshot has no ci-marker.txt
|
||||
(never seeded by pre_backup). After restore, the marker is either MISSING or 'mutated' —
|
||||
never 'original' — so this assertion FAILS → restore tier RED.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "runner"))
|
||||
from harness import lifecycle # noqa: E402
|
||||
|
||||
MARKER_PATH = "/usr/share/nginx/html/ci-marker.txt"
|
||||
|
||||
|
||||
def test_restore_returns_state(live_app):
|
||||
result = lifecycle.exec_in_app(
|
||||
live_app, ["sh", "-c", f"cat {MARKER_PATH} 2>/dev/null || echo MISSING"]
|
||||
).strip()
|
||||
assert result == "original", (
|
||||
f"restore did not return the pre-mutation (backed-up) state: got {result!r}. "
|
||||
"Expected 'original'. The backup had no marker (not seeded by pre_backup), so "
|
||||
"restore cannot recover it — this is the intended failure for the bad-restore RED canary."
|
||||
)
|
||||
Reference in New Issue
Block a user