diff --git a/seaweed-block/core/ops/volume_status_report_test.go b/seaweed-block/core/ops/volume_status_report_test.go index 13ed654fb8..b8e60cb837 100644 --- a/seaweed-block/core/ops/volume_status_report_test.go +++ b/seaweed-block/core/ops/volume_status_report_test.go @@ -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) + } + }) + } +}