-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
ci: refactor curl / wget test helpers with retries #12408
ci: refactor curl / wget test helpers with retries #12408
Conversation
Signed-off-by: JieJhih Jhang <jiejhihjhang@gmail.com>
test-me-please |
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.
Thanks a lot for the PR, it was bugging me for quite some time now.
I left a comment inline, please consider changing it as requested.
test/helpers/wrappers.go
Outdated
// retry the request if transient problems occur. Parameter retries are indicated the maximum retry times. | ||
// If the endpoint already contain "curl", the function will add --retry flag at the end of the command and return. | ||
// If the endpoint didn't contain "curl", the function will generate the command with --retry flag and return. | ||
func CurlWithRetries(endpoint string, retries int, optionalValues ...interface{}) string { |
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.
I think it makes a lot of sense to refactor this, but I feel that this functions shows too many implementation details and nesting CurlFail
into CurlWithRetries
is not necessary.
I would like CurlWithRetries
to accept the same arguments as CurlFail
with addition of --retry
flag.
I think this function should call CurlFail
and then perform string replacement on it that would replace curl
with curl --retry %d
.
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.
Thanks for reviewing. I think the function will become something like this:
CurlWithRetries
can use failed
flag to distinguish CurlFail and non-CurlFail.
func CurlWithRetries(endpoint string, retries int, failed bool, optionalValues ...interface{}) string {
if failed {
return fmt.Sprintf(
`%s --retry %d`,
CurlFail(endpoint, optionalValues...), retries)
}
if len(optionalValues) > 0 {
endpoint = fmt.Sprintf(endpoint, optionalValues...)
}
return fmt.Sprintf(
`curl --path-as-is -s -D /dev/stderr --output /dev/stderr --retry %d %s`,
retries, endpoint)
}
That made this line https://github.com/cilium/cilium/pull/12408/files#diff-0ac1702ef92e08f680c4d7d79842e042R95 can reuse the funtion.
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.
Looks good. One nit on argument names - failed
arg should be called fail
, as this is equivalent of curl --fail
flag.
Also please make sure that adding --retry %d
at the end of command always works as intended (although we will probably figure this out when running CI).
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.
Updated! Please take a look.
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.
Thanks for the PR! Overall I think this is good. +1 to @nebril's idea to refactor some of the details away in the new function
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; just a few minor comments, thanks. I think it's worth mentioning that there a few calls that can be simplified (they pass a format string as the 1st arg and utilize optionalValues
to fill in), however we can leave that to a follow up.
Signed-off-by: JieJhih Jhang <jiejhihjhang@gmail.com>
a9c7c3b
to
7402997
Compare
test-me-please |
1 similar comment
test-me-please |
@jiejhih Only members with commit access can trigger CI. If you need to trigger CI in the future, feel free to reach out to me here or Slack for quicker turnaround time. I'll trigger it now. |
test-me-please |
Thanks! I just wonder why Cilium-Ginkgo-GKE unit test didn't passed, I'm not sure if that is related to this PR. |
We have known issues with tests running on GKE. I would consider this PR as passing. |
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.
Thanks!
Looks like this PR had two identical commits that should have been squashed. We should be on the look out for issues like this next time before merging.
|
Marking for v1.8 backports to ease the backport of #13694. |
Fixes: #11994