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"
|
2023-07-12 15:37:35 +03:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
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())
|
2023-07-12 15:37:35 +03:00
|
|
|
require.Equal(t, 0, len(treeSec.AuthorizedKeys()))
|
2022-07-26 12:48:55 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
const path = "../../../../config/example/node"
|
|
|
|
|
2023-07-12 15:37:35 +03:00
|
|
|
var expectedKeys keys.PublicKeys
|
|
|
|
key, err := keys.NewPublicKeyFromString("0397d207ea77909f7d66fa6f36d08daae22ace672be7ea4f53513484dde8a142a0")
|
|
|
|
require.NoError(t, err)
|
|
|
|
expectedKeys = append(expectedKeys, key)
|
|
|
|
key, err = keys.NewPublicKeyFromString("02053819235c20d784132deba10bb3061629e3a5c819a039ef091841d9d35dad56")
|
|
|
|
require.NoError(t, err)
|
|
|
|
expectedKeys = append(expectedKeys, key)
|
|
|
|
|
2023-10-31 14:56:55 +03:00
|
|
|
fileConfigTest := func(c *config.Config) {
|
2022-07-26 12:48:55 +03:00
|
|
|
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())
|
2023-07-12 15:37:35 +03:00
|
|
|
require.Equal(t, expectedKeys, treeSec.AuthorizedKeys())
|
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
|
|
|
})
|
|
|
|
}
|