-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add envtest testing docs to extend cronjob example #1521
Add envtest testing docs to extend cronjob example #1521
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Welcome @gabbifish! |
Hi @gabbifish. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
5ad2ca6
to
8a9198d
Compare
I'm trying to sign the CLA but when I link my github account to my LF account, I keep seeing |
/ok-to-test @gabbifish really thank you for your great contribution. Please, see that you need to assign the CLA as well for this contribution be able to be accepted. |
All right! My CLA should be signed now. |
a225c42
to
24965e1
Compare
docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go
Outdated
Show resolved
Hide resolved
docs/book/src/cronjob-tutorial/testdata/project/controllers/suite_test.go
Outdated
Show resolved
Hide resolved
docs/book/src/cronjob-tutorial/testdata/project/controllers/suite_test.go
Outdated
Show resolved
Hide resolved
Still going through the example itself but this is pretty good and a lot more comprehensive than what I originally had in mind. |
docs/book/src/cronjob-tutorial/testdata/project/controllers/suite_test.go
Show resolved
Hide resolved
docs/book/src/cronjob-tutorial/testdata/project/controllers/suite_test.go
Show resolved
Hide resolved
docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go
Show resolved
Hide resolved
docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go
Outdated
Show resolved
Hide resolved
docs/book/src/cronjob-tutorial/testdata/project/controllers/suite_test.go
Show resolved
Hide resolved
Thank you for the great feedback, @camilamacedo86 and @hasbro17! I've incorporated most of it, and left a question above I would love some more clarification on. :) Unclear why continuous-integration is failing, given that I rebased my changes on master just now to include the testdata changes @camilamacedo86 recently pushed |
6f5d143
to
db469c6
Compare
/lgtm |
/hold cancel |
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.
Comments inline about tests. Just some details about a couple of points in the tests, overall structure looks fine. We should put this in the cronjob tutorial though -- it's not really reference.
Also: please stick the boilerplate sections (e.g. imports) in collapsible sections like we do in the other book pages.
docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go
Outdated
Show resolved
Hide resolved
} | ||
return true | ||
}, timeout, interval).Should(BeTrue()) | ||
Expect(createdCronjob.Spec.Schedule).Should(Equal("1 * * * *")) |
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.
can you add a comment here or something explaining this? I'm assuming it's a sanity test for when you have pruning turned on on the API server (CRD v1 or CRD v1beta1 w/ conversion), but it's worth pointing out.
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.
This isn't as much a sanity test for pruning as it is a check to ensure that our CronJob spec Schedule
field matches the parameters we passed in. (I don't think Schedule
is supposed to ever get pruned?) Please let me know if I misunderstood something!
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 i'm just not understanding the failure condition you're testing for. The two failure modes I can imaging are conversion screwing up something during round-tripping (which I forgot about when leaving the comment here) or pruning removing the field. Otherwise, "field passed in" == "field read" should be ensured by the apiserver. If not, somethings terribly wrong with the apiserver (hence referring to it above as a "sanity test").
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.
This failure condition was originally created to check for "field passed in" == "field read" (which is ensured by the APIserver). Pruning shouldn't happen here, given that Schedule is a required CronJob Spec field. The idea for adding this came from some conversations @camilamacedo86 and I had earlier (see #1521 (comment)). The conversion point you bring up is still valid and potentially worth leaving the test for, though.
Given that the consistency of a created object and its input spec is ensured by/tested in the apiserver, I think it could make sense to just delete this check or add a comment mentioning testing schedule string conversion behavior--what do you think?
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 went with the second option (add extra comment to clarify that this tests the conversion of the Schedule string). I think this should be ready for final review? :)
docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go
Outdated
Show resolved
Hide resolved
docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go
Show resolved
Hide resolved
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gabbifish, pwittrock 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 |
Thank you for the helpful feedback, @DirectXMan12! In my first follow-up commit, I incorporated all of it (except for one follow-up question I asked above). In the second follow-up commit, I put the |
PS.: For we are able to merge the commits need to be squashed |
aa3e6d0
to
e5fda8f
Compare
/retest |
rebased! now playing a game of whack-a-mole with the e2e tests 😂 (I think they are acting flaky at the moment). |
/retest |
e5fda8f
to
2080f31
Compare
/lgtm |
…sting-docs Add envtest testing docs to extend cronjob example
…sting-docs Add envtest testing docs to extend cronjob example
…sting-docs Add envtest testing docs to extend cronjob example
@pwittrock we need fix this one. See that it is not showing the in the book and then the previous info also shows no longer appears. |
…sting-docs Add envtest testing docs to extend cronjob example
This PR adds testing docs to extend the CronJob example and teach people general patterns for writing tests with envtest. It addresses #1518.