Skip to content

Commit

Permalink
chore: replace deprecated wait.Poll
Browse files Browse the repository at this point in the history
  • Loading branch information
marioferh committed Jul 25, 2023
1 parent aaa3776 commit a8e2553
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/e2e/framework/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit a8e2553

Please sign in to comment.