Skip to content
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

Code restructuring to accomodate fake clients for UT #111

Merged
merged 14 commits into from May 13, 2024
Merged

Conversation

Bhagyashreek8
Copy link
Collaborator

@Bhagyashreek8 Bhagyashreek8 commented May 8, 2024

Describe your changes

Issue ticket number and link

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests.
  • I have made sure existing UTs are not impacted
  • I have executed all necessary linter and made sure internal pipeline/travis is not broken

@Bhagyashreek8
Copy link
Collaborator Author

$ make fmt
hack/verify-golint.sh
Verifying golint
Congratulations! Lint check completed for all Go source files.
gofmt -l ./cmd/main.go ./config/driver-config.go ./tests/sanity/sanity_test.go ./tests/e2e/e2e_test.go ./tests/e2e/testsuites/test_pod_with_vol.go ./tests/e2e/testsuites/basesetups.go ./tests/e2e/testsuites/constants.go ./tests/e2e/testsuites/basespecs.go ./tests/e2e/rclone_test.go ./tests/e2e/s3fs_test.go ./pkg/mounter/mounter.go ./pkg/mounter/mounter-rclone.go ./pkg/mounter/mounter-s3fs_test.go ./pkg/mounter/mounter-s3fs.go ./pkg/driver/controllerserver.go ./pkg/driver/server.go ./pkg/driver/identityserver.go ./pkg/driver/identityserver_test.go ./pkg/driver/nodeserver_test.go ./pkg/driver/utils.go ./pkg/driver/s3-driver.go ./pkg/driver/controllerserver_test.go ./pkg/driver/fake/mounter/fake_mounter-rclone.go ./pkg/driver/fake/mounter/fake_mounter.go ./pkg/driver/fake/mounter/fake_mounter-s3fs.go ./pkg/driver/fake/s3client/fake_s3client.go ./pkg/driver/nodeserver.go ./pkg/driver/server_test.go ./pkg/driver/s3-driver_test.go ./pkg/constants/constants.go ./pkg/s3client/s3client.go ./pkg/s3client/s3client_test.go ./pkg/utils/utils.go ./pkg/utils/fake_utils.go

@Bhagyashreek8
Copy link
Collaborator Author

$ make test
go test -v -race ./cmd/... ./pkg/...
?   	github.com/IBM/ibm-object-csi-driver/cmd	[no test files]
?   	github.com/IBM/ibm-object-csi-driver/pkg/constants	[no test files]
?   	github.com/IBM/ibm-object-csi-driver/pkg/driver/fake/mounter	[no test files]
?   	github.com/IBM/ibm-object-csi-driver/pkg/driver/fake/s3client	[no test files]
?   	github.com/IBM/ibm-object-csi-driver/pkg/utils	[no test files]
=== RUN   TestControllerPublishVolume
    controllerserver_test.go:48: test case: Success attachment
--- PASS: TestControllerPublishVolume (0.00s)
=== RUN   TestControllerUnpublishVolume
    controllerserver_test.go:79: test case: Success detach volume
--- PASS: TestControllerUnpublishVolume (0.00s)
=== RUN   TestValidateVolumeCapabilities
    controllerserver_test.go:129: test case: Empty volume capabilities
    controllerserver_test.go:135: Error code
    controllerserver_test.go:129: test case: Empty volume ID
    controllerserver_test.go:135: Error code
--- PASS: TestValidateVolumeCapabilities (0.00s)
=== RUN   TestCreateSnapshot
    controllerserver_test.go:160: test case: Success create snapshot
--- PASS: TestCreateSnapshot (0.00s)
=== RUN   TestDeleteSnapshot
    controllerserver_test.go:191: test case: Success delete snapshot
--- PASS: TestDeleteSnapshot (0.00s)
=== RUN   TestListSnapshots
    controllerserver_test.go:222: test case: Success list snapshots
--- PASS: TestListSnapshots (0.00s)
=== RUN   TestControllerExpandVolume
    controllerserver_test.go:253: test case: Success controller expand volume
--- PASS: TestControllerExpandVolume (0.00s)
=== RUN   TestListVolumes
    controllerserver_test.go:284: test case: Success list volumes
--- PASS: TestListVolumes (0.00s)
=== RUN   TestGetCapacity
    controllerserver_test.go:315: test case: Success GetCapacity
