mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
weed filer -s3 checked the broker port against the filer, metrics, read-only, WebDAV, IAM and SFTP ports but not -debug.port, which the debug server binds before the broker starts. weed server already includes it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
2.7 KiB
Go
75 lines
2.7 KiB
Go
package command
|
|
|
|
import "testing"
|
|
|
|
func TestFilerS3MqBrokerFlagDefaults(t *testing.T) {
|
|
for name, want := range map[string]string{
|
|
"s3": "false",
|
|
"s3.mq.broker": "false",
|
|
"s3.mq.broker.port": "17777",
|
|
} {
|
|
flag := cmdFiler.Flag.Lookup(name)
|
|
if flag == nil {
|
|
t.Fatalf("weed filer does not expose -%s", name)
|
|
}
|
|
if flag.DefValue != want {
|
|
t.Errorf("-%s default = %q, want %q", name, flag.DefValue, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestFilerRunsMqBrokerOnlyBesideS3(t *testing.T) {
|
|
oldS3, oldBroker := *filerStartS3, *filerStartS3MqBroker
|
|
defer func() { *filerStartS3, *filerStartS3MqBroker = oldS3, oldBroker }()
|
|
for _, tc := range mqBrokerDefaultCases {
|
|
t.Run("-s3 "+tc.name, func(t *testing.T) {
|
|
withMqBrokerTLS(t, tc.tls)
|
|
*filerStartS3, *filerStartS3MqBroker = true, tc.value
|
|
if got := filerRunsMqBrokerBesideS3(tc.passed); got != tc.want {
|
|
t.Errorf("runs broker %v, want %v", got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
t.Run("no -s3", func(t *testing.T) {
|
|
withMqBrokerTLS(t, true)
|
|
*filerStartS3, *filerStartS3MqBroker = false, true
|
|
if filerRunsMqBrokerBesideS3(true) {
|
|
t.Error("broker started without the S3 gateway")
|
|
}
|
|
})
|
|
}
|
|
|
|
// weed filer -s3 -webdav -webdav.port=17777, weed filer -port=7777 -s3
|
|
// whose filer gRPC port is 17777, and weed filer -s3 -debug -debug.port=17777.
|
|
func TestFilerDefaultBrokerYieldsToFilerProcessPorts(t *testing.T) {
|
|
port, portGrpc, webdav, webdavPort := *f.port, *f.portGrpc, *filerStartWebDav, *filerWebDavOptions.port
|
|
debug, debugPort := *f.debug, *f.debugPort
|
|
t.Cleanup(func() {
|
|
*f.port, *f.portGrpc, *filerStartWebDav, *filerWebDavOptions.port = port, portGrpc, webdav, webdavPort
|
|
*f.debug, *f.debugPort = debug, debugPort
|
|
})
|
|
for _, tc := range []struct {
|
|
name string
|
|
filerPort, webdavPort int
|
|
webdav bool
|
|
debugPort int
|
|
}{
|
|
{"-webdav.port on the broker port", 8888, 17777, true, 0},
|
|
{"-port whose derived gRPC port is the broker's", 7777, 7333, false, 0},
|
|
{"-debug.port on the broker port", 8888, 7333, false, 17777},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
*f.port, *f.portGrpc, *filerStartWebDav, *filerWebDavOptions.port = tc.filerPort, 0, tc.webdav, tc.webdavPort
|
|
*f.debug, *f.debugPort = tc.debugPort != 0, tc.debugPort
|
|
s3opt := gatewayWithBroker(8333, 0, 17777)
|
|
if err := s3opt.checkMqBrokerPort("s3.mq.broker.port", false, filerPortsBesideS3()...); err != nil || s3opt.mqBroker != nil {
|
|
t.Fatalf("default broker on a filer process port: err %v, broker kept %v", err, s3opt.mqBroker != nil)
|
|
}
|
|
s3opt = gatewayWithBroker(8333, 0, 17777)
|
|
if err := s3opt.checkMqBrokerPort("s3.mq.broker.port", true, filerPortsBesideS3()...); err == nil {
|
|
t.Fatal("explicit -s3.mq.broker.port on a filer process port was accepted")
|
|
}
|
|
})
|
|
}
|
|
}
|