Skip to content

add envtests for extraMounts feature#456

Open
posikoya wants to merge 1 commit into
openstack-k8s-operators:mainfrom
posikoya:posikoya/env-tests-extraMounts
Open

add envtests for extraMounts feature#456
posikoya wants to merge 1 commit into
openstack-k8s-operators:mainfrom
posikoya:posikoya/env-tests-extraMounts

Conversation

@posikoya

Copy link
Copy Markdown
Contributor

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

@posikoya posikoya self-assigned this Jun 18, 2026
@openshift-ci openshift-ci Bot requested review from adrianfusco and dprince June 18, 2026 13:03
@posikoya posikoya marked this pull request as draft June 18, 2026 13:03
@posikoya posikoya force-pushed the posikoya/env-tests-extraMounts branch 8 times, most recently from 7d45b9f to cfe51ee Compare June 20, 2026 02:03
@posikoya posikoya marked this pull request as ready for review June 22, 2026 08:33
@openshift-ci openshift-ci Bot requested review from Valkyrie00 and abays June 22, 2026 08:33

@kstrenkova kstrenkova left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you create a helper function that would create this extraConfigMap? Something like CreateExtraMountConfigMap?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 and I would suggest creating this function to the base_test file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Expect(k8sClient.Create(ctx, extraConfigMap)).Should(Succeed())

spec := GetDefaultAnsibleTestSpec()
spec["extraMounts"] = []map[string]any{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+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 { ... }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as with the config map, but maybe it could be CreateExtraMountSecret?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

It("should add extra volume and volumeMount to the pod", func() {
pod := GetTestOperatorPod(namespace, ansibleTestName.Name)

foundVolume := false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Expect(k8sClient.Create(ctx, extraSecret)).Should(Succeed())

spec := GetDefaultAnsibleTestSpec()
spec["extraMounts"] = []map[string]any{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, but with secret.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Expect(k8sClient.Create(ctx, extraDataMap)).Should(Succeed())

spec := GetDefaultAnsibleTestSpec()
spec["extraMounts"] = []map[string]any{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one also needs a helper function, the code it too long to just be here and make clutter :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree also i moved the logic to the helper funcs file in base_test and done

@Valkyrie00

Copy link
Copy Markdown
Contributor

Hey @posikoya, the test scenarios themselves are well-chosen and functionally correct.
The blocking issue is the extensive code duplication. I agree with all of @kstrenkova's comments, especially regarding the helper functions, extracting those would make the PR dramatically smaller and test code more maintainable 👍

@posikoya posikoya force-pushed the posikoya/env-tests-extraMounts branch from cfe51ee to 38ffac2 Compare July 6, 2026 23:25
@openshift-ci

openshift-ci Bot commented Jul 6, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: posikoya
Once this PR has been reviewed and has the lgtm label, please ask for approval from kstrenkova. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@posikoya posikoya force-pushed the posikoya/env-tests-extraMounts branch from 38ffac2 to 2fb5c4c Compare July 7, 2026 11:51
@posikoya posikoya added the ready-for-review Marks additional review needed label Jul 7, 2026
@centosinfra-prod-github-app

Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/rdoproject.org/buildset/69445af515a44331b6270e6a640ababb

openstack-k8s-operators-content-provider FAILURE in 5m 02s
⚠️ podified-multinode-edpm-deployment-crc-test-operator SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider

@posikoya

posikoya commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

recheck

@posikoya posikoya changed the title envtests for extraMounts feature add envtests for extraMounts feature Jul 7, 2026
@posikoya posikoya removed the ready-for-review Marks additional review needed label Jul 7, 2026
@centosinfra-prod-github-app

Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/rdoproject.org/buildset/82df967fc7a8428da0506c0ccfed1ea1

openstack-k8s-operators-content-provider FAILURE in 4m 15s
⚠️ podified-multinode-edpm-deployment-crc-test-operator SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider

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
@posikoya posikoya force-pushed the posikoya/env-tests-extraMounts branch from 2fb5c4c to f943fe3 Compare July 7, 2026 12:26
@centosinfra-prod-github-app

Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/rdoproject.org/buildset/ede7e5fb0bd34404a4014a2d72bea4a3

openstack-k8s-operators-content-provider FAILURE in 4m 22s
⚠️ podified-multinode-edpm-deployment-crc-test-operator SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider

@posikoya posikoya requested a review from kstrenkova July 7, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants