carlos / platform Public

region HA: handover witness holds a real HA worker and observed holds

Task 8 fix round 1. The two-box witness now provisions a born-HA worker
through ReconcileSidecars, with its duty on A by the duty rule's hash,
and asserts its clean marker naming A, its released report entry, no
begin or take, and no start on B. The sleep before the take is replaced
by observed holds: the edge's MoveState goes through a recording
pass-through, and the test waits for one client hold and one replayable
hop hold in progress, then checks each Wait returned taken naming B. The
lost-lease witness waits on its hold and on SetMoveLeft. Driver calls are
checked as ordered subsequences, once each, seven in all.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 887f20429ea16c7b9c1b9cfca4825eed80733b39 parent 736908c
1 file changed, +263 −22
  • internal/host/hadrain_twobox_minio_linux_test.go +263 −22

Intent

Human

<task-notification> <task-id>a480ce66c5cf08171</task-id> <tool-use-id>toolu_01VV1eAoET9Kz7TDepbhW9kQ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/283be278-5c6a-4a71-a8d6-b3d32c668985/tasks/a480ce66c5cf08171.output</output-file> <status>completed</status> <summary>Agent "Implement Task 8: integration+spec" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE_WITH_CONCERNS. Commits (on region-ha-held-build, not pushed): - `cc8c08a1` persistent fence - `1a1c585e` spec - `9ec7c79c` two-box witness and CI step - `736908c8` census Tests: the fence and drain tests in `internal/host`, the sim package, gofmt, vet, the darwin and windows builds, and the census test all pass. Both new MinIO witnesses pass 10 of 10, under `-race`, and as the CI scoped user. The fence-move mutations are caught over 3,000 seeds with a clean baseline. 4 of 5 mutations against the witnesses are caught; the fifth (`MoveState` ignoring the loss latch) is equivalent for this witness and is covered elsewhere. No defects found in earlier tasks. Concerns: 1. Two things are not exercised end to end: an always-on worker being released (its start needs a real child process), and closing idle keep-alive connections (the edge registers its servers for that only inside `RunWithActivatorReady`). Both are covered by Task 5's tests. 2. The HA acquire uses one identity for the whole process (`lease.SetSelf`), so the test sets it to whichever box acquires next. This is not a production defect. 3. The CI step itself was not run here because it downloads from the mirror. I ran the same command against a local MinIO. 4. The census verdict on #280 is still owed: the controller gets the cross-family verdict. 5. Every commit warned about another process's `.git/packed-refs.lock`; the commits landed and I left the lock alone. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-held-build/.superpowers/sdd/2026-11-08-region-ha-held-requests/task-8-report.md</result> <usage><subagent_tokens>428022</subagent_tokens><tool_uses>187</tool_uses><duration_ms>3371407</duration_ms></usage> </task-notification>

