Status test: a healthy volume shows no binary_too_old; match by volume id

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-12-02 10:01:51 -08:00
1 parent 8fe764c039
commit a6f01f4aff
2 files changed
+24 -6

No files matched your search

@@ -17,6 +17,7 @@ type binaryTooOldStatusServer struct{ inspectionControlServer }
func (s binaryTooOldStatusServer) GetClusterStatus(ctx context.Context, q *control.GetClusterStatusRequest) (*control.ClusterStatusResponse, error) {
r, err := s.inspectionControlServer.GetClusterStatus(ctx, q)
r.Volumes = append(r.Volumes, &control.VolumeEvidence{VolumeId: "v-healthy", Status: "ok"})
r.Volumes[0].Conditions = append(r.Volumes[0].Conditions, &control.ObservationCondition{
Type: "HolderReadsFormat", Status: "false", Reason: "binary_too_old", Severity: "error",
Message: "node host-b's process for this volume reads format level 0; the cluster's format level is 1: no grant (binary_too_old)",
@@ -43,6 +44,7 @@ func TestClusterStatusJSONShowsABinaryTooOldHolder(t *testing.T) {
}
var body struct {
Volumes []struct {
VolumeID string `json:"volume_id"`
Conditions []struct {
Reason string `json:"reason"`
Message string `json:"message"`
@@ -52,12 +54,19 @@ func TestClusterStatusJSONShowsABinaryTooOldHolder(t *testing.T) {
if err := json.Unmarshal(out.Bytes(), &body); err != nil {
t.Fatal(err)
}
shown := map[string]bool{} // volume id -> has the binary_too_old condition
for _, v := range body.Volumes {
shown[v.VolumeID] = shown[v.VolumeID] || false
for _, c := range v.Conditions {
if c.Reason == "binary_too_old" && bytes.Contains([]byte(c.Message), []byte("host-b's process for this volume reads format level 0")) {
return
shown[v.VolumeID] = true
}
}
}
t.Fatalf("cluster status --json has no binary_too_old condition: %s", &out)
if !shown["v1"] {
t.Fatalf("cluster status --json: volume v1 has no binary_too_old condition: %s", &out)
}
if healthy, listed := shown["v-healthy"]; !listed || healthy {
t.Fatalf("cluster status --json: the healthy volume listed %v, with binary_too_old %v: %s", listed, healthy, &out)
}
}
@@ -636,6 +636,8 @@ func TestAHolderRestartedOnAnOldBinaryIsNotReissuedItsLine(t *testing.T) {
}
r.createVolume(t, "v")
r.place(t, "v", "node-b")
r.createVolume(t, "w") // the control volume: its holder reads level 1
r.place(t, "w", "node-b")
beat := func(inc string, reads uint32) {
t.Helper()
if _, err := r.obs.ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-b", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, ReadsLevel: reads,
@@ -696,16 +698,23 @@ func TestAHolderRestartedOnAnOldBinaryIsNotReissuedItsLine(t *testing.T) {
if err != nil {
t.Fatal(err)
}
found := false
found, seenW := false, false
for _, vol := range st.GetVolumes() {
seenW = seenW || vol.GetVolumeId() == "w"
for _, c := range vol.GetConditions() {
if vol.GetVolumeId() == "v" && c.GetReason() == "binary_too_old" && strings.Contains(c.GetMessage(), "node node-b's process for this volume reads format level 0") {
if c.GetReason() != "binary_too_old" {
continue
}
if vol.GetVolumeId() != "v" {
t.Fatalf("volume %s, held by a process reading level 1, shows binary_too_old: %v", vol.GetVolumeId(), c)
}
if strings.Contains(c.GetMessage(), "node node-b's process for this volume reads format level 0") {
found = true
}
}
}
if !found {
t.Fatalf("the master's status does not show v's refused holder: %v", st.GetVolumes())
if !found || !seenW {
t.Fatalf("the master's status: v's refused holder shown %v, control volume w listed %v: %v", found, seenW, st.GetVolumes())
}
})
}