2021-06-01 18:24:47 +00:00
|
|
|
package engineconfig_test
|
|
|
|
|
|
|
|
import (
|
2021-06-28 14:01:31 +00:00
|
|
|
"io/fs"
|
2021-06-01 18:24:47 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
|
|
|
engineconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine"
|
|
|
|
shardconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard"
|
|
|
|
configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEngineSection(t *testing.T) {
|
|
|
|
t.Run("defaults", func(t *testing.T) {
|
|
|
|
require.Panics(t, func() {
|
|
|
|
engineconfig.IterateShards(configtest.EmptyConfig(), nil)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const path = "../../../../config/example/node"
|
|
|
|
|
|
|
|
var fileConfigTest = func(c *config.Config) {
|
|
|
|
num := 0
|
|
|
|
|
|
|
|
engineconfig.IterateShards(c, func(sc *shardconfig.Config) {
|
|
|
|
defer func() {
|
|
|
|
num++
|
|
|
|
}()
|
|
|
|
|
|
|
|
wc := sc.WriteCache()
|
|
|
|
meta := sc.Metabase()
|
|
|
|
blob := sc.BlobStor()
|
|
|
|
blz := blob.Blobovnicza()
|
|
|
|
gc := sc.GC()
|
|
|
|
|
|
|
|
switch num {
|
|
|
|
case 0:
|
|
|
|
require.Equal(t, false, sc.UseWriteCache())
|
|
|
|
|
|
|
|
require.Equal(t, "tmp/0/cache", wc.Path())
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 2147483648, wc.MemSize())
|
|
|
|
require.EqualValues(t, 16384, wc.SmallObjectSize())
|
|
|
|
require.EqualValues(t, 134217728, wc.MaxObjectSize())
|
|
|
|
require.EqualValues(t, 30, wc.WorkersNumber())
|
2021-09-08 09:46:12 +00:00
|
|
|
require.EqualValues(t, 3221225472, wc.SizeLimit())
|
2021-06-01 18:24:47 +00:00
|
|
|
|
|
|
|
require.Equal(t, "tmp/0/meta", meta.Path())
|
2021-07-22 13:10:51 +00:00
|
|
|
require.Equal(t, fs.FileMode(0644), meta.Perm())
|
2021-06-01 18:24:47 +00:00
|
|
|
|
|
|
|
require.Equal(t, "tmp/0/blob", blob.Path())
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 0644, blob.Perm())
|
2021-06-01 18:24:47 +00:00
|
|
|
require.Equal(t, true, blob.Compress())
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 5, blob.ShallowDepth())
|
|
|
|
require.EqualValues(t, 102400, blob.SmallSizeLimit())
|
2021-06-01 18:24:47 +00:00
|
|
|
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 4194304, blz.Size())
|
|
|
|
require.EqualValues(t, 1, blz.ShallowDepth())
|
|
|
|
require.EqualValues(t, 4, blz.ShallowWidth())
|
|
|
|
require.EqualValues(t, 50, blz.OpenedCacheSize())
|
2021-06-01 18:24:47 +00:00
|
|
|
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 150, gc.RemoverBatchSize())
|
|
|
|
require.Equal(t, 2*time.Minute, gc.RemoverSleepInterval())
|
2021-06-01 18:24:47 +00:00
|
|
|
case 1:
|
|
|
|
require.Equal(t, true, sc.UseWriteCache())
|
|
|
|
|
|
|
|
require.Equal(t, "tmp/1/cache", wc.Path())
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 2147483648, wc.MemSize())
|
|
|
|
require.EqualValues(t, 16384, wc.SmallObjectSize())
|
|
|
|
require.EqualValues(t, 134217728, wc.MaxObjectSize())
|
|
|
|
require.EqualValues(t, 30, wc.WorkersNumber())
|
2021-09-08 09:46:12 +00:00
|
|
|
require.EqualValues(t, 4294967296, wc.SizeLimit())
|
2021-06-01 18:24:47 +00:00
|
|
|
|
|
|
|
require.Equal(t, "tmp/1/meta", meta.Path())
|
2021-07-22 13:10:51 +00:00
|
|
|
require.Equal(t, fs.FileMode(0644), meta.Perm())
|
2021-06-01 18:24:47 +00:00
|
|
|
|
|
|
|
require.Equal(t, "tmp/1/blob", blob.Path())
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 0644, blob.Perm())
|
2021-06-01 18:24:47 +00:00
|
|
|
require.Equal(t, false, blob.Compress())
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 5, blob.ShallowDepth())
|
|
|
|
require.EqualValues(t, 102400, blob.SmallSizeLimit())
|
2021-06-01 18:24:47 +00:00
|
|
|
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 4194304, blz.Size())
|
|
|
|
require.EqualValues(t, 1, blz.ShallowDepth())
|
|
|
|
require.EqualValues(t, 4, blz.ShallowWidth())
|
|
|
|
require.EqualValues(t, 50, blz.OpenedCacheSize())
|
2021-06-01 18:24:47 +00:00
|
|
|
|
2021-07-22 13:10:51 +00:00
|
|
|
require.EqualValues(t, 200, gc.RemoverBatchSize())
|
|
|
|
require.Equal(t, 5*time.Minute, gc.RemoverSleepInterval())
|
2021-06-01 18:24:47 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
require.Equal(t, 2, num)
|
|
|
|
}
|
|
|
|
|
|
|
|
configtest.ForEachFileType(path, fileConfigTest)
|
|
|
|
|
|
|
|
t.Run("ENV", func(t *testing.T) {
|
|
|
|
configtest.ForEnvFileType(path, fileConfigTest)
|
|
|
|
})
|
|
|
|
}
|