Skip to content

Commit

Permalink
test(compute): fix flake (#6307)
Browse files Browse the repository at this point in the history
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: #5988
  • Loading branch information
codyoss committed Jul 6, 2022
1 parent 963efe2 commit 8d455a5
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions compute/apiv1/smoke_test.go
Expand Up @@ -473,17 +473,25 @@ func TestCapitalLetter(t *testing.T) {
t.Fatal(err)
}
defer func() {
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 {
r.Errorf("%v", err)
}
})
if !ok {
t.Fatal(err)
}
timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)
defer cancel()
op, err := c.Delete(timeoutCtx,
&computepb.DeleteFirewallRequest{
Project: projectId,
Firewall: name,
})
if err != nil {
t.Error(err)
}
if err = op.Wait(ctx); err != nil {
if err = op.Wait(timeoutCtx); err != nil {
t.Error(err)
}
}()
Expand All @@ -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)
Expand Down

0 comments on commit 8d455a5

Please sign in to comment.