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

Tests: Add unit test and run tests with root privileges #288

Merged
merged 1 commit into from
May 24, 2020

Conversation

animeshk08
Copy link
Contributor

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

/kind test
What this PR does / why we need it:
Improves test coverage
Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:
The unit test now requires root privileges to run.
This is necessary as some operation like mounting need root priviledge

Release note:

Tests: Add unit tests for node server
Tests: Run unit tests with root priviledges
Tests: Add tests for node server

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 21, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @animeshk08. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 21, 2020
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 21, 2020
@animeshk08
Copy link
Contributor Author

Partially fixes the issue: #258

@andyzhangx
Copy link
Member

/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 May 21, 2020
@andyzhangx
Copy link
Member

@chewong some unit tests needs root permission, do you know where should we put sudo, should it be in test-infra repo, this PR tried sudo go test -v ..., it failed. thanks.

Activated service account credentials for: [pr-kubekins@kubernetes-jenkins-pull.iam.gserviceaccount.com]
+ make verify
sudo go test -v -race ./pkg/... ./test/utils/credentials
make: sudo: Command not found
make: *** [Makefile:54: unit-test] Error 127
+ EXIT_VALUE=2
+ set +o xtrace

@chewong
Copy link
Member

chewong commented May 22, 2020

@chewong some unit tests needs root permission, do you know where should we put sudo, should it be in test-infra repo, this PR tried sudo go test -v ..., it failed. thanks.

Activated service account credentials for: [pr-kubekins@kubernetes-jenkins-pull.iam.gserviceaccount.com]
+ make verify
sudo go test -v -race ./pkg/... ./test/utils/credentials
make: sudo: Command not found
make: *** [Makefile:54: unit-test] Error 127
+ EXIT_VALUE=2
+ set +o xtrace

Opened kubernetes/test-infra#17685, which might fix the issue. I don't think sudo is available in the test container. Could you try removing it?

@andyzhangx
Copy link
Member

/test pull-azurefile-csi-driver-verify
/test pull-azurefile-csi-driver-unit

@andyzhangx
Copy link
Member

@animeshk08 could you remove sudo, and try again? thanks.

@animeshk08
Copy link
Contributor Author

Thanks @andyzhangx make works now. Let me fix the errors then we are good to go with this PR :)

@andyzhangx
Copy link
Member

@animeshk08 can you squash commits next time, e.g.

git rebase -i HEAD~5

@animeshk08 animeshk08 force-pushed the node-server-test branch 6 times, most recently from cc6cacd to d14078f Compare May 23, 2020 14:14
@andyzhangx
Copy link
Member

/test pull-azurefile-csi-driver-verify

@andyzhangx
Copy link
Member

the error is different now:

=== RUN   TestNodePublishVolume
E0523 23:59:13.572690    8852 nodeserver.go:302] MakeDir failed on target: ./azure.go (mkdir ./azure.go: not a directory)
--- FAIL: TestNodePublishVolume (0.05s)
    nodeserver_test.go:147: 
        	Error Trace:	nodeserver_test.go:147
        	Error:      	Received unexpected error:
        	            	invalid argument
        	Test:       	TestNodePublishVolume
=== RUN   TestNodeUnpublishVolume
E0523 23:59:13.612379    8852 mount_linux.go:150] Mount failed: exit status 32

@animeshk08 animeshk08 force-pushed the node-server-test branch 3 times, most recently from 6d4b41d to 4b5b3b8 Compare May 24, 2020 05:36
The commit adds tests for nodeserver and
safe mounter

The commit also updates .tarvis.yaml and github
actions to run the tests with root permission.

This is necessary as some operations in
the unit tests require root priviledges
e.g. mounting.

Signed-off-by: Animesh Kumar <animuz111@gmail.com>
@animeshk08
Copy link
Contributor Author

Thank you for the help @andyzhangx. The build is passing now 🚀 I have updated Github actions to run with sudo as well.

The new coverage is:
Coverage increased (+12.4%) to 48.826%

@animeshk08 animeshk08 changed the title Tests: Add unit test and update travis and make with root priviledge Tests: Add unit test and run tests with root privileges May 24, 2020
Copy link
Member

@andyzhangx andyzhangx left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andyzhangx, animeshk08

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 lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 24, 2020
@k8s-ci-robot k8s-ci-robot merged commit a3e8d0d into kubernetes-sigs:master May 24, 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. 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants