test(compute): fix flake
Add retry around the creation of the operation as even though it
is fetched right away this does not mean it can be delted yet.
Fixes:
@@ -473,17 +473,25 @@ func TestCapitalLetter(t *testing.T) {
t.Fatal(err)
}
defer func() {
- timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)
- defer cancel()
- op, err := c.Delete(timeoutCtx,
+ var op *Operation
+ var err error
+ ok := testutil.Retry(t, 20, 10*time.Second, func(r *testutil.R) {
+ var err error
+ op, err = c.Delete(ctx,
&computepb.DeleteFirewallRequest{
Project: projectId,
Firewall: name,
})
if err != nil {
- t.Error(err)
+ r.Errorf("%v", err)
+ }
+ })
+ if !ok {
+ t.Fatal(err)
}
- if err = op.Wait(ctx); err != nil {
+ timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)
+ defer cancel()
+ if err = op.Wait(timeoutCtx); err != nil {
t.Error(err)
}
}()
@@ -492,7 +500,7 @@ func TestCapitalLetter(t *testing.T) {
Firewall: name,
})
if err != nil {
- t.Error(err)
+ t.Fatal(err)
}
if diff := cmp.Diff(fetched.GetAllowed(), allowed, cmp.Comparer(proto.Equal)); diff != "" {
t.Fatalf("got(-),want(+):\n%s", diff)
