github.com/redhat-appstudio/e2e-tests@v0.0.0-20240520140907-9709f6f59323/pkg/clients/jvmbuildservice/caches.go (about) 1 package jvmbuildservice 2 3 import ( 4 "context" 5 "fmt" 6 "time" 7 8 . "github.com/onsi/ginkgo/v2" 9 10 "github.com/redhat-appstudio/e2e-tests/pkg/clients/common" 11 "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" 12 13 v1 "k8s.io/api/apps/v1" 14 "k8s.io/apimachinery/pkg/util/wait" 15 ) 16 17 // WaitForCache waits for cache to exist. 18 func (j *JvmbuildserviceController) WaitForCache(commonctrl *common.SuiteController, testNamespace string) error { 19 return wait.PollUntilContextTimeout(context.Background(), 5*time.Second, 5*time.Minute, true, func(ctx context.Context) (bool, error) { 20 cache, err := commonctrl.GetDeployment(v1alpha1.CacheDeploymentName, testNamespace) 21 if err != nil { 22 GinkgoWriter.Printf("failed to get JBS cache deployment: %s\n", err.Error()) 23 return false, nil 24 } 25 if cache.Status.AvailableReplicas > 0 { 26 GinkgoWriter.Printf("JBS cache is available\n") 27 return true, nil 28 } 29 for _, cond := range cache.Status.Conditions { 30 if cond.Type == v1.DeploymentProgressing && cond.Status == "False" { 31 return false, fmt.Errorf("JBS cache %s/%s deployment failed", testNamespace, v1alpha1.CacheDeploymentName) 32 } 33 } 34 GinkgoWriter.Printf("JBS cache %s/%s is progressing\n", testNamespace, v1alpha1.CacheDeploymentName) 35 return false, nil 36 }) 37 }