refactor: close bounded phase 16 restart truth seams

Bind non-authoritative inventory, restart primary-truth rebasing, and sparse replica readiness retention into the heartbeat/master seam, and package the bounded finish-line checkpoint with explicit claims, non-claims, and proof commands.

Made-with: Cursor
This commit is contained in:
pingqiu committed 2026-04-04 16:13:06 -07:00
1 parent 10833c8b68
commit 0f72c8d062
12 files changed
+1491 -105

No files matched your search

+45
View File
@@ -1,6 +1,7 @@
package weed_server
import (
"path/filepath"
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
@@ -67,3 +68,47 @@ func TestMaintenanceMode(t *testing.T) {
})
}
}
func TestCollectBlockVolumeHeartbeat_IncludesInventoryAuthority(t *testing.T) {
vs := &VolumeServer{
store: &storage.Store{},
blockService: &BlockService{
blockStore: storage.NewBlockVolumeStore(),
blockInventoryAuthoritative: false,
},
}
hb := vs.collectBlockVolumeHeartbeat("127.0.0.1", 18080, "dc1", "rack1")
if hb.BlockVolumeInventoryAuthoritative == nil {
t.Fatal("expected block inventory authority bit to be present")
}
if hb.GetBlockVolumeInventoryAuthoritative() {
t.Fatal("expected non-authoritative block inventory bit on test heartbeat")
}
if !hb.HasNoBlockVolumes {
t.Fatal("expected empty heartbeat to report has_no_block_volumes")
}
}
func TestStartBlockService_ScanFailureEmitsNonAuthoritativeInventory(t *testing.T) {
missingDir := filepath.Join(t.TempDir(), "missing-block-dir")
bs := StartBlockService("127.0.0.1:3260", missingDir, "", "", NVMeConfig{})
if bs == nil {
t.Fatal("expected block service even when startup scan fails")
}
if bs.BlockInventoryAuthoritative() {
t.Fatal("startup scan failure should leave block inventory non-authoritative")
}
vs := &VolumeServer{
store: &storage.Store{},
blockService: bs,
}
hb := vs.collectBlockVolumeHeartbeat("127.0.0.1", 18080, "dc1", "rack1")
if hb.BlockVolumeInventoryAuthoritative == nil {
t.Fatal("expected inventory authority bit on startup-scan-failure heartbeat")
}
if hb.GetBlockVolumeInventoryAuthoritative() {
t.Fatal("startup-scan-failure heartbeat should be non-authoritative")
}
}