From a8e2553690ec388343dbafc28552966005459fa4 Mon Sep 17 00:00:00 2001 From: Mario Fernandez Date: Tue, 25 Jul 2023 23:14:48 +0200 Subject: [PATCH] chore: replace deprecated wait.Poll --- test/e2e/framework/assertions.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/e2e/framework/assertions.go b/test/e2e/framework/assertions.go index 0057a7f0a..7d1ba24c1 100644 --- a/test/e2e/framework/assertions.go +++ b/test/e2e/framework/assertions.go @@ -54,7 +54,7 @@ func (f *Framework) AssertResourceNeverExists(name, namespace string, resource c return func(t *testing.T) { t.Helper() - if err := wait.Poll(option.PollInterval, option.WaitTimeout, func() (done bool, err error) { + if err := wait.PollUntilContextTimeout(context.Background(), option.PollInterval, option.WaitTimeout, true, func(ctx context.Context) (done bool, err error) { key := types.NamespacedName{ Name: name, Namespace: namespace, @@ -82,7 +82,7 @@ func (f *Framework) AssertResourceEventuallyExists(name, namespace string, resou return func(t *testing.T) { t.Helper() - if err := wait.Poll(option.PollInterval, option.WaitTimeout, func() (done bool, err error) { + if err := wait.PollUntilContextTimeout(context.Background(), option.PollInterval, option.WaitTimeout, true, func(ctx context.Context) (done bool, err error) { key := types.NamespacedName{ Name: name, Namespace: namespace, @@ -109,7 +109,7 @@ func (f *Framework) AssertStatefulsetReady(name, namespace string, fns ...Option return func(t *testing.T) { t.Helper() key := types.NamespacedName{Name: name, Namespace: namespace} - if err := wait.Poll(5*time.Second, option.WaitTimeout, func() (bool, error) { + if err := wait.PollUntilContextTimeout(context.Background(), 5*time.Second, option.WaitTimeout, true, func(ctx context.Context) (bool, error) { pod := &appsv1.StatefulSet{} err := f.K8sClient.Get(context.Background(), key, pod) return err == nil && pod.Status.ReadyReplicas == *pod.Spec.Replicas, nil @@ -121,7 +121,7 @@ func (f *Framework) AssertStatefulsetReady(name, namespace string, fns ...Option func (f *Framework) GetResourceWithRetry(t *testing.T, name, namespace string, obj client.Object) { t.Helper() - err := wait.Poll(5*time.Second, wait.ForeverTestTimeout, func() (bool, error) { + err := wait.PollUntilContextTimeout(context.Background(), 5*time.Second, wait.ForeverTestTimeout, true, func(ctx context.Context) (bool, error) { key := types.NamespacedName{Name: name, Namespace: namespace} if err := f.K8sClient.Get(context.Background(), key, obj); errors.IsNotFound(err) { @@ -231,7 +231,7 @@ func (f *Framework) GetOperatorMetrics(t *testing.T) []byte { stopChan := make(chan struct{}) defer close(stopChan) - if err := wait.Poll(5*time.Second, wait.ForeverTestTimeout, func() (bool, error) { + if err := wait.PollUntilContextTimeout(context.Background(), 5*time.Second, wait.ForeverTestTimeout, true, func(ctx context.Context) (bool, error) { err := f.StartPortForward(pod.Name, pod.Namespace, "8080", stopChan) return err == nil, nil }); err != nil { @@ -273,7 +273,7 @@ func (f *Framework) GetStackWhenAvailable(t *testing.T, name, namespace string) } var lastErr error - err := wait.Poll(5*time.Second, wait.ForeverTestTimeout, func() (bool, error) { + err := wait.PollUntilContextTimeout(context.Background(), 5*time.Second, wait.ForeverTestTimeout, true, func(ctx context.Context) (bool, error) { lastErr = nil err := f.K8sClient.Get(context.Background(), key, &ms) if err != nil { @@ -300,7 +300,7 @@ func (f *Framework) AssertAlertmanagerAbsent(t *testing.T, name, namespace strin Name: name, Namespace: namespace, } - err := wait.Poll(5*time.Second, wait.ForeverTestTimeout, func() (bool, error) { + err := wait.PollUntilContextTimeout(context.Background(), 5*time.Second, wait.ForeverTestTimeout, true, func(ctx context.Context) (bool, error) { err := f.K8sClient.Get(context.Background(), key, &am) if errors.IsNotFound(err) { return true, nil