-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test/e2e: add retry with backoff to all updates #3662
Conversation
Closes projectcontour#3660. Signed-off-by: Steve Kriss <krisss@vmware.com>
Codecov Report
@@ Coverage Diff @@
## main #3662 +/- ##
==========================================
- Coverage 77.08% 77.03% -0.05%
==========================================
Files 100 100
Lines 7121 7121
==========================================
- Hits 5489 5486 -3
- Misses 1511 1514 +3
Partials 121 121
|
require.NoError(t, retry.RetryOnConflict(retry.DefaultBackoff, func() error { | ||
if err := fx.Client.Get(context.TODO(), client.ObjectKeyFromObject(p), p); err != nil { | ||
return err | ||
} | ||
|
||
p.Spec.Routes[0].HealthCheckPolicy = &contourv1.HTTPHealthCheckPolicy{ | ||
Path: "/status/418", | ||
} | ||
|
||
return fx.Client.Update(context.TODO(), p) | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this logic is ~repeated (get object, apply changes, update object), we could extract this to a test framework helper method. I was undecided on whether it was worth it or not, since you'd have to use some type-assertions or closure tricks to make it generic for types beyond just HTTPProxy
, and it might be unnecessarily complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The status updating code had a similar problem, and I used a Mutator function there to handle it, I'm not sure how good I feel about it, looking back. Although this is repetitive, this does have the advantage of clarity. I agree we should leave this for now, and see if we should dry it up later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I think that doing retry with backoff is a good habit anyway, leaving aside concerns about repetition.
require.NoError(t, retry.RetryOnConflict(retry.DefaultBackoff, func() error { | ||
if err := fx.Client.Get(context.TODO(), client.ObjectKeyFromObject(p), p); err != nil { | ||
return err | ||
} | ||
|
||
p.Spec.Routes[0].HealthCheckPolicy = &contourv1.HTTPHealthCheckPolicy{ | ||
Path: "/status/418", | ||
} | ||
|
||
return fx.Client.Update(context.TODO(), p) | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The status updating code had a similar problem, and I used a Mutator function there to handle it, I'm not sure how good I feel about it, looking back. Although this is repetitive, this does have the advantage of clarity. I agree we should leave this for now, and see if we should dry it up later.
cc @danehans we may want to do something similar in the operator e2e's to try to avoid some of the flakes we've been seeing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good to me, can DRY this up later if we need to
Closes #3660.
Signed-off-by: Steve Kriss krisss@vmware.com