From 94b378998fa7178f714322bb552d20b6dcb7d529 Mon Sep 17 00:00:00 2001 From: Anita Akaeze Date: Fri, 24 Feb 2023 14:34:14 -0500 Subject: [PATCH] NO_JIRA: refactor validate function in traffic mgt tests (#16422) --- .../resolver_subset_redirect_test.go | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/test/integration/consul-container/test/upgrade/l7_traffic_management/resolver_subset_redirect_test.go b/test/integration/consul-container/test/upgrade/l7_traffic_management/resolver_subset_redirect_test.go index 3ba808057a..30462cc1ad 100644 --- a/test/integration/consul-container/test/upgrade/l7_traffic_management/resolver_subset_redirect_test.go +++ b/test/integration/consul-container/test/upgrade/l7_traffic_management/resolver_subset_redirect_test.go @@ -125,27 +125,21 @@ func TestTrafficManagement_ServiceResolverSubsetRedirect(t *testing.T) { func (s *registeredServices) validateAgentServices(t *testing.T) (func(), func()) { var ( responseFormat = map[string]string{"format": "json"} - servicePort = make(map[string]int) proxyRestartFn func() assertionFn func() ) - - for serviceName, proxies := range s.services { - for _, proxy := range proxies { - _, adminPort := proxy.GetAdminAddr() - servicePort[serviceName] = adminPort - } - } - + // validate services proxy admin is up assertionFn = func() { - // validate services proxy admin is up - for serviceName, adminPort := range servicePort { - _, statusCode, err := libassert.GetEnvoyOutput(adminPort, "stats", responseFormat) - require.NoError(t, err) - assert.Equal(t, http.StatusOK, statusCode, fmt.Sprintf("%s cannot be reached %v", serviceName, statusCode)) + for serviceName, proxies := range s.services { + for _, proxy := range proxies { + _, adminPort := proxy.GetAdminAddr() + _, statusCode, err := libassert.GetEnvoyOutput(adminPort, "stats", responseFormat) + require.NoError(t, err) + assert.Equal(t, http.StatusOK, statusCode, fmt.Sprintf("%s cannot be reached %v", serviceName, statusCode)) - // certs are valid - libassert.AssertEnvoyPresentsCertURI(t, adminPort, serviceName) + // certs are valid + libassert.AssertEnvoyPresentsCertURI(t, adminPort, serviceName) + } } }