hub v0.7.3: ingest agent backups + restore_tests (slice 6 Phase A)
Accept + persist the now-populated host-report backups/restore_tests. Mirror structs in hostReportPayload; persisted via report_json (no schema change); a FAILED restore-test is logged prominently (loudest DR signal). Shared golden updated byte-identical with felhom-agent; bidirectional key-set tests added. Build/deploy deferred (backward-compatible). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -286,6 +286,58 @@ func TestHostStorageTarget_GoldenContract(t *testing.T) {
|
||||
assertSameStorageKeys(t, "storage_targets[0].thin_pool", goldenKeys["thin_pool"], mirrorKeys["thin_pool"])
|
||||
}
|
||||
|
||||
func TestHostBackup_GoldenContract(t *testing.T) {
|
||||
raw, err := os.ReadFile("testdata/host-report.golden.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var golden struct {
|
||||
Backups []json.RawMessage `json:"backups"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &golden); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(golden.Backups) == 0 {
|
||||
t.Fatal("golden has no backups to check")
|
||||
}
|
||||
var goldenKeys map[string]any
|
||||
json.Unmarshal(golden.Backups[0], &goldenKeys)
|
||||
var mirror hostBackup
|
||||
if err := json.Unmarshal(golden.Backups[0], &mirror); err != nil {
|
||||
t.Fatalf("golden backup does not parse into the mirror: %v", err)
|
||||
}
|
||||
b, _ := json.Marshal(mirror)
|
||||
var mirrorKeys map[string]any
|
||||
json.Unmarshal(b, &mirrorKeys)
|
||||
assertSameStorageKeys(t, "backups[0]", goldenKeys, mirrorKeys)
|
||||
}
|
||||
|
||||
func TestHostRestoreTest_GoldenContract(t *testing.T) {
|
||||
raw, err := os.ReadFile("testdata/host-report.golden.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var golden struct {
|
||||
RestoreTests []json.RawMessage `json:"restore_tests"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &golden); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(golden.RestoreTests) == 0 {
|
||||
t.Fatal("golden has no restore_tests to check")
|
||||
}
|
||||
var goldenKeys map[string]any
|
||||
json.Unmarshal(golden.RestoreTests[0], &goldenKeys)
|
||||
var mirror hostRestoreTest
|
||||
if err := json.Unmarshal(golden.RestoreTests[0], &mirror); err != nil {
|
||||
t.Fatalf("golden restore-test does not parse into the mirror: %v", err)
|
||||
}
|
||||
b, _ := json.Marshal(mirror)
|
||||
var mirrorKeys map[string]any
|
||||
json.Unmarshal(b, &mirrorKeys)
|
||||
assertSameStorageKeys(t, "restore_tests[0]", goldenKeys, mirrorKeys)
|
||||
}
|
||||
|
||||
func assertSameStorageKeys(t *testing.T, where string, a, b any) {
|
||||
t.Helper()
|
||||
ka, kb := sortedKeys(a), sortedKeys(b)
|
||||
|
||||
Reference in New Issue
Block a user