--- PASS: TestGetCapacity (0.00s)
=== RUN   TestControllerGetCapabilities
    controllerserver_test.go:350: test case: Success controller get capabilities
--- PASS: TestControllerGetCapabilities (0.00s)
=== RUN   TestGetPluginInfo
--- PASS: TestGetPluginInfo (0.00s)
=== RUN   TestGetPluginCapabilities
--- PASS: TestGetPluginCapabilities (0.00s)
=== RUN   TestProbe
--- PASS: TestProbe (0.00s)
=== RUN   TestNodeGetCapabilities
--- PASS: TestNodeGetCapabilities (0.00s)
=== RUN   TestNodeExpandVolume
--- PASS: TestNodeExpandVolume (0.00s)
=== RUN   TestSetups3Driver
--- PASS: TestSetups3Driver (0.00s)
=== RUN   TestSetup
    server_test.go:38: Good setup
    server_test.go:50: Wrong endpoint format
    server_test.go:55: ---------> error parse "---:/tmp/testcsi.sock": first path segment in URL cannot contain colon
    server_test.go:59: Wrong Scheme
    server_test.go:63: ---------> error endpoint scheme not supported
    server_test.go:67: tcp Scheme
    server_test.go:71: ---------> error <nil>
    server_test.go:76: Wrong address
    server_test.go:80: ---------> error failed to listen GRPC server
--- PASS: TestSetup (0.00s)
=== RUN   TestLogGRPC
    server_test.go:85: TODO:~ TestLogGRPC
--- PASS: TestLogGRPC (0.00s)
PASS
ok  	github.com/IBM/ibm-object-csi-driver/pkg/driver	4.070s
=== RUN   TestNewS3fsMounter_Success
I0509 09:28:52.104222   48922 mounter-s3fs.go:46] -newS3fsMounter-
I0509 09:28:52.104350   48922 mounter-s3fs.go:92] newS3fsMounter args:
	bucketName: [test-bucket-name]
	objPath: [test-obj-path]
	endPoint: [test-endpoint]
	locationConstraint: [test-loc-constraint]
	authType: [iam]
	kpRootKeyCrn: [test-kp-root-key-crn]
I0509 09:28:52.104373   48922 mounter-s3fs.go:228] No new mountOptions found. Using default mountOptions: map[opt1:val1 opt2:val2]
I0509 09:28:52.104403   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [opt1=val1]
I0509 09:28:52.104418   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [opt2=val2]
I0509 09:28:52.104430   48922 mounter-s3fs.go:270] S3fsMounter Options: [opt1=val1 opt2=val2]
--- PASS: TestNewS3fsMounter_Success (0.00s)
=== RUN   TestNewS3fsMounter_Success_Hmac
I0509 09:28:52.104580   48922 mounter-s3fs.go:46] -newS3fsMounter-
I0509 09:28:52.104603   48922 mounter-s3fs.go:92] newS3fsMounter args:
	bucketName: [test-bucket-name]
	objPath: [test-obj-path]
	endPoint: [test-endpoint]
	locationConstraint: [test-loc-constraint]
	authType: [hmac]
	kpRootKeyCrn: [test-kp-root-key-crn]
I0509 09:28:52.104622   48922 mounter-s3fs.go:228] No new mountOptions found. Using default mountOptions: map[opt1:val1 opt2:val2]
I0509 09:28:52.104643   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [opt1=val1]
I0509 09:28:52.104656   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [opt2=val2]
I0509 09:28:52.104665   48922 mounter-s3fs.go:270] S3fsMounter Options: [opt1=val1 opt2=val2]
--- PASS: TestNewS3fsMounter_Success_Hmac (0.00s)
=== RUN   Test_Mount_Positive
I0509 09:28:52.104789   48922 mounter-s3fs.go:46] -newS3fsMounter-
I0509 09:28:52.104806   48922 mounter-s3fs.go:92] newS3fsMounter args:
	bucketName: [test-bucket-name]
	objPath: [test-obj-path]
	endPoint: [test-endpoint]
	locationConstraint: [test-loc-constraint]
	authType: [iam]
	kpRootKeyCrn: [test-kp-root-key-crn]
I0509 09:28:52.104824   48922 mounter-s3fs.go:228] No new mountOptions found. Using default mountOptions: map[mountOption1:mountOption1 mountOption2:mountOption2]
I0509 09:28:52.104844   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption1]
I0509 09:28:52.104855   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption2]
I0509 09:28:52.104867   48922 mounter-s3fs.go:270] S3fsMounter Options: [mountOption1 mountOption2]
I0509 09:28:52.104882   48922 mounter-s3fs.go:107] -S3FSMounter Mount-
I0509 09:28:52.104891   48922 mounter-s3fs.go:108] Mount args:
	source: <source>
	target: </tmp/test-mount>
--- PASS: Test_Mount_Positive (0.00s)
=== RUN   Test_Mount_Positive_
I0509 09:28:52.105005   48922 mounter-s3fs.go:46] -newS3fsMounter-
I0509 09:28:52.105021   48922 mounter-s3fs.go:92] newS3fsMounter args:
	bucketName: [test-bucket-name]
	objPath: [test-obj-path]
	endPoint: [test-endpoint]
	locationConstraint: [test-loc-constraint]
	authType: [iam]
	kpRootKeyCrn: [test-kp-root-key-crn]
I0509 09:28:52.105039   48922 mounter-s3fs.go:228] No new mountOptions found. Using default mountOptions: map[mountOption1:mountOption1 mountOption2:mountOption2]
I0509 09:28:52.105059   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption1]
I0509 09:28:52.105099   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption2]
I0509 09:28:52.105131   48922 mounter-s3fs.go:270] S3fsMounter Options: [mountOption1 mountOption2]
I0509 09:28:52.105224   48922 mounter-s3fs.go:107] -S3FSMounter Mount-
I0509 09:28:52.105233   48922 mounter-s3fs.go:108] Mount args:
	source: <source>
	target: </tmp/test-mount>
--- PASS: Test_Mount_Positive_ (0.00s)
=== RUN   Test_Mount_Error_Creating_Mount_Point
I0509 09:28:52.105491   48922 mounter-s3fs.go:46] -newS3fsMounter-
I0509 09:28:52.105550   48922 mounter-s3fs.go:92] newS3fsMounter args:
	bucketName: [test-bucket-name]
	objPath: [test-obj-path]
	endPoint: [test-endpoint]
	locationConstraint: [test-loc-constraint]
	authType: [iam]
	kpRootKeyCrn: [test-kp-root-key-crn]
I0509 09:28:52.105581   48922 mounter-s3fs.go:228] No new mountOptions found. Using default mountOptions: map[mountOption1:mountOption1 mountOption2:mountOption2]
I0509 09:28:52.105604   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption1]
I0509 09:28:52.105617   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption2]
I0509 09:28:52.105628   48922 mounter-s3fs.go:270] S3fsMounter Options: [mountOption1 mountOption2]
I0509 09:28:52.105640   48922 mounter-s3fs.go:107] -S3FSMounter Mount-
I0509 09:28:52.105653   48922 mounter-s3fs.go:108] Mount args:
	source: <source>
	target: </tmp/test-mount>
E0509 09:28:52.105710   48922 mounter-s3fs.go:124] S3FSMounter Mount: Cannot create directory /var/lib/ibmc-s3fs/10d878e96c06bc5308c8eb255cda9880f1260676dac3c5f2c4be71075f7842b6: error creating mount path
--- PASS: Test_Mount_Error_Creating_Mount_Point (0.00s)
=== RUN   Test_Mount_Error_Creating_PWFile
I0509 09:28:52.105845   48922 mounter-s3fs.go:46] -newS3fsMounter-
I0509 09:28:52.105892   48922 mounter-s3fs.go:92] newS3fsMounter args:
	bucketName: [test-bucket-name]
	objPath: [test-obj-path]
	endPoint: [test-endpoint]
	locationConstraint: [test-loc-constraint]
	authType: [iam]
	kpRootKeyCrn: [test-kp-root-key-crn]
I0509 09:28:52.105925   48922 mounter-s3fs.go:228] No new mountOptions found. Using default mountOptions: map[mountOption1:mountOption1 mountOption2:mountOption2]
I0509 09:28:52.105949   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption1]
I0509 09:28:52.105960   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption2]
I0509 09:28:52.105973   48922 mounter-s3fs.go:270] S3fsMounter Options: [mountOption1 mountOption2]
I0509 09:28:52.105991   48922 mounter-s3fs.go:107] -S3FSMounter Mount-
I0509 09:28:52.106016   48922 mounter-s3fs.go:108] Mount args:
	source: <source>
	target: </tmp/test-mount>
E0509 09:28:52.106062   48922 mounter-s3fs.go:131] S3FSMounter Mount: Cannot create file /var/lib/ibmc-s3fs/10d878e96c06bc5308c8eb255cda9880f1260676dac3c5f2c4be71075f7842b6/.passwd-s3fs: error creating PWFile
--- PASS: Test_Mount_Error_Creating_PWFile (0.00s)
=== RUN   Test_Mount_ErrorMount
I0509 09:28:52.106172   48922 mounter-s3fs.go:46] -newS3fsMounter-
I0509 09:28:52.106205   48922 mounter-s3fs.go:92] newS3fsMounter args:
	bucketName: [test-bucket-name]
	objPath: [test-obj-path]
	endPoint: [test-endpoint]
	locationConstraint: [test-loc-constraint]
	authType: [iam]
	kpRootKeyCrn: [test-kp-root-key-crn]
I0509 09:28:52.106221   48922 mounter-s3fs.go:228] No new mountOptions found. Using default mountOptions: map[mountOption1:mountOption1 mountOption2:mountOption2]
I0509 09:28:52.106248   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption1]
I0509 09:28:52.106261   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption2]
I0509 09:28:52.106273   48922 mounter-s3fs.go:270] S3fsMounter Options: [mountOption1 mountOption2]
I0509 09:28:52.106291   48922 mounter-s3fs.go:107] -S3FSMounter Mount-
I0509 09:28:52.106305   48922 mounter-s3fs.go:108] Mount args:
	source: <source>
	target: </tmp/test-mount>
--- PASS: Test_Mount_ErrorMount (0.00s)
=== RUN   Test_Unmount_Positive
I0509 09:28:52.106424   48922 mounter-s3fs.go:46] -newS3fsMounter-
I0509 09:28:52.106443   48922 mounter-s3fs.go:92] newS3fsMounter args:
	bucketName: [test-bucket-name]
	objPath: [test-obj-path]
	endPoint: [test-endpoint]
	locationConstraint: [test-loc-constraint]
	authType: [iam]
	kpRootKeyCrn: [test-kp-root-key-crn]
I0509 09:28:52.106460   48922 mounter-s3fs.go:228] No new mountOptions found. Using default mountOptions: map[mountOption1:mountOption1 mountOption2:mountOption2]
I0509 09:28:52.106481   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption1]
I0509 09:28:52.106494   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption2]
I0509 09:28:52.106507   48922 mounter-s3fs.go:270] S3fsMounter Options: [mountOption1 mountOption2]
I0509 09:28:52.106713   48922 mounter-s3fs.go:182] -S3FSMounter Unmount-
I0509 09:28:52.106826   48922 fake_utils.go:51] -fake-fuseUnmount-
--- PASS: Test_Unmount_Positive (0.00s)
=== RUN   Test_Unmount_Error
I0509 09:28:52.107332   48922 mounter-s3fs.go:46] -newS3fsMounter-
I0509 09:28:52.107376   48922 mounter-s3fs.go:92] newS3fsMounter args:
	bucketName: [test-bucket-name]
	objPath: [test-obj-path]
	endPoint: [test-endpoint]
	locationConstraint: [test-loc-constraint]
	authType: [iam]
	kpRootKeyCrn: [test-kp-root-key-crn]
I0509 09:28:52.107419   48922 mounter-s3fs.go:228] No new mountOptions found. Using default mountOptions: map[mountOption1:mountOption1 mountOption2:mountOption2]
I0509 09:28:52.107462   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption1]
I0509 09:28:52.107501   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [mountOption2]
I0509 09:28:52.107517   48922 mounter-s3fs.go:270] S3fsMounter Options: [mountOption1 mountOption2]
I0509 09:28:52.107721   48922 mounter-s3fs.go:182] -S3FSMounter Unmount-
I0509 09:28:52.107850   48922 fake_utils.go:51] -fake-fuseUnmount-
--- PASS: Test_Unmount_Error (0.00s)
=== RUN   TestUpdateS3FSMountOptions
I0509 09:28:52.108388   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [uid=1001]
I0509 09:28:52.108423   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [additional_option=value3]
I0509 09:28:52.108441   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [option1=value1]
I0509 09:28:52.108470   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [option2=value2]
I0509 09:28:52.108527   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [tmpdir=/tmp]
I0509 09:28:52.108541   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [use_cache=true]
I0509 09:28:52.108596   48922 mounter-s3fs.go:267] newS3fsMounter mountOption: [gid=1001]
I0509 09:28:52.108609   48922 mounter-s3fs.go:270] S3fsMounter Options: [uid=1001 additional_option=value3 option1=value1 option2=value2 tmpdir=/tmp use_cache=true gid=1001]
--- PASS: TestUpdateS3FSMountOptions (0.00s)
PASS
ok  	github.com/IBM/ibm-object-csi-driver/pkg/mounter	2.967s
=== RUN   Test_NewObjectStorageSession_Positive
--- PASS: Test_NewObjectStorageSession_Positive (0.00s)
=== RUN   Test_NewObjectStorageIAMSession_Positive
--- PASS: Test_NewObjectStorageIAMSession_Positive (0.00s)
=== RUN   Test_CheckBucketAccess_Error
--- PASS: Test_CheckBucketAccess_Error (0.00s)
=== RUN   Test_CheckBucketAccess_Positive
--- PASS: Test_CheckBucketAccess_Positive (0.00s)
=== RUN   Test_CheckObjectPathExistence_Positive
--- PASS: Test_CheckObjectPathExistence_Positive (0.00s)
=== RUN   Test_CheckObjectPathExistence_WithoutSuffix
--- PASS: Test_CheckObjectPathExistence_WithoutSuffix (0.00s)
=== RUN   Test_CheckObjectPathExistence_PathNotFound
--- PASS: Test_CheckObjectPathExistence_PathNotFound (0.00s)
=== RUN   Test_CheckObjectPathExistence_Error
--- PASS: Test_CheckObjectPathExistence_Error (0.00s)
=== RUN   Test_CreateBucketAccess_Error
--- PASS: Test_CreateBucketAccess_Error (0.00s)
=== RUN   Test_CreateBucketAccess_BucketAlreadyExists_Positive
--- PASS: Test_CreateBucketAccess_BucketAlreadyExists_Positive (0.00s)
=== RUN   Test_CreateBucket_Positive
--- PASS: Test_CreateBucket_Positive (0.00s)
=== RUN   Test_DeleteBucket_BucketAlreadyDeleted_Positive
--- PASS: Test_DeleteBucket_BucketAlreadyDeleted_Positive (0.00s)
=== RUN   Test_DeleteBucket_ListObjectsError
--- PASS: Test_DeleteBucket_ListObjectsError (0.00s)
=== RUN   Test_DeleteBucket_DeleteObjectError
--- PASS: Test_DeleteBucket_DeleteObjectError (0.00s)
=== RUN   Test_DeleteBucket_Error
--- PASS: Test_DeleteBucket_Error (0.00s)
=== RUN   Test_DeleteBucket_Positive
--- PASS: Test_DeleteBucket_Positive (0.00s)
PASS
ok  	github.com/IBM/ibm-object-csi-driver/pkg/s3client	2.116s
Bhagyashrees-MacBook-Pro-2:ibm-object-csi-driver bhagyashree$ 

@Bhagyashreek8
Copy link
Collaborator Author

Screenshot 2024-05-09 at 9 31 04 AM

@Bhagyashreek8
Copy link
Collaborator Author

go.mod Outdated Show resolved Hide resolved
pkg/driver/s3-driver.go Show resolved Hide resolved
pkg/utils/fake_driver_utils.go Outdated Show resolved Hide resolved
@Bhagyashreek8
Copy link
Collaborator Author

Verified the functionality with these changes and it works fine.

Internal linter passed - https://v3.travis.ibm.com/github/alchemy-containers/ibm-object-csi-driver/jobs/18804058

@Bhagyashreek8 Bhagyashreek8 merged commit a3f4e59 into main May 13, 2024
3 checks passed
@Bhagyashreek8 Bhagyashreek8 deleted the bha-may8-ut branch May 13, 2024 08:44
@Bhagyashreek8 Bhagyashreek8 restored the bha-may8-ut branch May 13, 2024 08:44
@Bhagyashreek8 Bhagyashreek8 changed the title UT for mounter-s3fs.go Code restructuring to accomodate fake clients for UT May 13, 2024
@ashimagarg27 ashimagarg27 deleted the bha-may8-ut branch May 16, 2024 12:05
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.

None yet

3 participants