diff --git a/agent/consul/client_test.go b/agent/consul/client_test.go index 20647b3f66..f61541b5ef 100644 --- a/agent/consul/client_test.go +++ b/agent/consul/client_test.go @@ -15,6 +15,8 @@ import ( "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" "github.com/hashicorp/serf/serf" + "github.com/stretchr/testify/require" + "golang.org/x/time/rate" ) func testClientConfig(t *testing.T) (string, *Config) { @@ -665,3 +667,25 @@ func TestClient_Encrypted(t *testing.T) { 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()) +}