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

test: add unit tests #18

Merged
merged 1 commit into from
Aug 1, 2020
Merged

Conversation

fengzixu
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR added some unit tests for csi-handler and util package

Which issue(s) this PR fixes:

Fixes #11

Special notes for your reviewer:

Rely on: kubernetes-csi/csi-test#276

Does this PR introduce a user-facing change?:

None

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 21, 2020
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 21, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @fengzixu. Thanks for your PR.

I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 21, 2020
@fengzixu
Copy link
Contributor Author

/assign @fengzixu
/assign @xing-yang
/assign @NickrenREN

@NickrenREN
Copy link
Contributor

@fengzixu thanks for doing this 👍

@NickrenREN
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 22, 2020
@xing-yang
Copy link
Contributor

@fengzixu CI failed with this error:
pkg/csi-handler/pv_checker_test.go:313:40: checker.csiControllerServer.EXPECT().ControllerGetVolume undefined (type *"github.com/kubernetes-csi/csi-test/v3/driver".MockControllerServerMockRecorder has no field or method ControllerGetVolume) pkg/csi-handler/pv_handler_test.go:193:27: controllerServer.EXPECT().ControllerGetVolume undefined (type *"github.com/kubernetes-csi/csi-test/v3/driver".MockControllerServerMockRecorder has no field or method ControllerGetVolume)

I think you need to use the latest csi-test which has ControllerGetVolume.

@fengzixu
Copy link
Contributor Author

@fengzixu CI failed with this error:
pkg/csi-handler/pv_checker_test.go:313:40: checker.csiControllerServer.EXPECT().ControllerGetVolume undefined (type *"github.com/kubernetes-csi/csi-test/v3/driver".MockControllerServerMockRecorder has no field or method ControllerGetVolume) pkg/csi-handler/pv_handler_test.go:193:27: controllerServer.EXPECT().ControllerGetVolume undefined (type *"github.com/kubernetes-csi/csi-test/v3/driver".MockControllerServerMockRecorder has no field or method ControllerGetVolume)

I think you need to use the latest csi-test which has ControllerGetVolume.

@xing-yang Yep. Let me update me

@xing-yang
Copy link
Contributor

Looks like CI still complained about ControllerGetVolume not defined.

@fengzixu fengzixu force-pushed the master branch 2 times, most recently from 0382136 to 90913a3 Compare July 23, 2020 01:19
@fengzixu
Copy link
Contributor Author

@xing-yang test has passed

pkg/csi-handler/pv_checker_test.go Show resolved Hide resolved
pkg/csi-handler/pv_checker_test.go Show resolved Hide resolved
pkg/csi-handler/pv_handler_test.go Outdated Show resolved Hide resolved
pkg/csi-handler/pv_handler_test.go Outdated Show resolved Hide resolved
pkg/csi-handler/pv_handler_test.go Outdated Show resolved Hide resolved
pkg/csi-handler/pv_handler_test.go Outdated Show resolved Hide resolved
pkg/csi-handler/pv_handler_test.go Show resolved Hide resolved
pkg/csi-handler/pv_handler_test.go Outdated Show resolved Hide resolved
pkg/csi-handler/pv_checker_test.go Show resolved Hide resolved
pkg/csi-handler/pv_checker_test.go Show resolved Hide resolved
@fengzixu
Copy link
Contributor Author

@xing-yang Hi Xing. All unit test cases have been added.

@fengzixu fengzixu requested a review from xing-yang July 29, 2020 15:33
pkg/agent/agent_test.go Outdated Show resolved Hide resolved
pkg/agent/agent_test.go Outdated Show resolved Hide resolved
pkg/agent/agent_test.go Outdated Show resolved Hide resolved
pkg/agent/agent_test.go Outdated Show resolved Hide resolved
pkg/controller/controller_test.go Outdated Show resolved Hide resolved
@xing-yang
Copy link
Contributor

Can you squash your commits?

@fengzixu fengzixu force-pushed the master branch 3 times, most recently from 2ea125d to bd1792b Compare July 30, 2020 15:33
Copy link
Contributor

@xing-yang xing-yang left a comment

Choose a reason for hiding this comment

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

I just added a couple of more comments. Looks good other than that.

pkg/agent/agent_test.go Outdated Show resolved Hide resolved
Message: "Volume not found",
},
},
NativeVolume: mock.CreatePV(2, "pvc", "pv", mock.DefaultNS, "abnormalVolume1", "pvcuid", &mock.FSVolumeMode, v1.VolumePending),
Copy link
Contributor

Choose a reason for hiding this comment

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

We are only checking volumes that are bound. If volumes are not bound, there should already be events generated by the existing controllers. Also the Message says "Volume not found" which does not match "Pending".
So change v1.VolumePending to v1.Bound

Rename "Test_AbnormalVolumeVolumePending" to "Test_AbnormalVolumeIOError". Change Message from "Volume not found" to "IO error".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only test different error message looks like not necessary. Let me remove this test case

pkg/controller/controller_test.go Show resolved Hide resolved
@xing-yang
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 1, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fengzixu, xing-yang

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 1, 2020
@k8s-ci-robot k8s-ci-robot merged commit 2ec6a30 into kubernetes-csi:master Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add UTs
4 participants