Files
seaweedfs/weed/shell/command_cluster_check_placement_test.go
T
Chris LuandClaude Opus 5.5 f0fad41a3a shell: cluster.check prints placement warnings before the capacity checks
A disk type with no free slots made cluster.check return before the
default data center/rack warnings were printed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 13:44:50 -08:00

30 lines
832 B
Go

package shell
import (
"bytes"
"strings"
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"github.com/seaweedfs/seaweedfs/weed/topology"
)
func TestPrintDefaultPlacementWarnings(t *testing.T) {
topo := &master_pb.TopologyInfo{
DataCenterInfos: []*master_pb.DataCenterInfo{
{Id: "dc1", RackInfos: []*master_pb.RackInfo{
{Id: "r1", DataNodeInfos: []*master_pb.DataNodeInfo{{Id: "10.0.0.1:8080"}}},
}},
{Id: topology.DefaultDataCenter, RackInfos: []*master_pb.RackInfo{
{Id: topology.DefaultRack, DataNodeInfos: []*master_pb.DataNodeInfo{{Id: "10.0.0.2:8080"}}},
}},
},
}
var buf bytes.Buffer
printDefaultPlacementWarnings(&buf, topo)
out := buf.String()
if strings.Count(out, "warning:") != 1 || !strings.Contains(out, "10.0.0.2:8080") {
t.Fatalf("unexpected output: %q", out)
}
}