Skip to content

add unit tests to validate mount options#1043

Open
Sneha-at wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
Sneha-at:add_token_retry
Open

add unit tests to validate mount options#1043
Sneha-at wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
Sneha-at:add_token_retry

Conversation

@Sneha-at
Copy link
Copy Markdown
Collaborator

@Sneha-at Sneha-at commented Oct 24, 2025

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation

/kind failing-test

/kind feature
/kind flake

What this PR does / why we need it:
Adds unit tests to validate fuse mount options are correctly set for respective features.
Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:
Testing
Feature overlay

make e2e-test E2E_TEST_USE_GKE_MANAGED_DRIVER=false E2E_TEST_BUILD_DRIVER=false BUILD_GCSFUSE_FROM_SOURCE=false  STAGINGVERSION=$STAGINGVERSION  REGISTRY=$REGISTRY  OVERLAY=sidecar_bucket_access_check ENABLE_SIDECAR_BUCKET_ACCESS_CHECK=true
PROJECT is snehaaradhey-gke-dev
OVERLAY is sidecar_bucket_access_check
STAGINGVERSION is test-unit-test-prow-gob-internal-boskos-1
DRIVER_IMAGE is us-central1-docker.pkg.dev/snehaaradhey-gke-dev/csi-dev/gcs-fuse-csi-driver
SIDECAR_IMAGE is us-central1-docker.pkg.dev/snehaaradhey-gke-dev/csi-dev/gcs-fuse-csi-driver-sidecar-mounter
WEBHOOK_IMAGE is us-central1-docker.pkg.dev/snehaaradhey-gke-dev/csi-dev/gcs-fuse-csi-driver-webhook
.......
Ran 340 of 453 Specs in 4881.595 seconds
SUCCESS! -- 340 Passed | 0 Failed | 1 Flaked | 0 Pending | 113 Skipped

Ginkgo ran 1 suite in 1h21m42.202261817s
Test Suite Passed

Stable overlay

make e2e-test E2E_TEST_USE_GKE_MANAGED_DRIVER=false E2E_TEST_BUILD_DRIVER=false BUILD_GCSFUSE_FROM_SOURCE=false  STAGINGVERSION=$STAGINGVERSION  REGISTRY=$REGISTRY  
PROJECT is snehaaradhey-gke-dev
OVERLAY is stable
STAGINGVERSION is test-unit-test-prow-gob-internal-boskos-1
DRIVER_IMAGE is us-central1-docker.pkg.dev/snehaaradhey-gke-dev/csi-dev/gcs-fuse-csi-driver
SIDECAR_IMAGE is us-central1-docker.pkg.dev/snehaaradhey-gke-dev/csi-dev/gcs-fuse-csi-driver-sidecar-mounter
WEBHOOK_IMAGE is us-central1-docker.pkg.dev/snehaaradhey-gke-dev/csi-dev/gcs-fuse-csi-driver-webhook
.......
------------------------------
[ReportAfterSuite] PASSED [0.138 seconds]
[ReportAfterSuite] Autogenerated ReportAfterSuite for --junit-report
autogenerated by Ginkgo
------------------------------

Ran 338 of 453 Specs in 4700.386 seconds
SUCCESS! -- 338 Passed | 0 Failed | 0 Pending | 115 Skipped


Ginkgo ran 1 suite in 1h18m30.337829414s
Test Suite Passed

Does this PR introduce a user-facing change?:

NONE

},
},
{
name: "validate sidecar bucket access check is disabled when host network is enabled",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please include scenario and expected outcome in the test name: https://engdoc.corp.google.com/eng/doc/tott/episodes/660.md?cl=head


if enableCloudProfilerForSidecar && gcsFuseSidecarImage != "" && isSidecarVersionSupportedForGivenFeature(gcsFuseSidecarImage, SidecarCloudProfilerMinVersion) {
fuseMountOptions = joinMountOptions(fuseMountOptions, []string{util.EnableCloudProfilerForSidecarConst + "=" + strconv.FormatBool(enableCloudProfilerForSidecar)})
enableCloudProfilerForVersion := enableCloudProfilerForSidecar && gcsFuseSidecarImage != "" && isSidecarVersionSupportedForGivenFeature(gcsFuseSidecarImage, SidecarCloudProfilerMinVersion)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we return error at the beginning if gcsFuseSidecarImage == "" instead of continuing to check for this throughout? gcsFuseSidecarImage == "" should should never happen, and if it does, we should return error

return ""
}

func addFuseMountOptions(identityProvider string, identityPool string, fuseMountOptions []string, vc map[string]string, hostNetworkEnabled bool, enableSidecarBucketAccessCheckForSidecarVersion bool, enableCloudProfilerForVersion bool) ([]string, error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add function comment .
Is there a reason why we didn't put everything into addFuseMountOptions. For example, testing the MachineTypeAutoConfig?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I have added all the references for joinMountptions call in this addFuseMountOptionsfunction. MachineTypeAutoConfig seems to be using a slightly different approach to pass in the mount options so did not combine that.

}
}

func TestAddFuseMountOptions(t *testing.T) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add additional missing test cases.

  • Case where inputFuseMountOptions != []string{} (What happens if a field already exists that we need to add?)

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.

2 participants