From 6dea8c4dd13ca4e11fbe1b201460ac2b96c611c3 Mon Sep 17 00:00:00 2001 From: Dhia Ayachi Date: Wed, 4 Sep 2024 11:22:08 -0400 Subject: [PATCH] fix config and test --- agent/consul/server.go | 4 ++-- agent/consul/server_test.go | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/agent/consul/server.go b/agent/consul/server.go index 4ec9c29610..cc85f28f2f 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -1189,13 +1189,13 @@ func (s *Server) setupRaft() error { return nil } // Only use WAL if there is no existing raft.db, even if it's enabled. - if s.config.LogStoreConfig.Backend == LogStoreBackendDefault && !boltFileExists { + if (s.config.LogStoreConfig.Backend == LogStoreBackendDefault || s.config.LogStoreConfig.Backend == LogStoreBackendWAL) && !boltFileExists { s.config.LogStoreConfig.Backend = LogStoreBackendWAL if err = initWAL(); err != nil { return err } } else { - if s.config.LogStoreConfig.Backend == LogStoreBackendWAL { + if s.config.LogStoreConfig.Backend == LogStoreBackendWAL || s.config.LogStoreConfig.Backend == LogStoreBackendDefault { // User configured the new storage, but still has old raft.db. Warn // them! s.logger.Warn("BoltDB file raft.db found, IGNORING raft_logstore.backend which is set to 'wal'") diff --git a/agent/consul/server_test.go b/agent/consul/server_test.go index 6b147d8eae..f01d24cb4b 100644 --- a/agent/consul/server_test.go +++ b/agent/consul/server_test.go @@ -466,15 +466,14 @@ func TestServer_RaftBackend_BoltDB(t *testing.T) { // Start up a server and then stop it. _, s1 := testServerWithConfig(t, func(config *Config) { config.LogStoreConfig.Backend = LogStoreBackendBoltDB - config.LogStoreConfig.Verification.Enabled = true + config.LogStoreConfig.Verification.Enabled = false }) - store, ok := s1.raftStore.(*raftboltdb.BoltStore) + _, ok := s1.raftStore.(*raftboltdb.BoltStore) defer func() { if err := s1.Shutdown(); err != nil { t.Fatalf("err: %v", err) } }() - fmt.Printf("%v\n", store) require.True(t, ok) }