-
Notifications
You must be signed in to change notification settings - Fork 40.6k
add UT for volumepathhandler #128429
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
base: master
Are you sure you want to change the base?
add UT for volumepathhandler #128429
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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-sigs/prow repository. |
/release-note-none |
e41a70a
to
d17a54b
Compare
d17a54b
to
bafd6d1
Compare
ab8ab7a
to
73ded98
Compare
/test pull-kubernetes-unit |
1 similar comment
/test pull-kubernetes-unit |
@carlory , any idea about this fail? |
@liyuerich please add the following content to the file package volumepathhandler
import (
"fmt"
"path/filepath"
"testing"
utilexec "k8s.io/utils/exec"
)
func createTestDevice(t *testing.T) string {
executor := utilexec.New()
backingFile := filepath.Join(t.TempDir(), "backingFile")
out, err := executor.Command("fallocate", "-l", "1M", backingFile).CombinedOutput()
if err != nil {
t.Fatalf("failed to create backing file: %v, %v", err, string(out))
}
devicePath, err := makeLoopDevice(backingFile)
if err != nil {
t.Fatalf("failed to create loop device: %v", err)
}
t.Cleanup(func() {
err := removeLoopDevice(devicePath)
if err != nil {
t.Errorf("failed to remove loop device: %v", err)
}
})
return devicePath
}
func TestIsDeviceBindMountExist(t *testing.T) {
devicePath := createTestDevice(t)
handler := VolumePathHandler{}
mapPath := t.TempDir()
linkName := "link"
err := mapBindMountDevice(handler, devicePath, mapPath, linkName)
if err != nil {
t.Fatalf("failed to map bind mount: %v", err)
}
t.Cleanup(func() {
err := unmapBindMountDevice(handler, mapPath, linkName)
if err != nil {
t.Fatalf("failed to unmap bind mount: %v", err)
}
})
linkPath := filepath.Join(mapPath, linkName)
yes, err := handler.IsDeviceBindMountExist(linkPath)
if err != nil {
t.Fatalf("failed to check bind mount: %v", err)
}
if !yes {
t.Fatalf("expected device bind mount")
}
} |
73ded98
to
3df9697
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: liyuerich The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
3df9697
to
b81cd48
Compare
@carlory , please review again. Thanks. |
/lgtm |
LGTM label has been added. Git tree hash: faeb83d44e782af03c2c44b47bd9e50dac006552
|
hi @thockin , could you help to approve? Thanks. |
Most PRs are prioritized behind KEPs at the moment. It's in my queue.
…On Thu, Jan 23, 2025 at 9:51 PM liyue ***@***.***> wrote:
hi @thockin <https://github.com/thockin> , could you help to approve?
Thanks.
—
Reply to this email directly, view it on GitHub
<#128429 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKWAVFDSD7MA474M2EGV432MHIGJAVCNFSM6AAAAABQ3B7SHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMJRGY2TQMBYGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
hi @thockin , is it ok to approve now? Thanks. |
b81cd48
to
f66c673
Compare
New changes are detected. LGTM label has been removed. |
Signed-off-by: liyuerich <yue.li@daocloud.io>
f66c673
to
1ce8503
Compare
/retest |
/cc @sunnylovestiramisu , Sunny, please review . thanks. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
add UT for pkg/volume/util/volumepathhandler/volume_path_handler.go, UT coverage can increase from 0% to 34.2%
Which issue(s) this PR fixes:
NONE
Special notes for your reviewer:
NONE
Does this PR introduce a user-facing change?
NONE
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
NONE