Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
Loading
from

Conversation

liyuerich
Copy link
Contributor

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

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 30, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 30, 2024
@liyuerich
Copy link
Contributor Author

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 30, 2024
@liyuerich liyuerich force-pushed the volumepathhandler branch 2 times, most recently from e41a70a to d17a54b Compare November 4, 2024 01:05
@liyuerich liyuerich force-pushed the volumepathhandler branch 3 times, most recently from ab8ab7a to 73ded98 Compare December 22, 2024 09:16
@liyuerich
Copy link
Contributor Author

/test pull-kubernetes-unit

1 similar comment
@liyuerich
Copy link
Contributor Author

/test pull-kubernetes-unit

@liyuerich
Copy link
Contributor Author

@carlory , any idea about this fail?

@carlory
Copy link
Member

carlory commented Jan 2, 2025

@liyuerich please add the following content to the file volume_path_handler_linux_test.go

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")
	}
}

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: liyuerich
Once this PR has been reviewed and has the lgtm label, please assign thockin for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@carlory
Copy link
Member

carlory commented Jan 8, 2025

/retest

@liyuerich
Copy link
Contributor Author

@carlory , please review again. Thanks.

@carlory
Copy link
Member

carlory commented Jan 23, 2025

/lgtm

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

LGTM label has been added.

Git tree hash: faeb83d44e782af03c2c44b47bd9e50dac006552

@liyuerich
Copy link
Contributor Author

hi @thockin , could you help to approve? Thanks.

@thockin
Copy link
Member

thockin commented Jan 30, 2025 via email

@liyuerich
Copy link
Contributor Author

hi @thockin , is it ok to approve now? Thanks.

@liyuerich liyuerich force-pushed the volumepathhandler branch from b81cd48 to f66c673 Compare May 20, 2025 05:48
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 20, 2025
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot requested a review from carlory May 20, 2025 05:48
Signed-off-by: liyuerich <yue.li@daocloud.io>
@liyuerich liyuerich force-pushed the volumepathhandler branch from f66c673 to 1ce8503 Compare May 20, 2025 08:48
@liyuerich
Copy link
Contributor Author

/retest

@liyuerich
Copy link
Contributor Author

/cc @sunnylovestiramisu , Sunny, please review . thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/storage Categorizes an issue or PR as relevant to SIG Storage. 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.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.