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

ci: refactor curl / wget test helpers with retries #12408

Merged
merged 2 commits into from
Jul 15, 2020

Conversation

LexCC
Copy link
Contributor

@LexCC LexCC commented Jul 4, 2020

Fixes: #11994

ci: refactor curl / wget test helpers with retries

Signed-off-by: JieJhih Jhang <jiejhihjhang@gmail.com>
@LexCC LexCC requested a review from a team as a code owner July 4, 2020 05:29
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jul 4, 2020
@coveralls
Copy link

coveralls commented Jul 4, 2020

Coverage Status

Coverage increased (+0.009%) to 36.957% when pulling 7402997 on JieJhih:pr/JieJhih/refactor-test-helpers into d7e2076 on cilium:master.

@aanm aanm added the release-note/ci This PR makes changes to the CI. label Jul 6, 2020
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jul 6, 2020
@aanm
Copy link
Member

aanm commented Jul 6, 2020

test-me-please

Copy link
Member

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

// 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 {
Copy link
Member

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.

Copy link
Contributor Author

@LexCC LexCC Jul 7, 2020

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.

Copy link
Member

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).

Copy link
Contributor Author

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.

@christarazi christarazi self-requested a review July 6, 2020 18:29
Copy link
Member

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

Copy link
Member

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

test/helpers/wrappers.go Outdated Show resolved Hide resolved
test/helpers/wrappers.go Outdated Show resolved Hide resolved
Signed-off-by: JieJhih Jhang <jiejhihjhang@gmail.com>
@LexCC LexCC force-pushed the pr/JieJhih/refactor-test-helpers branch from a9c7c3b to 7402997 Compare July 9, 2020 07:00
@christarazi
Copy link
Member

test-me-please

1 similar comment
@LexCC
Copy link
Contributor Author

LexCC commented Jul 10, 2020

test-me-please

@christarazi
Copy link
Member

christarazi commented Jul 10, 2020

@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.

@christarazi
Copy link
Member

test-me-please

@christarazi christarazi requested a review from nebril July 10, 2020 19:40
@LexCC
Copy link
Contributor Author

LexCC commented Jul 11, 2020

@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.

Thanks! I just wonder why Cilium-Ginkgo-GKE unit test didn't passed, I'm not sure if that is related to this PR.

@christarazi
Copy link
Member

@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.

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.

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jul 15, 2020
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@qmonnet qmonnet merged commit a336059 into cilium:master Jul 15, 2020
@christarazi
Copy link
Member

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.

$ git log
...
* 8f0b57d0b kvstore: Add metric to count quorum errors
* a33605936 ci: refactor curl / wget test helpers with retries
* 21be15ebe ci: refactor curl / wget test helpers with retries
* 38d9bf589 bpf: explicitly set ttl in tunnel key

@pchaigno
Copy link
Member

Marking for v1.8 backports to ease the backport of #13694.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/ci This PR makes changes to the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI: Refactor curl / wget test helpers with retries
8 participants