Skip to content
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

Merged
merged 1 commit into from
May 11, 2021

Conversation

skriss
Copy link
Member

@skriss skriss commented May 10, 2021

Closes #3660.

Signed-off-by: Steve Kriss krisss@vmware.com

Closes projectcontour#3660.

Signed-off-by: Steve Kriss <krisss@vmware.com>
@skriss skriss requested a review from a team as a code owner May 10, 2021 21:15
@skriss skriss requested review from danehans and sunjayBhatia and removed request for a team May 10, 2021 21:15
@codecov
Copy link

codecov bot commented May 10, 2021

Codecov Report

Merging #3662 (1e477b7) into main (1b1ce87) will decrease coverage by 0.04%.
The diff coverage is n/a.

❗ Current head 1e477b7 differs from pull request most recent head b785ad8. Consider uploading reports for the commit b785ad8 to get more accurate results
Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
internal/k8s/log.go 63.04% <0.00%> (-6.53%) ⬇️

Comment on lines +68 to +78
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)
}))
Copy link
Member Author

@skriss skriss May 10, 2021

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.

Copy link
Member

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.

Copy link
Member

@youngnick youngnick left a 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.

Comment on lines +68 to +78
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)
}))
Copy link
Member

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.

@skriss
Copy link
Member Author

skriss commented May 11, 2021

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.

Copy link
Member

@sunjayBhatia sunjayBhatia left a 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

@skriss skriss merged commit 5635b97 into projectcontour:main May 11, 2021
@skriss skriss deleted the e2e-retry-updates branch May 11, 2021 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test/e2e test flake
3 participants