Skip to content

Commit

Permalink
test(compute): wait on operations and don't retry them (#6292)
Browse files Browse the repository at this point in the history
Operations should be waited on and not just created. This was causing
tests to fail because the operation was finishing silently and then
subsquent delete operations could not find the resulting instance
that had already been deleted.

Fixes: #5988
  • Loading branch information
codyoss authored Jun 30, 2022
1 parent d24600f commit eed822d
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions compute/apiv1/smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import (

"google.golang.org/api/option"

"cloud.google.com/go/internal"
"github.com/googleapis/gax-go/v2"

"github.com/google/go-cmp/cmp"

"cloud.google.com/go/internal/testutil"
Expand Down Expand Up @@ -478,17 +475,17 @@ func TestCapitalLetter(t *testing.T) {
defer func() {
timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)
defer cancel()
err = internal.Retry(timeoutCtx, gax.Backoff{}, func() (stop bool, err error) {
_, err = c.Delete(timeoutCtx,
&computepb.DeleteFirewallRequest{
Project: projectId,
Firewall: name,
})
return err == nil, err
})
op, err := c.Delete(timeoutCtx,
&computepb.DeleteFirewallRequest{
Project: projectId,
Firewall: name,
})
if err != nil {
t.Error(err)
}
if err = op.Wait(ctx); err != nil {
t.Error(err)
}
}()
fetched, err := c.Get(ctx, &computepb.GetFirewallRequest{
Project: projectId,
Expand Down Expand Up @@ -637,11 +634,7 @@ func TestInstanceGroupResize(t *testing.T) {
if err != nil {
t.Error(err)
}
err = internal.Retry(timeoutCtx, gax.Backoff{}, func() (stop bool, err error) {
err = deleteOp.Wait(ctx)
return deleteOp.Done(), err
})
if err != nil {
if err := deleteOp.Wait(ctx); err != nil {
t.Error(err)
}
}()
Expand Down

0 comments on commit eed822d

Please sign in to comment.