3c6b49b31c
gates / gates (push) Successful in 27s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
60 lines
2.4 KiB
Go
60 lines
2.4 KiB
Go
package stacks
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// R-665 + R-664 (v0.269.0) — the new version is judged by ITS OWN .felhom.yml: the catalog's, or the
|
|
// ladder step's; never the stack dir's, which a restore rewrites with the unit's older file.
|
|
//
|
|
// COMPANION RED-PROOF (REPORT): make updateHealthFor ignore metaFile (the v0.268.0 behaviour) — the probe
|
|
// port read is then the RESTORED 1111 and both cases fail.
|
|
func probePortSeen(t *testing.T, m *Manager) *int {
|
|
t.Helper()
|
|
port := new(int)
|
|
m.updateHealthMetaFn = func(_ context.Context, _ string, _ time.Duration, meta *Metadata) (bool, string) {
|
|
if meta != nil && meta.HealthCheck != nil && len(meta.HealthCheck.Checks) > 0 {
|
|
*port = meta.HealthCheck.Checks[0].Port
|
|
}
|
|
return true, "fake"
|
|
}
|
|
return port
|
|
}
|
|
|
|
func TestR665_TheVerifyUsesTheNewVersionsOwnFile(t *testing.T) {
|
|
m, dir, _, _ := newSlice4Manager(t)
|
|
mustWrite(t, filepath.Join(dir, ".felhom.yml"), "healthcheck:\n checks:\n - type: http\n port: 1111\n") // what a restore wrote
|
|
mustWrite(t, m.CatalogTemplatePath("nextcloud", ".felhom.yml"), "healthcheck:\n checks:\n - type: http\n port: 2222\n")
|
|
port := probePortSeen(t, m)
|
|
if err := m.StartGuardedUpdate("nextcloud"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if st := waitUpdateDone(t, m, "nextcloud"); st.UpdatePhase != UpdatePhaseDone {
|
|
t.Fatalf("ended %q", st.UpdatePhase)
|
|
}
|
|
if *port != 2222 {
|
|
t.Fatalf("verified with probe port %d, want the catalog's 2222 (1111 = the restored file, R-665)", *port)
|
|
}
|
|
}
|
|
|
|
func TestR664_AStepIsVerifiedWithItsOwnFile(t *testing.T) {
|
|
m, dir, _, _, _ := ladderManager(t, true)
|
|
catDir := filepath.Dir(m.CatalogTemplatePath("nextcloud", "docker-compose.yml"))
|
|
mustWrite(t, filepath.Join(dir, ".felhom.yml"), "healthcheck:\n checks:\n - type: http\n port: 1111\n")
|
|
mustWriteMk(t, StepMetaFile(catDir, map[string]string{"web": ladderB}), "healthcheck:\n checks:\n - type: http\n port: 3333\n")
|
|
port := probePortSeen(t, m)
|
|
if err := m.StartGuardedUpdate("nextcloud"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
waitUpdateDone(t, m, "nextcloud")
|
|
if *port != 3333 {
|
|
t.Fatalf("step B verified with probe port %d, want its own 3333", *port)
|
|
}
|
|
if got := fileBody(t, filepath.Join(dir, appliedMetaDir, ".felhom.yml")); got != "healthcheck:\n checks:\n - type: http\n port: 3333\n" {
|
|
t.Fatalf("applied-meta after step B is not the step's own file: %q", got)
|
|
}
|
|
}
|