From b2c5e2d0592efb4e46c56e22ce4b22b87f810d4b Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 18 Nov 2020 16:07:00 -0500 Subject: [PATCH] Use freeport To prevent other tests which already use freeport from flaking when port 0 steals their reserved port. --- agent/agent_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agent/agent_test.go b/agent/agent_test.go index 8d7d418ab0..6d5d4d3243 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -4714,6 +4714,10 @@ func TestSharedRPCRouter(t *testing.T) { } func TestAgent_ListenHTTP_MultipleAddresses(t *testing.T) { + ports, err := freeport.Take(2) + require.NoError(t, err) + t.Cleanup(func() { freeport.Return(ports) }) + caConfig := tlsutil.Config{} tlsConf, err := tlsutil.NewConfigurator(caConfig, hclog.New(nil)) require.NoError(t, err) @@ -4725,8 +4729,8 @@ func TestAgent_ListenHTTP_MultipleAddresses(t *testing.T) { }, RuntimeConfig: &config.RuntimeConfig{ HTTPAddrs: []net.Addr{ - &net.TCPAddr{IP: net.ParseIP("127.0.0.1")}, - &net.TCPAddr{IP: net.ParseIP("127.0.0.1")}, + &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: ports[0]}, + &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: ports[1]}, }, }, Cache: cache.New(cache.Options{}),