github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/ha/monitor/ha_setup_test.go (about) 1 // Copyright (c) 2022, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package monitor 5 6 import ( 7 "context" 8 "net/http" 9 10 "github.com/hashicorp/go-retryablehttp" 11 . "github.com/onsi/ginkgo/v2" 12 . "github.com/onsi/gomega" 13 "github.com/verrazzano/verrazzano/pkg/k8sutil" 14 "github.com/verrazzano/verrazzano/tests/e2e/pkg" 15 ) 16 17 // config for HA monitoring test suite 18 type config struct { 19 api *pkg.APIEndpoint 20 httpClient *retryablehttp.Client 21 hosts struct { 22 rancher string 23 kiali string 24 } 25 users struct { 26 verrazzano *pkg.UsernamePassword 27 } 28 } 29 30 var web = config{} 31 32 var beforeSuite = clusterDump.BeforeSuiteFunc(func() { 33 kubeconfigPath, err := k8sutil.GetKubeConfigLocation() 34 Expect(err).ShouldNot(HaveOccurred()) 35 web.api = pkg.EventuallyGetAPIEndpoint(kubeconfigPath) 36 web.httpClient = pkg.EventuallyVerrazzanoRetryableHTTPClient() 37 web.httpClient.CheckRetry = haCheckRetryRetryPolicy(web.httpClient.CheckRetry) 38 web.users.verrazzano = pkg.EventuallyGetSystemVMICredentials() 39 web.hosts.rancher = pkg.EventuallyGetURLForIngress(t.Logs, web.api, "cattle-system", "rancher", "https") 40 web.hosts.kiali = pkg.EventuallyGetKialiHost(clientset) 41 }) 42 var _ = BeforeSuite(beforeSuite) 43 44 // haCheckRetryRetryPolicy - wrap the default retry policy to retry on 401s in this case only 45 // - workaround for case where we've had issues with Keycloak availability during cluster upgrade, even with HA configurations 46 func haCheckRetryRetryPolicy(retry retryablehttp.CheckRetry) retryablehttp.CheckRetry { 47 return func(ctx context.Context, resp *http.Response, err error) (bool, error) { 48 currentRetry := retry 49 if resp != nil && resp.StatusCode == 401 { 50 return true, nil 51 } 52 if currentRetry != nil { 53 return currentRetry(ctx, resp, err) 54 } 55 return false, nil 56 } 57 }