Browse Source

test: honor rust env in dual volume harness

rust-volume-server
Chris Lu 3 days ago
parent
commit
338451c0ee
  1. 6
      test/volume_server/framework/cluster_dual.go
  2. 8
      test/volume_server/framework/cluster_interface.go
  3. 20
      test/volume_server/framework/cluster_interface_test.go

6
test/volume_server/framework/cluster_dual.go

@ -11,7 +11,7 @@ import (
type DualVolumeCluster = MultiVolumeCluster type DualVolumeCluster = MultiVolumeCluster
// StartDualVolumeCluster starts a cluster with 2 volume servers. // 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)
} }

8
test/volume_server/framework/cluster_interface.go

@ -22,12 +22,16 @@ type TestCluster interface {
Stop() Stop()
} }
func useRustVolumeServer() bool {
return os.Getenv("VOLUME_SERVER_IMPL") == "rust"
}
// StartVolumeCluster starts a single-volume cluster using either the Go or // StartVolumeCluster starts a single-volume cluster using either the Go or
// Rust volume server, depending on the VOLUME_SERVER_IMPL environment variable. // Rust volume server, depending on the VOLUME_SERVER_IMPL environment variable.
// Set VOLUME_SERVER_IMPL=rust to use the Rust volume server. // Set VOLUME_SERVER_IMPL=rust to use the Rust volume server.
func StartVolumeCluster(t testing.TB, profile matrix.Profile) TestCluster { func StartVolumeCluster(t testing.TB, profile matrix.Profile) TestCluster {
t.Helper() t.Helper()
if os.Getenv("VOLUME_SERVER_IMPL") == "rust" {
if useRustVolumeServer() {
return StartRustVolumeCluster(t, profile) return StartRustVolumeCluster(t, profile)
} }
return StartSingleVolumeCluster(t, profile) return StartSingleVolumeCluster(t, profile)
@ -52,7 +56,7 @@ type MultiCluster interface {
// Set VOLUME_SERVER_IMPL=rust to use Rust volume servers. // Set VOLUME_SERVER_IMPL=rust to use Rust volume servers.
func StartMultiVolumeClusterAuto(t testing.TB, profile matrix.Profile, count int) MultiCluster { func StartMultiVolumeClusterAuto(t testing.TB, profile matrix.Profile, count int) MultiCluster {
t.Helper() t.Helper()
if os.Getenv("VOLUME_SERVER_IMPL") == "rust" {
if useRustVolumeServer() {
return StartRustMultiVolumeCluster(t, profile, count) return StartRustMultiVolumeCluster(t, profile, count)
} }
return StartMultiVolumeCluster(t, profile, count) return StartMultiVolumeCluster(t, profile, count)

20
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")
}
}
Loading…
Cancel
Save