From 338451c0ee46181310dbc8b4f15339001ba19ee3 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 18 Mar 2026 00:23:34 -0700 Subject: [PATCH] test: honor rust env in dual volume harness --- test/volume_server/framework/cluster_dual.go | 6 +++--- .../framework/cluster_interface.go | 8 ++++++-- .../framework/cluster_interface_test.go | 20 +++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 test/volume_server/framework/cluster_interface_test.go diff --git a/test/volume_server/framework/cluster_dual.go b/test/volume_server/framework/cluster_dual.go index b068419c0..1e3a2554c 100644 --- a/test/volume_server/framework/cluster_dual.go +++ b/test/volume_server/framework/cluster_dual.go @@ -11,7 +11,7 @@ import ( type DualVolumeCluster = MultiVolumeCluster // StartDualVolumeCluster starts a cluster with 2 volume servers. -// Deprecated: Use StartMultiVolumeCluster(t, profile, 2) directly. -func StartDualVolumeCluster(t testing.TB, profile matrix.Profile) *DualVolumeCluster { - return StartMultiVolumeCluster(t, profile, 2) +// Deprecated: Use StartMultiVolumeClusterAuto(t, profile, 2) directly. +func StartDualVolumeCluster(t testing.TB, profile matrix.Profile) MultiCluster { + return StartMultiVolumeClusterAuto(t, profile, 2) } diff --git a/test/volume_server/framework/cluster_interface.go b/test/volume_server/framework/cluster_interface.go index 59962eb11..875e66675 100644 --- a/test/volume_server/framework/cluster_interface.go +++ b/test/volume_server/framework/cluster_interface.go @@ -22,12 +22,16 @@ type TestCluster interface { Stop() } +func useRustVolumeServer() bool { + return os.Getenv("VOLUME_SERVER_IMPL") == "rust" +} + // StartVolumeCluster starts a single-volume cluster using either the Go or // Rust volume server, depending on the VOLUME_SERVER_IMPL environment variable. // Set VOLUME_SERVER_IMPL=rust to use the Rust volume server. func StartVolumeCluster(t testing.TB, profile matrix.Profile) TestCluster { t.Helper() - if os.Getenv("VOLUME_SERVER_IMPL") == "rust" { + if useRustVolumeServer() { return StartRustVolumeCluster(t, profile) } return StartSingleVolumeCluster(t, profile) @@ -52,7 +56,7 @@ type MultiCluster interface { // Set VOLUME_SERVER_IMPL=rust to use Rust volume servers. func StartMultiVolumeClusterAuto(t testing.TB, profile matrix.Profile, count int) MultiCluster { t.Helper() - if os.Getenv("VOLUME_SERVER_IMPL") == "rust" { + if useRustVolumeServer() { return StartRustMultiVolumeCluster(t, profile, count) } return StartMultiVolumeCluster(t, profile, count) diff --git a/test/volume_server/framework/cluster_interface_test.go b/test/volume_server/framework/cluster_interface_test.go new file mode 100644 index 000000000..58dceaf56 --- /dev/null +++ b/test/volume_server/framework/cluster_interface_test.go @@ -0,0 +1,20 @@ +package framework + +import "testing" + +func TestUseRustVolumeServer(t *testing.T) { + t.Setenv("VOLUME_SERVER_IMPL", "rust") + if !useRustVolumeServer() { + t.Fatalf("expected rust selection when VOLUME_SERVER_IMPL=rust") + } + + t.Setenv("VOLUME_SERVER_IMPL", "go") + if useRustVolumeServer() { + t.Fatalf("expected go selection when VOLUME_SERVER_IMPL=go") + } + + t.Setenv("VOLUME_SERVER_IMPL", "") + if useRustVolumeServer() { + t.Fatalf("expected go selection when VOLUME_SERVER_IMPL is unset") + } +}