-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
seperation of network call in KubernetesReleaseVersion #78026
Conversation
no. don't test! :( |
cc |
e043999
to
eace437
Compare
/test pull-kubernetes-e2e-gce |
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 @Klaven !
That's what I expected. However, let's have it along with some tests, that actually make use of the new way of mocking fetching a version over the internet.
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 @Klaven !
As a few ideas for additional test cases, you can try to use the new func in place of the full blown one in version_test.go
. For example TestVersionFromNetwork
can be done without running mock HTTP server, TestValidVersion
should never go on the network, and so on.
242bcbf
to
8a80df8
Compare
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.
On a good track here. You can also try to modify the TestValidVersion
, TestInvalidVersion
and TestEmptyVersion
to fail if they try to access the internet.
return kubernetesReleaseVersion(version, fetchFromURL) | ||
} | ||
|
||
func kubernetesReleaseVersion(version string, fetcher func(string, time.Duration) (string, error)) (string, error) { |
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.
Thinking over this, it may be good to add a comment here, that this func is separate for test purposes.
861d030
to
faef40b
Compare
not sure what is going on with bazel. I rebased with master, re-ran |
faef40b
to
94dcd88
Compare
2448c62
to
00c2b7d
Compare
00c2b7d
to
f95f93b
Compare
updated the network calls to be package local so tests could pass their own implementation. A public interface was not provided as it would not be likely this would ever be needed or wanted.
one test also proved it did not call the internet but this was not fool proof as it did not return a string and thus could be called with something expecting to fail.
commit will be squashed before merge
f95f93b
to
eb6eb11
Compare
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 @Klaven !
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Klaven, rosti The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Review the full test history for this PR. Silence the bot with an |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Made network calls package local so unit tests would be able to mock them out. I did not put them behind a full interface due to it adding unnecessary complexity for something we are not even sure should ever be supported (fetching the version from someplace other then a URL.)
Which issue(s) this PR fixes:
Fixes #kubernetes/kubeadm#902
Special notes for your reviewer:
Does this PR introduce a user-facing change?: