mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
master: the line-wake test orders its builds so only the hook can wake the last
The test now drains the initial build and the grace's rebuild before the one heartbeat, whose single wake is consumed by the build showing v1 supported; the controller binds after it, and with no heartbeat, expiry or GC tick left, the build carrying the line can only come from the hook. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
75bb94c46d
commit
1cb5e0e124
1 file changed
+44
-20
@@ -9,10 +9,16 @@ import (
|
||||
)
|
||||
|
||||
// A published line wakes the observation build, through the master's
|
||||
// wiring of the publisher's line-change hook: a volume reported once (no
|
||||
// heartbeat follows) is bound by the controller, and the next build carries
|
||||
// that line. Timestamp-only heartbeats wake nothing, so without the wiring
|
||||
// the build would keep the unbound basis until some unrelated change.
|
||||
// wiring of the publisher's line-change hook. The order is made
|
||||
// deterministic so no other wake can stand in for the hook:
|
||||
// - the master starts with nothing ingested; its initial build runs, and
|
||||
// the 1 ms pending grace's deadline is consumed (its rebuild runs too);
|
||||
// - after the builds drain, one heartbeat is ingested: its single wake is
|
||||
// consumed by one build whose snapshot already holds it (the snapshot is
|
||||
// taken after the wake is received), showing v1 supported and unbound;
|
||||
// - the controller binds v1 after that build. No heartbeat follows, no
|
||||
// expiry is due (a one-hour window), and there is no GC tick: a later
|
||||
// build carrying the line can only come from the hook.
|
||||
func TestMasterRebuildsObservationOnAPublishedLine(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("the lifecycle stores need directory fsync")
|
||||
@@ -21,8 +27,7 @@ func TestMasterRebuildsObservationOnAPublishedLine(t *testing.T) {
|
||||
AuthorityStoreDir: t.TempDir(),
|
||||
LifecycleStoreDir: t.TempDir(),
|
||||
Listen: "127.0.0.1:0",
|
||||
// No expiry and no GC wake within the test.
|
||||
Freshness: authority.FreshnessConfig{FreshnessWindow: time.Hour},
|
||||
Freshness: authority.FreshnessConfig{FreshnessWindow: time.Hour, PendingGrace: time.Millisecond},
|
||||
Topology: authority.AcceptedTopology{Volumes: []authority.VolumeExpected{{
|
||||
VolumeID: "v1",
|
||||
Slots: []authority.ExpectedSlot{{ReplicaID: "r1", ServerID: "node-a"}},
|
||||
@@ -33,26 +38,45 @@ func TestMasterRebuildsObservationOnAPublishedLine(t *testing.T) {
|
||||
}
|
||||
h.Start()
|
||||
defer closeTestMaster(t, h)
|
||||
waitBuild := func(what string, ok func(authority.BuildResult) bool) authority.BuildResult {
|
||||
t.Helper()
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
if b, have := h.obs.LastBuild(); have && ok(b) {
|
||||
return b
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
b, _ := h.obs.LastBuild()
|
||||
t.Fatalf("%s: last build %+v", what, b.Snapshot.Volumes)
|
||||
return authority.BuildResult{}
|
||||
}
|
||||
waitBuild("the initial build", func(authority.BuildResult) bool { return true })
|
||||
time.Sleep(300 * time.Millisecond) // the grace's deadline fires and its rebuild drains
|
||||
if err := h.obs.IngestHeartbeat(authority.HeartbeatMessage{
|
||||
ServerID: "node-a", SentAt: time.Now().UTC(), Reachable: true, Eligible: true,
|
||||
Slots: []authority.HeartbeatSlot{{VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:9201", CtrlAddr: "127.0.0.1:9101", Reachable: true, ReadyForPrimary: true, Eligible: true}},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
if line, ok := h.Publisher().VolumeAuthorityLine("v1"); ok && line.Assigned {
|
||||
if b, have := h.obs.LastBuild(); have {
|
||||
for _, v := range b.Snapshot.Volumes {
|
||||
if v.VolumeID == "v1" && v.Authority.Assigned && v.Authority.Epoch == line.Epoch {
|
||||
return
|
||||
}
|
||||
}
|
||||
waitBuild("the heartbeat's build (v1 supported)", func(b authority.BuildResult) bool {
|
||||
for _, v := range b.Snapshot.Volumes {
|
||||
if v.VolumeID == "v1" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
}
|
||||
line, ok := h.Publisher().VolumeAuthorityLine("v1")
|
||||
b, _ := h.obs.LastBuild()
|
||||
t.Fatalf("published line %+v (%v), but the last build's volumes are %+v", line, ok, b.Snapshot.Volumes)
|
||||
return false
|
||||
})
|
||||
waitBuild("the build after the controller's publication", func(b authority.BuildResult) bool {
|
||||
line, ok := h.Publisher().VolumeAuthorityLine("v1")
|
||||
if !ok || !line.Assigned {
|
||||
return false
|
||||
}
|
||||
for _, v := range b.Snapshot.Volumes {
|
||||
if v.VolumeID == "v1" && v.Authority.Assigned && v.Authority.Epoch == line.Epoch {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user