Files
seaweedfs/weed/admin/dash/admin_data_test.go
T
Chris LuandClaude Opus 5.5 3f557b73c8 admin: show the right master ports when -port.grpc is not port+10000 (#12570)
* admin: take master HTTP ports from raft member names

The masters page and dashboard turned each raft member's gRPC address
into an HTTP address by subtracting 10000 from the port, so masters with
a custom -port.grpc showed wrong or negative ports. Raft members are
named after their master address, which carries the HTTP port; use it
and keep the old derivation only for names that are not addresses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: test raft member address mapping

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:22:29 -08:00

29 lines
1.0 KiB
Go

package dash
import (
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
)
func TestRaftMasterHttpAddress(t *testing.T) {
tests := []struct {
name, id, address, want string
}{
{"goraft names members by full address", "127.101.0.1:11111.11112", "127.101.0.1:11112", "127.101.0.1:11111"},
{"hashicorp names members by http address", "127.102.0.1:2222", "127.102.0.1:3333", "127.102.0.1:2222"},
{"default ports", "10.0.0.1:9333", "10.0.0.1:19333", "10.0.0.1:9333"},
{"ipv6", "[::1]:2222.3333", "[::1]:3333", "[::1]:2222"},
{"id that is not an address", "master-a", "10.0.0.2:19333", "10.0.0.2:9333"},
{"id without a valid port", "10.0.0.3:0", "10.0.0.3:19334", "10.0.0.3:9334"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := raftMasterHttpAddress(&master_pb.RaftListClusterServersResponse_ClusterServers{Id: tt.id, Address: tt.address})
if got != tt.want {
t.Errorf("raftMasterHttpAddress(%q, %q) = %q, want %q", tt.id, tt.address, got, tt.want)
}
})
}
}