From 744827d5cc03e51d236ac1272e58eb3a5b38366f Mon Sep 17 00:00:00 2001 From: "Jason E. Aten" Date: Mon, 16 Nov 2020 23:18:50 +0000 Subject: [PATCH] restore the env variable PILOSA_TXSRC's affect --- ctl/server.go | 5 ++++- ctl/server_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ctl/server.go b/ctl/server.go index 629aac3dd..129556b23 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -15,6 +15,7 @@ package ctl import ( + "fmt" "time" "github.com/pilosa/pilosa/v2" @@ -89,7 +90,9 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags.IntVar(&srv.Config.Profile.MutexFraction, "profile.mutex-fraction", srv.Config.Profile.MutexFraction, "Sampling fraction for mutex contention profiling. Sample 1/ of events.") // Transactional storage engine - flags.StringVarP(&srv.Config.Txsrc, "tx", "", pilosa.DefaultTxsrc, "transaction/storage to use: one of roaring, rbf, bolt, lmdb, or a blue-green setup: rbf_roaring, roaring_rbf, bolt_roaring, roaring_bolt, bolt_rbf, etc.") + // Note: the default for --tx must be kept "" empty string. Otherwise we + // cannot detect and honor the PILOSA_TXSRC env var over-ride. + flags.StringVarP(&srv.Config.Txsrc, "tx", "", "", fmt.Sprintf("transaction/storage to use: one of roaring, rbf, bolt, lmdb, or a blue-green setup: rbf_roaring, roaring_rbf, bolt_roaring, roaring_bolt, bolt_rbf, etc. The default is: %v. The env var PILOSA_TXSRC is over-ridden by --tx option on the command line.", pilosa.DefaultTxsrc)) // RowcacheOff flags.BoolVarP((&srv.Config.RowcacheOff), "rowcache-off", "", srv.Config.RowcacheOff, "turn off the rowcache for all backends (reduces memory use)") diff --git a/ctl/server_test.go b/ctl/server_test.go index b99a2ed25..a1ce06ed8 100644 --- a/ctl/server_test.go +++ b/ctl/server_test.go @@ -35,3 +35,14 @@ func TestBuildServerFlags(t *testing.T) { t.Fatal("log-path flag is required") } } + +func TestServerDefaultTxsrcFlags(t *testing.T) { + cm := &cobra.Command{} + buf := bytes.Buffer{} + stdin, stdout, stderr := GetIO(buf) + Server := server.NewCommand(stdin, stdout, stderr) + BuildServerFlags(cm, Server) + if cm.Flags().Lookup("tx").DefValue != "" { + t.Fatal("cannot set the tx default in ctl/server.go, otherwise we won't know to let the environment override the lack of --tx on the command line. We want explicit command line --tx to override the env value.") + } +}