Skip to content

Commit

Permalink
tests: fix rpc limit tests (#12364)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Mar 24, 2022
1 parent 8e77776 commit 47b07f5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions nomad/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 47b07f5

Please sign in to comment.