diff --git a/server/handler_test.go b/server/handler_test.go index 71c8d2f78..50aef2764 100644 --- a/server/handler_test.go +++ b/server/handler_test.go @@ -1050,7 +1050,11 @@ func TestCluster_TranslateStore(t *testing.T) { func TestClusterTranslator(t *testing.T) { cluster := make(test.Cluster, 2) - cluster[0] = test.NewCommandNode(true) + cluster[0] = test.NewCommandNode(true, + server.OptCommandServerOptions( + pilosa.OptServerOpenTranslateStore(boltdb.OpenTranslateStore), + ), + ) cluster[0].Config.Gossip.Port = "0" err := cluster[0].Start() if err != nil { diff --git a/test/pilosa.go b/test/pilosa.go index 34880e627..5a5e8c67b 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -89,6 +89,10 @@ func newCommand(opts ...server.CommandOption) *Command { // NewCommandNode returns a new instance of Command with clustering enabled. func NewCommandNode(isCoordinator bool, opts ...server.CommandOption) *Command { + // We want tests to default to using the in-memory translate store, so we + // prepend opts with that functional option. If a different translate store + // has been specified, it will override this one. + opts = prependWithMemStore(opts) m := newCommand(opts...) m.Config.Cluster.Disabled = false m.Config.Cluster.Coordinator = isCoordinator @@ -398,6 +402,11 @@ func runCluster(size int, opts ...[]server.CommandOption) (Cluster, error) { // MustRunCluster creates and starts a new cluster func MustRunCluster(tb testing.TB, size int, opts ...[]server.CommandOption) Cluster { + // We want tests to default to using the in-memory translate store, so we + // prepend opts with that functional option. If a different translate store + // has been specified, it will override this one. + opts = prependOpts(opts) + tb.Helper() c, err := runCluster(size, opts...) if err != nil { @@ -406,6 +415,29 @@ func MustRunCluster(tb testing.TB, size int, opts ...[]server.CommandOption) Clu return c } +// prependOpts applies prependWithMemStore to each of the ops (one per +// node, or one for the entire cluser). +func prependOpts(opts [][]server.CommandOption) [][]server.CommandOption { + if len(opts) == 0 { + opts = [][]server.CommandOption{ + prependWithMemStore([]server.CommandOption{}), + } + } else { + for i := range opts { + opts[i] = prependWithMemStore(opts[i]) + } + } + return opts +} + +// prependWithMemStore prepends opts with the OpenInMemTranslateStore. +func prependWithMemStore(opts []server.CommandOption) []server.CommandOption { + defaultOpts := []server.CommandOption{ + server.OptCommandServerOptions(pilosa.OptServerOpenTranslateStore(pilosa.OpenInMemTranslateStore)), + } + return append(defaultOpts, opts...) +} + //////////////////////////////////////////////////////////////////////////////////// // MustDo executes http.Do() with an http.NewRequest(). Panic on error.