test: keep production freshness during survivor rejoin

This commit is contained in:
pingqiu committed 2026-11-28 14:42:09 -08:00
1 parent 79a7801a9d
commit cd1768ae9f
1 file changed
+18 -2
@@ -29,7 +29,7 @@ func TestFencingRoundHealContinuesThePrimary(t *testing.T) { fencingRoundHeal(t,
// TestFencingRoundSurvivorRejoins is the same scenario carried one step
// further: once r3 can persist again, both replicas serve r1 at epoch 2
// (healthy peers of the primary).
// (healthy peers of the primary), even across a short host scheduling pause.
func TestFencingRoundSurvivorRejoins(t *testing.T) { fencingRoundHeal(t, true) }
func fencingRoundHeal(t *testing.T, rejoin bool) {
@@ -59,7 +59,10 @@ func fencingRoundHeal(t *testing.T, rejoin bool) {
master := h.start(t, "blockmaster", bins.master,
"--authority-store", filepath.Join(h.dir, "master", "authority"), "--lifecycle-store", filepath.Join(h.dir, "master", "lifecycle"),
"--cluster-spec", spec, "--expected-slots-per-volume", "3", "--lifecycle-product-loop-interval", "200ms",
"--freshness-window", "2s", "--launcher-replication-ack", "sync-quorum", "--listen", h.masterAddr)
// Keep the production default (30s). A 2s override turns a short
// scheduling pause during rejoin into another real fencing round,
// after which waiting for the old epoch can never succeed.
"--launcher-replication-ack", "sync-quorum", "--listen", h.masterAddr)
master.waitLog(t, 30*time.Second, "blockmaster: lock acquired")
for i, b := range hosts {
lockDir := b.root + ".locks"
@@ -171,6 +174,16 @@ func fencingRoundHeal(t *testing.T, rejoin bool) {
}
// 5. r3 can persist again: both replicas rejoin r1 at epoch 2.
healFloor()
// A deterministic slow-host control: longer than the former 2s test
// window, but below the production freshness window. Do not mistake it
// for a second primary failure. Cleanup already resumes a stopped child.
if err := r1.d.proc.Signal(syscall.SIGSTOP); err != nil {
t.Fatal(err)
}
time.Sleep(6 * time.Second)
if err := r1.d.proc.Signal(syscall.SIGCONT); err != nil {
t.Fatal(err)
}
waitPeersHealthy(t, r1.status, 2)
}
@@ -210,11 +223,14 @@ func waitPeersHealthy(t *testing.T, statusAddr string, epoch uint64) {
}
if json.Unmarshal(body, &st) == nil {
healthy := map[string]bool{}
var states []string
for _, p := range st.Peers {
states = append(states, fmt.Sprintf("%s=%s@%d", p.ReplicaID, p.State, p.Epoch))
if p.State == "healthy" && p.Epoch == epoch {
healthy[p.ReplicaID] = true
}
}
last = strings.Join(states, ", ")
if healthy["r2"] && healthy["r3"] {
return
}