package rpcconfig import ( "testing" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config" configtest "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/test" "github.com/stretchr/testify/require" ) func TestRPCSection(t *testing.T) { t.Run("defaults", func(t *testing.T) { require.Empty(t, Limits(configtest.EmptyConfig())) }) t.Run("correct config", func(t *testing.T) { const path = "../../../../config/example/node" fileConfigTest := func(c *config.Config) { limits := Limits(c) require.Len(t, limits, 2) limit0 := limits[0] limit1 := limits[1] require.ElementsMatch(t, limit0.Methods, []string{"/neo.fs.v2.object.ObjectService/PutSingle", "/neo.fs.v2.object.ObjectService/Put"}) require.Equal(t, limit0.MaxOps, int64(1000)) require.ElementsMatch(t, limit1.Methods, []string{"/neo.fs.v2.object.ObjectService/Get"}) require.Equal(t, limit1.MaxOps, int64(10000)) } configtest.ForEachFileType(path, fileConfigTest) t.Run("ENV", func(t *testing.T) { configtest.ForEnvFileType(t, path, fileConfigTest) }) }) t.Run("no max operations", func(t *testing.T) { const path = "testdata/no_max_ops" fileConfigTest := func(c *config.Config) { require.Panics(t, func() { _ = Limits(c) }) } configtest.ForEachFileType(path, fileConfigTest) t.Run("ENV", func(t *testing.T) { configtest.ForEnvFileType(t, path, fileConfigTest) }) }) t.Run("zero max operations", func(t *testing.T) { const path = "testdata/zero_max_ops" fileConfigTest := func(c *config.Config) { limits := Limits(c) require.Len(t, limits, 2) limit0 := limits[0] limit1 := limits[1] require.ElementsMatch(t, limit0.Methods, []string{"/neo.fs.v2.object.ObjectService/PutSingle", "/neo.fs.v2.object.ObjectService/Put"}) require.Equal(t, limit0.MaxOps, int64(0)) require.ElementsMatch(t, limit1.Methods, []string{"/neo.fs.v2.object.ObjectService/Get"}) require.Equal(t, limit1.MaxOps, int64(10000)) } configtest.ForEachFileType(path, fileConfigTest) t.Run("ENV", func(t *testing.T) { configtest.ForEnvFileType(t, path, fileConfigTest) }) }) }