-
Notifications
You must be signed in to change notification settings - Fork 511
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 basic Helm chart unittests for kuberay-operator #3253
Conversation
Signed-off-by: Yi Chen <[email protected]>
Hi @kevin85421, PTAL when you have time. |
cc @win5923 would you mind reviewing this PR? Thanks! |
Signed-off-by: Yi Chen <[email protected]>
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.
LGTM
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.
@ChenYi015 are these tests running in the CI now? cc @MortalHappiness would you mind reviewing this PR? Thanks!
@kevin85421 Not yet. I will raise another PR to add Helm chart unit test to CI once this PR is merged. |
Got it. Would you mind adding a screenshot of the result from running |
Sure.
Have created an issue #3279 for tracking this and PR #3280 for closing it. |
Thank you! |
@MortalHappiness please take a look. Thanks. |
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.
LGTM. Just one question: are the tests and the YAML formatting auto-generated?
No. I wrote the tests and format the YAML manually. |
Here is the screenshot of running helm unittest: |
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.
Overall LGTM. I've left some comments out of curiosity.
{{- toYaml .Values.labels | nindent 4 }} | ||
{{- end }} | ||
{{ include "kuberay-operator.labels" . | nindent 4 }} | ||
{{- with .Values.labels }} |
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.
Would you mind explaining the rationale behind the change from if
to with
? The only difference seems to be able to use toYaml .
?
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.
with
can be used to specify the context scope, so we can simplify the template code (especially when the name of values are long) without repeating the values.
{{- if .Values.labels }} | ||
{{- toYaml .Values.labels | nindent 4 }} | ||
{{- end }} | ||
{{ include "kuberay-operator.labels" . | nindent 4 }} |
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.
What's the reason to change from indent
to nindent
?
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.
metadata:
labels:
{{ include "kuberay-operator.labels" . | indent 4 }}
metadata:
labels:
{{- include "kuberay-operator.labels" . | nindent 4 }}
The above two template blocks work the same. But since yaml uses indention to convey the struct information, it will be easier to read if we can adjust the indention of helm template code.
Signed-off-by: Yi Chen <[email protected]>
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.
Thank you!
Why are these changes needed?
Make sure kuberay-operator Helm chart can work as expected with various configurations by adding unit tests.
One can run Helm chart unit tests by:
$ helm plugin install https://github.com/helm-unittest/helm-unittest.git $ helm unittest helm-chart/kuberay-operator --strict --debug ### Chart [ kuberay-operator ] helm-chart/kuberay-operator PASS Test Deployment helm-chart/kuberay-operator/tests/deployment_test.yaml PASS Test ClusterRole helm-chart/kuberay-operator/tests/role_test.yaml PASS Test ClusterRoleBinding helm-chart/kuberay-operator/tests/rolebinding_test.yaml PASS Test Service helm-chart/kuberay-operator/tests/service_test.yaml PASS Test ServiceAccount helm-chart/kuberay-operator/tests/serviceaccount_test.yaml Charts: 1 passed, 1 total Test Suites: 5 passed, 5 total Tests: 25 passed, 25 total Snapshot: 0 passed, 0 total Time: 118.062459ms
Related issue number
Closes #3244
Checks