d4be12ca95
gates / gates (push) Successful in 13s
The golden template in local:backup/ was picked as the newest settled archive on demo-hp and failed every 6 h. Candidates are now vzdump-<type>-<vmid> files or PBS ct|vm/<vmid> snapshots with a reported vmid. Red-proofed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
57 lines
2.9 KiB
Go
57 lines
2.9 KiB
Go
package backup
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-agent/internal/proxmox"
|
|
)
|
|
|
|
// R-689 (v0.135.0) — demo-hp keeps its golden template in `local:backup/`. It is content "backup",
|
|
// 654 MB and so "plausibly complete", and it was the newest SETTLED entry: the restore test picked it
|
|
// every 6 h and failed extractconfig with a 403 (measured 2026-09-24 10:36, 09-25 04:57 and 10:57),
|
|
// while the guest's own archive — younger than the 24 h settle — went untested and nothing was proven.
|
|
//
|
|
// COMPANION RED-PROOF (REPORT.md): drop the guestBackupArchive call from PickSettledRestoreCandidateOn —
|
|
// this test then picks `local:backup/felhom-golden-0.236.0.tar.zst`.
|
|
func TestR689_TheRestoreTestNeverPicksTheGolden(t *testing.T) {
|
|
const day = int64(86400)
|
|
now := int64(1790370000) // 2026-09-25 ~19:00Z
|
|
api := &fakeBackupAPI{content: []proxmox.StorageContent{
|
|
// the guest's real archive, settled (older than the cutoff below)
|
|
{VolID: "local:backup/vzdump-lxc-9201-2026_09_22-21_59_25.tar.zst", Content: "backup", VMID: 9201, Size: 8 << 30, CTime: now - 3*day},
|
|
// the golden: newer, settled, big, and NOT a backup of a guest
|
|
{VolID: "local:backup/felhom-golden-0.236.0.tar.zst", Content: "backup", Size: 654115664, CTime: now - 2*day},
|
|
// a hand-copied tarball that PVE happens to attribute to a vmid — the name is not a vzdump's
|
|
{VolID: "local:backup/copy-of-9201.tar.zst", Content: "backup", VMID: 9201, Size: 8 << 30, CTime: now - 2*day},
|
|
}}
|
|
r := NewBackupRunner(api, "local", proxmox.ModeSnapshot, "", "keep-last=1", quiet())
|
|
got, _, err := r.PickSettledRestoreCandidateOn(context.Background(), "local", time.Unix(now-day, 0).UTC())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got != "local:backup/vzdump-lxc-9201-2026_09_22-21_59_25.tar.zst" {
|
|
t.Fatalf("picked %q — the restore test must prove a backup OF A GUEST", got)
|
|
}
|
|
}
|
|
|
|
func TestR689_GuestBackupArchiveShapes(t *testing.T) {
|
|
for _, c := range []struct {
|
|
e proxmox.StorageContent
|
|
ok bool
|
|
}{
|
|
{proxmox.StorageContent{VolID: "local:backup/vzdump-lxc-9201-2026_09_24-21_59_25.tar.zst", VMID: 9201}, true},
|
|
{proxmox.StorageContent{VolID: "local:backup/vzdump-qemu-300-2026_09_24-21_59_25.vma.zst", VMID: 300}, true},
|
|
{proxmox.StorageContent{VolID: "felhom-pbs:backup/ct/9201/2026-07-28T05:31:14Z", VMID: 9201}, true},
|
|
{proxmox.StorageContent{VolID: "felhom-pbs:backup/vm/300/2026-07-28T05:31:14Z", VMID: 300}, true},
|
|
{proxmox.StorageContent{VolID: "local:backup/felhom-golden-0.236.0.tar.zst"}, false},
|
|
{proxmox.StorageContent{VolID: "local:backup/vzdump-lxc-9201-x.tar.zst", VMID: 9202}, false}, // vmid disagrees with the name
|
|
{proxmox.StorageContent{VolID: "felhom-pbs:backup/ct/9201/2026-07-28T05:31:14Z"}, false}, // no vmid reported
|
|
} {
|
|
if ok, why := guestBackupArchive(c.e); ok != c.ok {
|
|
t.Errorf("%s vmid=%d: ok=%v (%s), want %v", c.e.VolID, c.e.VMID, ok, why, c.ok)
|
|
}
|
|
}
|
|
}
|