Files
seaweedfs/weed/admin/dash/admin_server_filergroup_test.go
T
9d75048594 admin: respect filerGroup for cluster discovery (#10170)
* Respect filerGroup in admin discovery

Admin discovery previously queried master cluster nodes with an empty filer group, so filers registered under a non-default group could not appear in the admin UI. Add an admin filerGroup flag and carry it through cluster-node discovery requests while preserving the empty default behavior.

Constraint: SeaweedFS master ListClusterNodes filters by exact filer_group.

Rejected: Discover all groups implicitly | no existing admin or shell behavior exposes cross-group discovery.

Confidence: high

Scope-risk: narrow

Directive: Keep admin cluster discovery scoped to the configured filerGroup unless an explicit all-groups API is added.

Tested: docker run --rm -v "$PWD:/src" -w /src golang:1.25 go test ./weed/admin/dash -run TestListClusterNodesRequest -count=1

Tested: docker run --rm -v "$PWD:/src" -w /src golang:1.25 go test ./weed/command -run '^$' -count=1

Not-tested: full repository test suite

* mini: pass filer group to admin cluster discovery

miniAdminOptions.filerGroup was never initialized, so startAdminServer
dereferenced a nil *string. Share the filer.filerGroup flag pointer so the
co-located admin queries the same group the filer registers under.

---------

Co-authored-by: Chris Lu <chris.lu@gmail.com>
2026-07-01 10:56:58 -07:00

31 lines
739 B
Go

package dash
import (
"testing"
"github.com/seaweedfs/seaweedfs/weed/cluster"
)
func TestListClusterNodesRequestIncludesFilerGroup(t *testing.T) {
server := &AdminServer{filerGroup: "tenant-a"}
req := server.listClusterNodesRequest(cluster.FilerType)
if req.ClientType != cluster.FilerType {
t.Fatalf("ClientType = %q, want %q", req.ClientType, cluster.FilerType)
}
if req.FilerGroup != "tenant-a" {
t.Fatalf("FilerGroup = %q, want %q", req.FilerGroup, "tenant-a")
}
}
func TestListClusterNodesRequestKeepsDefaultFilerGroupEmpty(t *testing.T) {
server := &AdminServer{}
req := server.listClusterNodesRequest(cluster.FilerType)
if req.FilerGroup != "" {
t.Fatalf("FilerGroup = %q, want empty", req.FilerGroup)
}
}