Files
seaweedfs/weed/storage/volume_info_test.go
T
Chris Lu 65b9ae7704 master: keep disk_id when registering volumes from incremental heartbeats (#10686)
The volume server names the directory index in every
VolumeShortInformationMessage, but NewVolumeInfoFromShort dropped it, so
volumes registered through the incremental new-volume path showed
disk_id 0 at the master until a full report -- misreporting multi-dir
servers in volume.list and the per-physical-disk topology views.

Claude-Session: https://claude.ai/code/session_01QdTEEPbg4MtcoEGwqbgtZC
2026-08-10 00:40:29 -07:00

43 lines
711 B
Go

package storage
import (
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
)
func TestSortVolumeInfos(t *testing.T) {
vis := []*VolumeInfo{
&VolumeInfo{
Id: 2,
},
&VolumeInfo{
Id: 1,
},
&VolumeInfo{
Id: 3,
},
}
sortVolumeInfos(vis)
for i := 0; i < len(vis); i++ {
if vis[i].Id != needle.VolumeId(i+1) {
t.Fatal()
}
}
}
func TestNewVolumeInfoFromShortKeepsDiskId(t *testing.T) {
vi, err := NewVolumeInfoFromShort(&master_pb.VolumeShortInformationMessage{
Id: 7,
Version: 3,
DiskId: 3,
})
if err != nil {
t.Fatal(err)
}
if vi.DiskId != 3 {
t.Fatalf("DiskId = %d, want 3", vi.DiskId)
}
}