mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
test: retain chunk status in volume reports
This commit is contained in:
1 parent
0d499a9859
commit
09b3fe445b
1 file changed
+39
@@ -534,3 +534,42 @@ func firstMapFromSlice(t *testing.T, v any) map[string]any {
|
||||
}
|
||||
return asMap(t, items[0])
|
||||
}
|
||||
|
||||
func TestBuildVolumeStatusReport_PreservesChunkStatus(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
chunk *durable.ChunkStatus
|
||||
}{
|
||||
{name: "walstore-chunk", chunk: &durable.ChunkStatus{Attached: true, RemoteLSN: 42}},
|
||||
{name: "walstore"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
report := BuildVolumeStatusReport(VolumeStatusReportInput{
|
||||
Durable: []durable.VolumeStatus{{VolumeID: "v1", Impl: tc.name, Chunk: tc.chunk}},
|
||||
})
|
||||
data, err := json.Marshal(report)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var decoded struct {
|
||||
Durable []struct {
|
||||
Chunk *durable.ChunkStatus `json:"chunk"`
|
||||
} `json:"durable"`
|
||||
}
|
||||
if err := json.Unmarshal(data, &decoded); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(decoded.Durable) != 1 {
|
||||
t.Fatalf("durable entries = %d, want 1", len(decoded.Durable))
|
||||
}
|
||||
got := decoded.Durable[0].Chunk
|
||||
if tc.chunk == nil {
|
||||
if got != nil {
|
||||
t.Fatalf("plain walstore has chunk status: %+v", got)
|
||||
}
|
||||
} else if got == nil || !got.Attached || got.RemoteLSN != 42 {
|
||||
t.Fatalf("chunk status lost from report: %s", data)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user