2022-07-26 12:48:55 +03:00
|
|
|
package treeconfig_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2022-12-14 19:28:44 +03:00
|
|
|
"time"
|
2022-07-26 12:48:55 +03:00
|
|
|
|
2023-03-07 16:38:26 +03:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
|
|
|
|
configtest "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/test"
|
|
|
|
treeconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/tree"
|
2022-07-26 12:48:55 +03:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTreeSection(t *testing.T) {
|
|
|
|
t.Run("defaults", func(t *testing.T) {
|
|
|
|
empty := configtest.EmptyConfig()
|
|
|
|
|
|
|
|
treeSec := treeconfig.Tree(empty)
|
|
|
|
|
|
|
|
require.False(t, treeSec.Enabled())
|
|
|
|
require.Equal(t, 0, treeSec.CacheSize())
|
|
|
|
require.Equal(t, 0, treeSec.ReplicationChannelCapacity())
|
|
|
|
require.Equal(t, 0, treeSec.ReplicationWorkerCount())
|
2022-12-14 19:28:44 +03:00
|
|
|
require.Equal(t, time.Duration(0), treeSec.ReplicationTimeout())
|
2022-07-26 12:48:55 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
const path = "../../../../config/example/node"
|
|
|
|
|
|
|
|
var fileConfigTest = func(c *config.Config) {
|
|
|
|
treeSec := treeconfig.Tree(c)
|
|
|
|
|
|
|
|
require.True(t, treeSec.Enabled())
|
|
|
|
require.Equal(t, 15, treeSec.CacheSize())
|
|
|
|
require.Equal(t, 32, treeSec.ReplicationChannelCapacity())
|
|
|
|
require.Equal(t, 32, treeSec.ReplicationWorkerCount())
|
2022-12-14 19:28:44 +03:00
|
|
|
require.Equal(t, 5*time.Second, treeSec.ReplicationTimeout())
|
2022-12-10 13:59:18 +03:00
|
|
|
require.Equal(t, time.Hour, treeSec.SyncInterval())
|
2022-07-26 12:48:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
configtest.ForEachFileType(path, fileConfigTest)
|
|
|
|
|
|
|
|
t.Run("ENV", func(t *testing.T) {
|
2023-03-28 17:16:03 +03:00
|
|
|
configtest.ForEnvFileType(t, path, fileConfigTest)
|
2022-07-26 12:48:55 +03:00
|
|
|
})
|
|
|
|
}
|