NO_JIRA: refactor validate function in traffic mgt tests (#16422)

This commit is contained in:
Anita Akaeze 2023-02-24 14:34:14 -05:00 committed by GitHub
parent dca7c18ec4
commit 94b378998f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,21 +125,14 @@ 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()
)
// validate services proxy admin is up
assertionFn = func() {
for serviceName, proxies := range s.services {
for _, proxy := range proxies {
_, adminPort := proxy.GetAdminAddr()
servicePort[serviceName] = adminPort
}
}
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))
@ -148,6 +141,7 @@ func (s *registeredServices) validateAgentServices(t *testing.T) (func(), func()
libassert.AssertEnvoyPresentsCertURI(t, adminPort, serviceName)
}
}
}
for _, serviceConnectProxy := range s.services {
for _, proxy := range serviceConnectProxy {