fix config and test

zalimeni/dhiaayachi/raft-wal-backend-as-default--suggestions
Dhia Ayachi 3 months ago
parent e2f327c989
commit 6dea8c4dd1
No known key found for this signature in database

@ -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'")

@ -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)
}

Loading…
Cancel
Save