add envtests for extraMounts feature#456
Conversation
7d45b9f to
cfe51ee
Compare
kstrenkova
left a comment
There was a problem hiding this comment.
Thank you for the PR! I have tried running it locally and it is working as expected :D
Overall the functionality and scale of the tests is nice, however I would like you to introduce a few helper functions into test/functional/base_test.go to reduce the repetition and code clutter. I have commented on a few, but please note that all of the code creating resources and searching for a name match should be helper functions, even when I have not marked them.
Note: I think Claude will have a quick solution for this (moving code into helper functions) if you feel like it's too repetitive to fix it all.
Note2: The name of the commit should start with a verb to keep good practice.
| testOperatorConfigMap := CreateTestOperatorConfigMap(namespace) | ||
| Expect(k8sClient.Create(ctx, testOperatorConfigMap)).Should(Succeed()) | ||
|
|
||
| extraConfigMap := &corev1.ConfigMap{ |
There was a problem hiding this comment.
Could you create a helper function that would create this extraConfigMap? Something like CreateExtraMountConfigMap?
There was a problem hiding this comment.
+1 and I would suggest creating this function to the base_test file.
There was a problem hiding this comment.
ack - I had added helper generic funcs to the base_test file and i will update the rest of the tests. the current changes are currently passing on ansible test and has cut down alot of the duplication here. also ramping up on this test framework, i added some additions such as context https://medium.com/@dees3g/testing-with-ginkgo-and-gomega-1f1ecc8407a8 to reduce duplicated calls also. really appreciate the reviews here both :)
| Expect(k8sClient.Create(ctx, extraConfigMap)).Should(Succeed()) | ||
|
|
||
| spec := GetDefaultAnsibleTestSpec() | ||
| spec["extraMounts"] = []map[string]any{ |
There was a problem hiding this comment.
Same here. It could be a helper function that would have AnsibleTest as a variable so it could be used for other resource types as well :D
There was a problem hiding this comment.
+1, e.g.
func BuildConfigMapExtraMountSpec(propagation string, volName string, cmName string, mountPath string) []map[string]any { ... }
func BuildSecretExtraMountSpec(propagation string, volName string, secretName string, mountPath string) []map[string]any { ... }
There was a problem hiding this comment.
Done: I added the func BuildExtraMountsSpec with return signature return []map[string]any{ {"extraVol": []map[string]any{extraVol}}, } to account for the scenario of multiple mounts (mount 0 - mount N-1) with different types (configmap + secret)
| testOperatorConfigMap := CreateTestOperatorConfigMap(namespace) | ||
| Expect(k8sClient.Create(ctx, testOperatorConfigMap)).Should(Succeed()) | ||
|
|
||
| extraSecret := &corev1.Secret{ |
There was a problem hiding this comment.
Same here as with the config map, but maybe it could be CreateExtraMountSecret?
| It("should add extra volume and volumeMount to the pod", func() { | ||
| pod := GetTestOperatorPod(namespace, ansibleTestName.Name) | ||
|
|
||
| foundVolume := false |
There was a problem hiding this comment.
This could be a helper function as well, something that looks for volumes and is just called with the volume name as parameter (plus all other parameters needed).
| Expect(k8sClient.Create(ctx, extraSecret)).Should(Succeed()) | ||
|
|
||
| spec := GetDefaultAnsibleTestSpec() | ||
| spec["extraMounts"] = []map[string]any{ |
There was a problem hiding this comment.
Same here, but with secret.
| Expect(k8sClient.Create(ctx, extraDataMap)).Should(Succeed()) | ||
|
|
||
| spec := GetDefaultAnsibleTestSpec() | ||
| spec["extraMounts"] = []map[string]any{ |
There was a problem hiding this comment.
This one also needs a helper function, the code it too long to just be here and make clutter :D
There was a problem hiding this comment.
I agree also i moved the logic to the helper funcs file in base_test and done
|
Hey @posikoya, the test scenarios themselves are well-chosen and functionally correct. |
cfe51ee to
38ffac2
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: posikoya The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
38ffac2 to
2fb5c4c
Compare
|
Build failed (check pipeline). Post ❌ openstack-k8s-operators-content-provider FAILURE in 5m 02s |
|
recheck |
|
Build failed (check pipeline). Post ❌ openstack-k8s-operators-content-provider FAILURE in 4m 15s |
The extraMounts feature allows mounting additional volumes (ConfigMaps, Secrets, PVCs) into test pods via propagation filtering. Goal is to add extraMounts envtests for all four controllers (AnsibleTest, Tempest, Tobiko, HorizonTest) that verify the reconciler correctly propagates extra volumes and volumeMounts to the pod spec
2fb5c4c to
f943fe3
Compare
|
Build failed (check pipeline). Post ❌ openstack-k8s-operators-content-provider FAILURE in 4m 22s |
The extraMounts feature allows mounting additional volumes (ConfigMaps, Secrets, PVCs) into test pods via propagation filtering.
Add extraMounts envtests for all four controllers (AnsibleTest, Tempest, Tobiko, HorizonTest) that verify the reconciler correctly propagates extra volumes and volumeMounts to the pod spec.i