Attributed to this commit: 32.7 g CO₂e (4,251,529 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-held-build, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/host/hadrain_twobox_minio_linux_test.go b/internal/host/hadrain_twobox_minio_linux_test.go
index 35230db28..8145eb00f 100644
--- a/internal/host/hadrain_twobox_minio_linux_test.go
+++ b/internal/host/hadrain_twobox_minio_linux_test.go
@@ -38,6 +38,7 @@ import (
"golang.org/x/crypto/acme/autocert"
"github.com/carlosframework/platform/internal/activator"
+ "github.com/carlosframework/platform/internal/boxchoice"
"github.com/carlosframework/platform/internal/domains"
"github.com/carlosframework/platform/internal/edge"
"github.com/carlosframework/platform/internal/groupadmission"
@@ -80,6 +81,9 @@ import (
// It runs only against a real MinIO (CARLOS_MINIO_TEST=1 and the MINIO_*
// variables), which .amadan/ci.d/30-minio-contract stands up in CI.
+//go:linkname drainWitnessDutyHRW github.com/carlosframework/platform/internal/activator.dutyHRW
+func drainWitnessDutyHRW(host string, refs []string) (string, bool)
+
//go:linkname drainWitnessBackhaulPort github.com/carlosframework/platform/internal/edge.backhaulPort
var drainWitnessBackhaulPort string
@@ -220,6 +224,12 @@ func (c *dwControl) start(host string) (string, error) {
if err := dwEnsureDB(rt.DBPath); err != nil {
return "", err
}
+ if rt.IsSidecar() {
+ // An always-on worker binds nothing: it reports ready over the
+ // agent socket, as the activator's HA worker tests do.
+ c.box.svc.NoteWorkerReady(host, "v1")
+ return "inv-" + host, nil
+ }
app := c.box.app(host)
_ = os.Remove(rt.Socket)
if err := os.MkdirAll(filepath.Dir(rt.Socket), 0o755); err != nil {
@@ -334,6 +344,7 @@ type dwBox struct {
svc *activator.Service
e *edge.Edge
srv *httptest.Server
+ moves *dwMoves
drain *haDrainState
ident edgesFile
last []byte
@@ -363,6 +374,7 @@ type dwScene struct {
prefix string
host string // the HA host that moves
plain string // a host on A that is not HA
+ worker string // an HA worker (a born-HA sidecar) awake on A
rec provision.Record
plainRec provision.Record
escrow *ecdh.PrivateKey
@@ -452,6 +464,7 @@ func newDWScene(t *testing.T) *dwScene {
s.rec = provision.Record{Schema: 1, Host: s.host, App: "shop", Account: domains.Sqid(2), Channel: "stable", CreatedAt: created, HA: true, Pool: dwPool}
s.plainRec = provision.Record{Schema: 1, Host: s.plain, App: "plain", Account: domains.Sqid(2), Channel: "stable", CreatedAt: created, Pool: dwPool}
s.tls(t)
+ s.workerRecords(t, tag)
s.a = s.box(t, "annie", "127.0.0.21", true)
s.b = s.box(t, "betty", "127.0.0.22", true)
@@ -487,6 +500,38 @@ func newDWScene(t *testing.T) *dwScene {
return s
}
+// workerRecords writes an HA worker's (a born-HA sidecar's) account, manifest and
+// record to the deployment store, named so that HRW over the two HA boxes
+// gives its duty to A (the duty rule's own hash, linknamed).
+func (s *dwScene) workerRecords(t *testing.T, tag string) {
+ t.Helper()
+ ctx := t.Context()
+ acct := domains.Sqid(2)
+ for i := 0; ; i++ {
+ host := provision.SidecarHost(fmt.Sprintf("bot%d", i), "shop", acct)
+ if w, ok := drainWitnessDutyHRW(host, []string{"annie", "betty"}); ok && w == "annie" && len(host) <= provision.MaxInstanceID {
+ s.worker = host
+ break
+ }
+ }
+ if _, err := s.store.Put(ctx, "accounts/"+acct+"/account.json", []byte(fmt.Sprintf(`{"id":2,"sqid":%q,"name":"Shop","created_at":"2026-10-26T09:00:00Z"}`, acct)), ""); err != nil {
+ t.Fatal(err)
+ }
+ if err := provision.PutSidecarManifest(ctx, s.store, acct, "shop", provision.SidecarManifest{Schema: 1, App: "shop", Args: []string{"work"}}); err != nil {
+ t.Fatal(err)
+ }
+ name := strings.SplitN(s.worker, ".", 2)[0]
+ // The record's region is the boxes' placement scope ("ie").
+ raw := fmt.Sprintf(`{"schema":1,"account":%q,"app":"shop","name":%q,"host":%q,"channel":"stable","pool":%q,"region":"ie","created_at":"2026-10-26T09:00:00Z","ha":true}`, acct, name, s.worker, dwPool)
+ var rec provision.SidecarRecord
+ if err := json.Unmarshal([]byte(raw), &rec); err != nil {
+ t.Fatal(err)
+ }
+ if err := provision.CreateSidecarRecord(ctx, s.store, rec); err != nil {
+ t.Fatal(err)
+ }
+}
+
// tls makes the scene's CA and one leaf every box presents, publishes the
// leaf to control/certs/ as the issuer would (every edge's mirror then
// holds it, which is what names a peer on the control path), and points
@@ -618,6 +663,18 @@ func (s *dwScene) box(t *testing.T, name, ip string, ha bool) *dwBox {
t.Fatal(err)
}
}
+ if ha {
+ // The worker's row and lifetime, from the records pass.
+ if err := provision.ReconcileSidecars(t.Context(), s.store, x.reg, provision.ReconcileConfig{DataDir: b.DataDir, Lifetimes: b.Lifetimes, Pools: pools, Region: "ie"}); err != nil {
+ t.Fatal(err)
+ }
+ if row, err := x.reg.Get(s.worker); err != nil || row == nil || !row.HA || !row.IsSidecar() {
+ t.Fatalf("%s: worker row %+v %v", name, row, err)
+ }
+ if err := os.Symlink(bin, filepath.Join(b.OptDir, "live", s.worker)); err != nil {
+ t.Fatal(err)
+ }
+ }
x.eb = b
x.svc = activator.New(cfg, b, x.reg)
t.Cleanup(func() {
@@ -625,7 +682,8 @@ func (s *dwScene) box(t *testing.T, name, ip string, ha bool) *dwBox {
defer cancel()
x.svc.Shutdown(ctx)
})
- x.e, err = edge.New(x.reg, x.svc)
+ x.moves = &dwMoves{Service: x.svc, changed: make(chan struct{})}
+ x.e, err = edge.New(x.reg, x.moves)
if err != nil {
t.Fatal(err)
}
@@ -648,6 +706,19 @@ func (s *dwScene) box(t *testing.T, name, ip string, ha bool) *dwBox {
}
x.e.SetHAIngressLookup(ingress.lookup)
x.svc.SetHeldWakeHook(x.e.HeldWake)
+ // The duty view, as the agent wires it.
+ x.svc.DutyStore = x.reg
+ lifetimes := b.Lifetimes
+ x.svc.SetDutyView(func(rt registry.Route) boxchoice.WakeSnapshot {
+ if rt.IsSidecar() {
+ entry, ok := lifetimes.Lookup(rt.Host)
+ if !ok {
+ return boxchoice.WakeSnapshot{LocalDenied: true}
+ }
+ return x.e.SidecarDutySnapshot(rt, entry.SidecarPlacement)
+ }
+ return x.e.DutySnapshot(rt)
+ })
x.svc.SetDrainingSource(x.drain.IsDraining)
x.svc.SetPeerDrainView(x.e.PeerDraining)
x.e.SetPeerDrainedHook(x.svc.DropHoldersNaming)
@@ -756,6 +827,124 @@ func (s *dwScene) lock(t *testing.T, host string) hafresh.Lock {
return l
}
+// dwMoves is the activator the edge is handed: the real Service, with
+// each MoveState decision recorded and each hold's Wait observed (entered,
+// and what it returned). Every call goes through unchanged.
+type dwMoves struct {
+ *activator.Service
+ mu sync.Mutex
+ active map[string]int // holds in progress, by kind
+ entered map[string]int
+ ended []string // "<kind> <phase> <holder>"
+ changed chan struct{}
+}
+
+func dwAskKind(ask edge.MoveAsk) string {
+ switch {
+ case ask.Hop && ask.Replayable:
+ return "replayable-hop"
+ case ask.Hop:
+ return "hop"
+ case ask.Forwardable:
+ return "client"
+ }
+ return "unforwardable"
+}
+
+func (m *dwMoves) bump() {
+ close(m.changed)
+ m.changed = make(chan struct{})
+}
+
+func (m *dwMoves) MoveState(rt registry.Route, ask edge.MoveAsk) edge.MoveDecision {
+ d := m.Service.MoveState(rt, ask)
+ if d.Phase != edge.MoveHolding || d.Wait == nil {
+ return d
+ }
+ kind := rt.Host + " " + dwAskKind(ask)
+ m.mu.Lock()
+ if m.active == nil {
+ m.active, m.entered = map[string]int{}, map[string]int{}
+ }
+ m.active[kind]++
+ m.entered[kind]++
+ m.bump()
+ m.mu.Unlock()
+ wait := d.Wait
+ d.Wait = func(ctx context.Context) edge.MoveDecision {
+ r := wait(ctx)
+ m.mu.Lock()
+ m.active[kind]--
+ m.ended = append(m.ended, fmt.Sprintf("%s %d %s", kind, r.Phase, r.Holder))
+ m.bump()
+ m.mu.Unlock()
+ return r
+ }
+ return d
+}
+
+// waitHeld waits until want holds are in progress, by kind.
+func (m *dwMoves) waitHeld(t *testing.T, want map[string]int, bound time.Duration) {
+ t.Helper()
+ deadline := time.After(bound)
+ for {
+ m.mu.Lock()
+ ok := true
+ for k, n := range want {
+ if m.active[k] != n {
+ ok = false
+ }
+ }
+ got := fmt.Sprint(m.active)
+ ch := m.changed
+ m.mu.Unlock()
+ if ok {
+ return
+ }
+ select {
+ case <-ch:
+ case <-deadline:
+ t.Fatalf("holds in progress %s, want %v", got, want)
+ }
+ }
+}
+
+func (m *dwMoves) endedHolds() []string {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ return append([]string(nil), m.ended...)
+}
+
+// calledTaken is whether the driver has called SetMoveTaken.
+func calledTaken(o *dwObserver) bool {
+ for _, l := range o.log() {
+ if strings.HasPrefix(l, "taken ") {
+ return true
+ }
+ }
+ return false
+}
+
+// dwInOrder checks that want occurs in lines in order, each exactly once
+// (other lines may interleave).
+func dwInOrder(t *testing.T, lines, want []string) {
+ t.Helper()
+ pos := -1
+ for _, w := range want {
+ n, at := 0, -1
+ for i, l := range lines {
+ if l == w {
+ n++
+ at = i
+ }
+ }
+ if n != 1 || at < pos {
+ t.Fatalf("%q occurs %d times (at %d, after %d), want once in order:\n%s", w, n, at, pos, strings.Join(lines, "\n"))
+ }
+ pos = at
+ }
+}
+
// dwObserver is the drain driver's activator: the real Service, with the
// move calls recorded in order and BeginMove signalled. Every call goes
// through unchanged.
@@ -932,6 +1121,22 @@ func TestHeldHandoverTwoBoxMinio(t *testing.T) {
if r := s.do(C, "GET", s.host, "/", "via-c", nil, 0); r.status != 200 || !strings.HasPrefix(r.body, "annie|via-c") {
t.Fatalf("C's request before the move: %v", r)
}
+ // An HA worker (a born-HA sidecar, the kind the duty rule governs)
+ // awake on A: its duty is A's (HRW), and its lease is taken from an
+ // absent lock.
+ workerRT, err := A.reg.Get(s.worker)
+ if err != nil || workerRT == nil {
+ t.Fatal(workerRT, err)
+ }
+ if err := A.svc.WakeWorker(*workerRT); err != nil {
+ t.Fatalf("worker wake on A: %v", err)
+ }
+ if !A.svc.HoldsAwake(s.worker) || A.ctl.startCount(s.worker) != 1 {
+ t.Fatalf("the worker is not awake on A (starts %d)", A.ctl.startCount(s.worker))
+ }
+ if l := s.lock(t, s.worker); !strings.Contains(l.Owner, "ref=annie") || l.Release != nil {
+ t.Fatalf("worker lock after the wake: %+v", l)
+ }
// A slow request inside A's app keeps the move in its in-flight
// drain, so the requests below arrive while the host is held.
@@ -992,16 +1197,21 @@ func TestHeldHandoverTwoBoxMinio(t *testing.T) {
defer wg.Done()
chunked = s.do(C, "POST", s.host, "/chunked", "hop-3", io.MultiReader(strings.NewReader("chunk")), -1)
}()
- // The non-replayable hop is answered at once, while the host is still
- // held (the slow request is still in A's app).
+ // Both the direct request and the replayable hop are inside A's hold
+ // (MoveState answered holding and their Wait has not returned), and
+ // the non-replayable hop has been refused at once, all while the slow
+ // request is still in A's app. Only then does the move go on.
+ A.moves.waitHeld(t, map[string]int{s.host + " client": 1, s.host + " replayable-hop": 1}, 30*time.Second)
deadline := time.Now().Add(20 * time.Second)
for time.Now().Before(deadline) && A.svc.DrainHoldStatsNow().RefusedAtOnce == 0 {
time.Sleep(20 * time.Millisecond)
}
- if A.svc.DrainHoldStatsNow().RefusedAtOnce == 0 {
- t.Fatalf("the non-replayable hop was not refused at once; calls %v", obs.log())
+ if A.svc.DrainHoldStatsNow().RefusedAtOnce != 1 {
+ t.Fatalf("refused at once %d, want the non-replayable hop; calls %v", A.svc.DrainHoldStatsNow().RefusedAtOnce, obs.log())
+ }
+ if A.app(s.host).count("direct-1")+A.app(s.host).count("hop-2")+B.app(s.host).count("direct-1")+B.app(s.host).count("hop-2") != 0 || calledTaken(obs) {
+ t.Fatal("a held request was delivered before the take")
}
- time.Sleep(300 * time.Millisecond) // the direct request and the replayable hop reach their holds
app.mu.Lock()
close(app.slow)
app.slow = nil
@@ -1029,45 +1239,67 @@ func TestHeldHandoverTwoBoxMinio(t *testing.T) {
// fold (one LIST and a GET per edges file) on each of the two peers;
// for the host moved, the marker PUT and the successor's acquire
// (GET and PUT), plus at most one coalesced lock read for a
- // redirect; the plain host's legacy release; and the restore's reads,
+ // redirect; the worker's marker PUT; the plain host's legacy release
+ // (a DELETE); and the restore's reads,
// which the host's next wake would make anyway. Nothing else polls.
s3Sum, storeSum := dwSummary(s3Drain), dwSummary(storeDrain)
if storeSum["PUT edges"] != 2 || storeSum["LIST edges"] != 4 || storeSum["GET edges"] > 16 || len(storeDrain) != storeSum["PUT edges"]+storeSum["LIST edges"]+storeSum["GET edges"] {
t.Fatalf("deployment store calls during the drain: %v", storeDrain)
}
- if s3Sum["PUT lock"] != 2 || s3Sum["GET lock"] > 3 || s3Sum["DELETE lock"] != 1 || s3Sum["PUT files"] != 0 || s3Sum["other"]+s3Sum["GET other"]+s3Sum["PUT other"]+s3Sum["LIST other"] != 0 {
+ if s3Sum["PUT lock"] != 3 || s3Sum["GET lock"] > 3 || s3Sum["DELETE lock"] != 1 || s3Sum["PUT files"] != 0 || s3Sum["other"]+s3Sum["GET other"]+s3Sum["PUT other"]+s3Sum["LIST other"] != 0 {
t.Fatalf("S3 calls during the drain: %s\n%s", dwSorted(s3Sum), strings.Join(s3Drain, "\n"))
}
- // The sequence: BeginMove, the stop with its clean marker, the take
- // naming B, SetMoveTaken, and the redirects dropped only at the end.
- calls := strings.Join(obs.log(), "\n")
- for _, want := range []string{"begin " + s.host + " <nil>", "releasing " + s.host + " <nil>", "stop " + s.host + " marker=true clean=true <nil>", "taken " + s.host + " betty <nil>", "end-moves"} {
- if !strings.Contains(calls, want) {
- t.Fatalf("driver calls lack %q:\n%s", want, calls)
- }
+ // The sequence, in order and once each: BeginMove, releasing, the
+ // stop with its clean marker, SetMoveTaken naming B, and the redirects
+ // dropped only at the end. The worker and the plain host are stopped
+ // with clean markers before the end and never begun or taken.
+ lines := obs.log()
+ dwInOrder(t, lines, []string{"begin " + s.host + " <nil>", "releasing " + s.host + " <nil>", "stop " + s.host + " marker=true clean=true <nil>", "taken " + s.host + " betty <nil>", "end-moves"})
+ dwInOrder(t, lines, []string{"stop " + s.worker + " marker=true clean=true <nil>", "end-moves"})
+ dwInOrder(t, lines, []string{"stop " + s.plain + " marker=true clean=true <nil>", "end-moves"})
+ if len(lines) != 7 {
+ t.Fatalf("driver calls %d, want 7:\n%s", len(lines), strings.Join(lines, "\n"))
}
- if strings.Contains(calls, "left ") {
- t.Fatalf("a move failed:\n%s", calls)
+ // Each held request's Wait returned taken, naming B (phase 3).
+ ended := A.moves.endedHolds()
+ sort.Strings(ended)
+ if want := []string{s.host + " client 3 betty", s.host + " replayable-hop 3 betty"}; strings.Join(ended, "|") != strings.Join(want, "|") {
+ t.Fatalf("holds ended %v, want %v", ended, want)
}
if len(v.rep.Moved) != 1 || v.rep.Moved[0].Host != s.host || v.rep.Moved[0].Holder != "betty" || v.rep.Moved[0].Confirmed != "take" || v.rep.Moved[0].Gen < 2 {
t.Fatalf("moved: %+v", v.rep.Moved)
}
- var plainReleased bool
+ var plainReleased, workerReleased bool
for _, r := range v.rep.Released {
if r.Host == s.plain && r.Marker && r.Clean {
plainReleased = true
}
+ if r.Host == s.worker && r.Kind == "worker" && r.Marker && r.Clean {
+ workerReleased = true
+ }
if r.Host == s.host {
t.Fatalf("the HA host was released, not taken: %+v", r)
}
}
- if !plainReleased || len(v.rep.Unclean) != 0 || len(v.rep.Left) != 0 {
+ if !plainReleased || !workerReleased || len(v.rep.Released) != 2 || len(v.rep.Unclean) != 0 || len(v.rep.Left) != 0 {
t.Fatalf("released %+v unclean %v left %+v", v.rep.Released, v.rep.Unclean, v.rep.Left)
}
if B.ctl.startCount(s.plain) != 0 {
t.Fatal("the plain host was started on B")
}
+ // The worker: released with a clean marker naming A, taken by nobody.
+ // It resumes on its HRW box through the departure import, after the
+ // provider action; nothing in the drain starts it anywhere.
+ if l := s.lock(t, s.worker); l.Release == nil || l.Release.Box != "annie" || !l.Release.Clean {
+ t.Fatalf("worker lock after the drain: %+v (release %+v)", l, l.Release)
+ }
+ if B.ctl.startCount(s.worker) != 0 || B.svc.HoldsAwake(s.worker) || A.svc.HoldsAwake(s.worker) || A.ctl.startCount(s.worker) != 1 {
+ t.Fatal("the worker was started after its release")
+ }
+ if active, _, _ := A.ctl.unitState(t.Context(), "carlos-instance@"+s.worker+".service"); active != "inactive" {
+ t.Fatalf("the worker's unit on A is %s after its release", active)
+ }
if l := s.lock(t, s.host); !strings.Contains(l.Owner, "ref=betty") {
t.Fatalf("lock after the move: %+v", l)
}
@@ -1186,7 +1418,7 @@ func TestHeldHandoverLostLeaseMinio(t *testing.T) {
// today's answer.
held := make(chan dwReply, 1)
go func() { held <- s.do(A, "GET", s.host, "/held", "held", nil, 0) }()
- time.Sleep(300 * time.Millisecond)
+ A.moves.waitHeld(t, map[string]int{s.host + " client": 1}, 30*time.Second)
lockKey := "/" + s.bucket + "/" + activator.HibernatePrefix(s.prefix, s.host) + "/lock.json"
s.s3.setRefuse(func(method, path string) bool { return method == http.MethodPut && path == lockKey })
t.Cleanup(func() { s.s3.setRefuse(nil) })
@@ -1197,9 +1429,10 @@ func TestHeldHandoverLostLeaseMinio(t *testing.T) {
if r := <-slow; r.status != 200 {
t.Fatalf("the slow request: %v", r)
}
- // Wait for the stop's outcome: no marker.
+ // Wait for the move's end: the stop without a marker, then the move
+ // left (SetMoveLeft).
deadline := time.Now().Add(2 * time.Minute)
- for time.Now().Before(deadline) && !strings.Contains(strings.Join(obs.log(), "\n"), "stop "+s.host+" marker=false") {
+ for time.Now().Before(deadline) && !strings.Contains(strings.Join(obs.log(), "\n"), "left "+s.host) {
time.Sleep(50 * time.Millisecond)
}
calls := strings.Join(obs.log(), "\n")
@@ -1216,6 +1449,14 @@ func TestHeldHandoverLostLeaseMinio(t *testing.T) {
if h := <-held; h.status != http.StatusServiceUnavailable || h.header.Get("Retry-After") != "10" || A.app(s.host).count("held") != 0 || B.app(s.host).count("held") != 0 {
t.Fatalf("the request held across the failed move: %v", h)
}
+ // The one hold ends with the loss latch's answer (F-A, when the hold
+ // sees the latch first) or the failed move's (SetMoveLeft); both are
+ // today's 503 with Retry-After: 10, and neither delivers.
+ if ended := A.moves.endedHolds(); len(ended) != 1 || (ended[0] != fmt.Sprintf("%s client %d ", s.host, edge.MoveLost) && ended[0] != fmt.Sprintf("%s client %d ", s.host, edge.MoveRefused)) {
+ t.Fatalf("holds ended %v, want the one hold ended by the loss or the failed move", ended)
+ } else {
+ t.Logf("the held request's hold ended %q", ended[0])
+ }
// The answer is the loss latch's: A owes the release, and its forward
// decision for the host is the refusal F-A gives.
if q := A.svc.DrainQuietNow(); q.Owed == 0 {