diff --git a/tests/projectvpc_test.go b/tests/projectvpc_test.go index 753b9ce5..816782b2 100644 --- a/tests/projectvpc_test.go +++ b/tests/projectvpc_test.go @@ -147,7 +147,7 @@ func TestProjectVPCID(t *testing.T) { // Gets Aiven object var kafkaAvnUpd *aiven.Service - require.NoError(t, retryForever(ctx, func() (bool, error) { + require.NoError(t, retryForever(ctx, fmt.Sprintf("migrate %s to VPC with ID %s", kafkaName, vpc2.Status.ID), func() (bool, error) { kafkaAvnUpd, err = avnClient.Services.Get(ctx, testProject, kafkaName) if err != nil { return false, err diff --git a/tests/session.go b/tests/session.go index 37e7262e..e22a45d0 100644 --- a/tests/session.go +++ b/tests/session.go @@ -27,7 +27,7 @@ import ( ) const ( - retryInterval = time.Second * 5 + retryInterval = time.Second * 10 createTimeout = time.Second * 15 waitRunningTimeout = time.Minute * 10 yamlBufferSize = 100 @@ -111,7 +111,7 @@ func (s *session) GetRunning(obj client.Object, keys ...string) error { ctx, cancel := context.WithTimeout(s.ctx, waitRunningTimeout) defer cancel() - return retryForever(ctx, func() (bool, error) { + return retryForever(ctx, fmt.Sprintf("verify %s is running", key), func() (bool, error) { err := s.k8s.Get(ctx, key, obj) if err != nil { // The error is quite verbose @@ -190,7 +190,7 @@ func (s *session) delete(o client.Object) error { // Waits being deleted from kube key := types.NamespacedName{Name: o.GetName(), Namespace: o.GetNamespace()} - return retryForever(s.ctx, func() (bool, error) { + return retryForever(s.ctx, fmt.Sprintf("delete %s", o.GetName()), func() (bool, error) { err := s.k8s.Get(s.ctx, key, o) return !isNotFound(err), nil }) @@ -204,17 +204,20 @@ func (s *session) recover() { } } -func retryForever(ctx context.Context, f func() (bool, error)) (err error) { +func retryForever(ctx context.Context, operation string, f func() (bool, error)) (err error) { retry := false + log.Printf("Starting operation: %s\n", operation) + for { select { case <-ctx.Done(): - return fmt.Errorf("context timeout while retrying operation, error=%q", err) + return fmt.Errorf("context timeout while retrying operation: %s, error=%q", operation, err) case <-time.After(retryInterval): retry, err = f() if retry { continue } + log.Printf("Operation %s finished\n", operation) return err } }