From f13861aaa4e3f9014b1fcec75bc3d5b5c9d9ac78 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 18 Mar 2026 00:35:48 -0700 Subject: [PATCH] test: pass readMode to rust volume harnesses --- .../framework/cluster_multi_rust.go | 29 +++------- test/volume_server/framework/cluster_rust.go | 56 +++++++++++++------ .../framework/cluster_rust_test.go | 38 +++++++++++++ 3 files changed, 86 insertions(+), 37 deletions(-) create mode 100644 test/volume_server/framework/cluster_rust_test.go diff --git a/test/volume_server/framework/cluster_multi_rust.go b/test/volume_server/framework/cluster_multi_rust.go index a9378d2ce..45b9572ae 100644 --- a/test/volume_server/framework/cluster_multi_rust.go +++ b/test/volume_server/framework/cluster_multi_rust.go @@ -223,26 +223,15 @@ func (c *RustMultiVolumeCluster) startRustVolume(index int, dataDir string) erro return err } - args := []string{ - "--port", strconv.Itoa(c.volumePorts[index]), - "--port.grpc", strconv.Itoa(c.volumeGrpcPorts[index]), - "--port.public", strconv.Itoa(c.volumePubPorts[index]), - "--ip", "127.0.0.1", - "--ip.bind", "127.0.0.1", - "--dir", dataDir, - "--max", "16", - "--master", "127.0.0.1:" + strconv.Itoa(c.masterPort), - "--securityFile", filepath.Join(c.configDir, "security.toml"), - "--concurrentUploadLimitMB", strconv.Itoa(c.profile.ConcurrentUploadLimitMB), - "--concurrentDownloadLimitMB", strconv.Itoa(c.profile.ConcurrentDownloadLimitMB), - "--preStopSeconds", "0", - } - if c.profile.InflightUploadTimeout > 0 { - args = append(args, "--inflightUploadDataTimeout", c.profile.InflightUploadTimeout.String()) - } - if c.profile.InflightDownloadTimeout > 0 { - args = append(args, "--inflightDownloadDataTimeout", c.profile.InflightDownloadTimeout.String()) - } + args := rustVolumeArgs( + c.profile, + c.configDir, + c.masterPort, + c.volumePorts[index], + c.volumeGrpcPorts[index], + c.volumePubPorts[index], + dataDir, + ) cmd := exec.Command(c.rustVolumeBinary, args...) cmd.Dir = c.baseDir diff --git a/test/volume_server/framework/cluster_rust.go b/test/volume_server/framework/cluster_rust.go index fe2175ea3..5d5f56a14 100644 --- a/test/volume_server/framework/cluster_rust.go +++ b/test/volume_server/framework/cluster_rust.go @@ -184,33 +184,55 @@ func (rc *RustCluster) startMaster(dataDir string) error { return rc.masterCmd.Start() } -func (rc *RustCluster) startRustVolume(dataDir string) error { - logFile, err := os.Create(filepath.Join(rc.logsDir, "volume.log")) - if err != nil { - return err - } - +func rustVolumeArgs( + profile matrix.Profile, + configDir string, + masterPort int, + volumePort int, + volumeGrpcPort int, + volumePubPort int, + dataDir string, +) []string { args := []string{ - "--port", strconv.Itoa(rc.volumePort), - "--port.grpc", strconv.Itoa(rc.volumeGrpcPort), - "--port.public", strconv.Itoa(rc.volumePubPort), + "--port", strconv.Itoa(volumePort), + "--port.grpc", strconv.Itoa(volumeGrpcPort), + "--port.public", strconv.Itoa(volumePubPort), "--ip", "127.0.0.1", "--ip.bind", "127.0.0.1", "--dir", dataDir, "--max", "16", - "--master", "127.0.0.1:" + strconv.Itoa(rc.masterPort), - "--securityFile", filepath.Join(rc.configDir, "security.toml"), - "--concurrentUploadLimitMB", strconv.Itoa(rc.profile.ConcurrentUploadLimitMB), - "--concurrentDownloadLimitMB", strconv.Itoa(rc.profile.ConcurrentDownloadLimitMB), + "--master", "127.0.0.1:" + strconv.Itoa(masterPort), + "--securityFile", filepath.Join(configDir, "security.toml"), + "--readMode", profile.ReadMode, + "--concurrentUploadLimitMB", strconv.Itoa(profile.ConcurrentUploadLimitMB), + "--concurrentDownloadLimitMB", strconv.Itoa(profile.ConcurrentDownloadLimitMB), "--preStopSeconds", "0", } - if rc.profile.InflightUploadTimeout > 0 { - args = append(args, "--inflightUploadDataTimeout", rc.profile.InflightUploadTimeout.String()) + if profile.InflightUploadTimeout > 0 { + args = append(args, "--inflightUploadDataTimeout", profile.InflightUploadTimeout.String()) + } + if profile.InflightDownloadTimeout > 0 { + args = append(args, "--inflightDownloadDataTimeout", profile.InflightDownloadTimeout.String()) } - if rc.profile.InflightDownloadTimeout > 0 { - args = append(args, "--inflightDownloadDataTimeout", rc.profile.InflightDownloadTimeout.String()) + return args +} + +func (rc *RustCluster) startRustVolume(dataDir string) error { + logFile, err := os.Create(filepath.Join(rc.logsDir, "volume.log")) + if err != nil { + return err } + args := rustVolumeArgs( + rc.profile, + rc.configDir, + rc.masterPort, + rc.volumePort, + rc.volumeGrpcPort, + rc.volumePubPort, + dataDir, + ) + rc.volumeCmd = exec.Command(rc.rustVolumeBinary, args...) rc.volumeCmd.Dir = rc.baseDir rc.volumeCmd.Stdout = logFile diff --git a/test/volume_server/framework/cluster_rust_test.go b/test/volume_server/framework/cluster_rust_test.go new file mode 100644 index 000000000..f2558753a --- /dev/null +++ b/test/volume_server/framework/cluster_rust_test.go @@ -0,0 +1,38 @@ +package framework + +import ( + "testing" + "time" + + "github.com/seaweedfs/seaweedfs/test/volume_server/matrix" +) + +func TestRustVolumeArgsIncludeReadMode(t *testing.T) { + profile := matrix.P1() + profile.ReadMode = "redirect" + profile.ConcurrentUploadLimitMB = 7 + profile.ConcurrentDownloadLimitMB = 9 + profile.InflightUploadTimeout = 3 * time.Second + profile.InflightDownloadTimeout = 4 * time.Second + + args := rustVolumeArgs(profile, "/tmp/config", 9333, 18080, 28080, 38080, "/tmp/data") + + assertArgPair(t, args, "--readMode", "redirect") + assertArgPair(t, args, "--concurrentUploadLimitMB", "7") + assertArgPair(t, args, "--concurrentDownloadLimitMB", "9") + assertArgPair(t, args, "--inflightUploadDataTimeout", "3s") + assertArgPair(t, args, "--inflightDownloadDataTimeout", "4s") +} + +func assertArgPair(t *testing.T, args []string, flag string, want string) { + t.Helper() + for i := 0; i+1 < len(args); i += 2 { + if args[i] == flag { + if args[i+1] != want { + t.Fatalf("%s value mismatch: got %q want %q", flag, args[i+1], want) + } + return + } + } + t.Fatalf("missing %s in args: %v", flag, args) +}