From 41e6f6cd8be293fcd382ae8226f53c1428bfec53 Mon Sep 17 00:00:00 2001 From: "Chris S. Kim" Date: Tue, 3 Oct 2023 14:57:53 -0400 Subject: [PATCH] Reduce number of ports that consul test agents take (#19047) --- agent/testagent.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/agent/testagent.go b/agent/testagent.go index 39a83a087f..8ae2220adc 100644 --- a/agent/testagent.go +++ b/agent/testagent.go @@ -17,9 +17,9 @@ import ( "text/template" "time" - metrics "github.com/armon/go-metrics" + "github.com/armon/go-metrics" "github.com/hashicorp/go-hclog" - uuid "github.com/hashicorp/go-uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/agent/config" @@ -414,12 +414,12 @@ func (a *TestAgent) consulConfig() *consul.Config { // Instead of relying on one set of ports to be sufficient we retry // starting the agent with different ports on port conflict. func randomPortsSource(t *testing.T, useHTTPS bool) string { - ports := freeport.GetN(t, 8) + ports := freeport.GetN(t, 7) var http, https int if useHTTPS { http = -1 - https = ports[2] + https = ports[1] } else { http = ports[1] https = -1 @@ -430,11 +430,11 @@ func randomPortsSource(t *testing.T, useHTTPS bool) string { dns = ` + strconv.Itoa(ports[0]) + ` http = ` + strconv.Itoa(http) + ` https = ` + strconv.Itoa(https) + ` - serf_lan = ` + strconv.Itoa(ports[3]) + ` - serf_wan = ` + strconv.Itoa(ports[4]) + ` - server = ` + strconv.Itoa(ports[5]) + ` - grpc = ` + strconv.Itoa(ports[6]) + ` - grpc_tls = ` + strconv.Itoa(ports[7]) + ` + serf_lan = ` + strconv.Itoa(ports[2]) + ` + serf_wan = ` + strconv.Itoa(ports[3]) + ` + server = ` + strconv.Itoa(ports[4]) + ` + grpc = ` + strconv.Itoa(ports[5]) + ` + grpc_tls = ` + strconv.Itoa(ports[6]) + ` } ` }