-
Notifications
You must be signed in to change notification settings - Fork 86
Improve test coverage of Kubernetes package #1894
Conversation
@ebaron snapshot fabric8-wit image is available for testing. |
Codecov Report
@@ Coverage Diff @@
## master #1894 +/- ##
==========================================
+ Coverage 61.05% 63.44% +2.39%
==========================================
Files 144 144
Lines 13366 13392 +26
==========================================
+ Hits 8161 8497 +336
+ Misses 4482 4084 -398
- Partials 723 811 +88
Continue to review full report at Codecov.
|
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 looks good overall, but have you considered using something like go-vcr
to handle the HTTP responses ? This would require you to configure/replace the default HTTP client's transport
of the Kube/OS client with the one provided by the recorder
, but then you may have less boilerplate code in your tests.
@xcoulon go-vcr sounds promising. Could I consider that as a future enhancement, since it would involve substantial changes? |
@ebaron snapshot fabric8-wit image is available for testing. |
a8c06bf
to
44aee4a
Compare
@ebaron snapshot fabric8-wit image is available for testing. |
@xcoulon Sorry about the broken rebase, this happened due to moving from the old "apps" API to "deployments" during development. I've squashed the commits and all seems good now. |
@ebaron ok, I'm fine with using |
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.
PR approved
44aee4a
to
2c303df
Compare
@ebaron snapshot fabric8-wit image is available for testing. |
@xcoulon I'll try to experiment using go-vcr shortly. I filed an issue here: openshiftio/openshift.io#2355 |
@ebaron snapshot fabric8-wit image is available for testing. |
@ebaron snapshot fabric8-wit image is available for testing. |
This PR adds several tests for deployments_kubeclient.go, focusing on the API methods used by "deployments" controller. The new tests use JSON files as input containing mock Kubernetes/OpenShift resources. Likewise, existing communication with the OpenShift API server in deployments_kubeclient.go using YAML has been changed to JSON.
This PR also fixes a bug discovered during testing, where the pod list is incorrect due to using a pointer to a loop iteration variable. This has been changed to point to elements from the slice returned by Kubernetes. This bug was introduced recently when switching from the "apps" to "deployments" API.
One other thing changed by this PR is to return an empty array for pod statuses, when there are no pods in a deployment. In order to return an empty array in the JSON response, I had to specify the "pods" attribute as "Required" in the goa design. Previously, we would return a dummy entry of "0 Running".