mirror of https://github.com/hashicorp/consul
Add a Client ReloadConfig test
parent
08e26d10b8
commit
0df7cd22aa
|
@ -15,6 +15,8 @@ import (
|
||||||
"github.com/hashicorp/consul/testutil/retry"
|
"github.com/hashicorp/consul/testutil/retry"
|
||||||
"github.com/hashicorp/net-rpc-msgpackrpc"
|
"github.com/hashicorp/net-rpc-msgpackrpc"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testClientConfig(t *testing.T) (string, *Config) {
|
func testClientConfig(t *testing.T) (string, *Config) {
|
||||||
|
@ -665,3 +667,25 @@ func TestClient_Encrypted(t *testing.T) {
|
||||||
t.Fatalf("should be encrypted")
|
t.Fatalf("should be encrypted")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClient_Reload(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
dir1, c := testClientWithConfig(t, func(c *Config) {
|
||||||
|
c.RPCRate = 500
|
||||||
|
c.RPCMaxBurst = 5000
|
||||||
|
})
|
||||||
|
defer os.RemoveAll(dir1)
|
||||||
|
defer c.Shutdown()
|
||||||
|
|
||||||
|
limiter := c.rpcLimiter.Load().(*rate.Limiter)
|
||||||
|
require.Equal(t, rate.Limit(500), limiter.Limit())
|
||||||
|
require.Equal(t, 5000, limiter.Burst())
|
||||||
|
|
||||||
|
c.config.RPCRate = 1000
|
||||||
|
c.config.RPCMaxBurst = 10000
|
||||||
|
|
||||||
|
require.NoError(t, c.ReloadConfig(c.config))
|
||||||
|
limiter = c.rpcLimiter.Load().(*rate.Limiter)
|
||||||
|
require.Equal(t, rate.Limit(1000), limiter.Limit())
|
||||||
|
require.Equal(t, 10000, limiter.Burst())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue