From e7382a6b454a23d1b5f92309b156a5e74f570c17 Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Thu, 24 Mar 2022 15:31:47 -0400 Subject: [PATCH] tests: fix rpc limit tests (#12364) --- nomad/rpc_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nomad/rpc_test.go b/nomad/rpc_test.go index d7c0dc910..0ae94f0c7 100644 --- a/nomad/rpc_test.go +++ b/nomad/rpc_test.go @@ -17,6 +17,7 @@ import ( "time" "github.com/hashicorp/go-msgpack/codec" + "github.com/hashicorp/go-sockaddr" msgpackrpc "github.com/hashicorp/net-rpc-msgpackrpc" "github.com/hashicorp/nomad/ci" cstructs "github.com/hashicorp/nomad/client/structs" @@ -868,6 +869,15 @@ func TestRPC_Limits_OK(t *testing.T) { } c.RPCHandshakeTimeout = tc.timeout c.RPCMaxConnsPerClient = tc.limit + + // Bind the server to a private IP so that Autopilot's + // StatsFetcher requests come from a different IP than the test + // requests, otherwise they would interfere with the connection + // rate limiter since limits are imposed by IP address. + ip, err := sockaddr.GetPrivateIP() + require.NoError(t, err) + c.RPCAddr.IP = []byte(ip) + c.SerfConfig.MemberlistConfig.BindAddr = ip }) defer func() { cleanup()