test(compute): wait on operations and don't retry them
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:
@@ -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"
@@ -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,
+ op, err := c.Delete(timeoutCtx,
&computepb.DeleteFirewallRequest{
Project: projectId,
Firewall: name,
})
- return err == nil, err
- })
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,
@@ -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)
}
}()
