-
Notifications
You must be signed in to change notification settings - Fork 164
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 unit test for Node controller #1648
Conversation
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.
Just a few nits. You have coverage over all these functions but because you are doing a table test you could create a test that tests every condition in the isDraining
function. So the annotations to see if they are blank, etc. That way the confidence of this function will increase as you tested that each condition can create the return value necessary.
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 we need the following tests for this controller:
- Test individual functions such as
isDraining
with all possible scenarios as Troy suggested. - Make
isDraining
mockable and test the controller viaReconcile
. This way we don't have to meet all the conditions insideisDraining
in test data and don't have to care about implementation ofisDraining
: we just make it returns eithertrue
orfalse
and cover these code paths.
I'm happy for these two things to be submitted in a separate PRs, if you prefer. But we definitely need the second point - without it there is a lot of code (contriller's main logic) without coverage.
59b6059
to
42ce320
Compare
@m1kola @troy0820 I agree we should test via Reconcile, and I had previously attempted to do it unsuccessfully, but I can work on it more. I have addressed the other comments and squashed commits, so we can either merge with followup issue to change to Reconcile, or else I will continue to work on it via this PR - whatever is preferred. |
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.
@cadenmarchese let's finish covering individual functions in this PR and cover Reconcile
in a separate PR.
42ce320
to
e52008c
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.
Looks good. Only one small suggestion for TestSetAnnotation
.
e52008c
to
7cff2a7
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.
Looks good. We still need to cover main logic of this controller (Reconcile
method). Let's do it in a separate PR.
Troy's feedback was addressed, I believe. Dismissing the review.
Which issue this PR addresses:
https://msazure.visualstudio.com/AzureRedHatOpenShift/_workitems/edit/10227470/
What this PR does / why we need it:
Adds some coverage to the Node controller to ensure we're adding and reading our annotations properly. Also adds a const.go file for the node package since it's standard practice among other operator controllers.
Test plan for issue:
make test-go
go test -v
Is there any documentation that needs to be updated for this PR?
No