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 18954ccd3e
commit 4f3bfdbb91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 16 deletions

View File

@ -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)
}
}
}