Skip to content

Commit

Permalink
Merge pull request #522 from andyzhangx/fix-TestLogGRPC-failure
Browse files Browse the repository at this point in the history
test: fix TestLogGRPC ut failure
  • Loading branch information
andyzhangx committed Jul 31, 2022
2 parents e044d84 + b6c05bc commit c679210
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
3 changes: 3 additions & 0 deletions pkg/csi-common/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package csicommon
import (
"sync"
"testing"
"time"

"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
Expand All @@ -31,6 +32,8 @@ func TestNewNonBlockingGRPCServer(t *testing.T) {

func TestStart(t *testing.T) {
s := NewNonBlockingGRPCServer()
// sleep a while to avoid race condition in unit test
time.Sleep(time.Millisecond * 2000)
s.Start("tcp://127.0.0.1:0", nil, nil, nil, true)
}

Expand Down
10 changes: 6 additions & 4 deletions pkg/mounter/safe_mounter_v1beta_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ func (mounter *csiProxyMounterV1Beta) Mount(source string, target string, fstype

// Rmdir - delete the given directory
// TODO: Call separate rmdir for pod context and plugin context. v1alpha1 for CSI
// proxy does a relaxed check for prefix as c:\var\lib\kubelet, so we can do
// rmdir with either pod or plugin context.
//
// proxy does a relaxed check for prefix as c:\var\lib\kubelet, so we can do
// rmdir with either pod or plugin context.
func (mounter *csiProxyMounterV1Beta) Rmdir(path string) error {
klog.V(4).Infof("Remove directory: %s", path)
rmdirRequest := &fs.RmdirRequest{
Expand Down Expand Up @@ -149,8 +150,9 @@ func (mounter *csiProxyMounterV1Beta) IsMountPointMatch(mp mount.MountPoint, dir
}

// IsLikelyMountPoint - If the directory does not exists, the function will return os.ErrNotExist error.
// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target
// path is checked.
//
// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target
// path is checked.
func (mounter *csiProxyMounterV1Beta) IsLikelyNotMountPoint(path string) (bool, error) {
klog.V(4).Infof("IsLikelyNotMountPoint: %s", path)
isExists, err := mounter.ExistsPath(path)
Expand Down
10 changes: 6 additions & 4 deletions pkg/mounter/safe_mounter_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ func Split(r rune) bool {

// Rmdir - delete the given directory
// TODO: Call separate rmdir for pod context and plugin context. v1alpha1 for CSI
// proxy does a relaxed check for prefix as c:\var\lib\kubelet, so we can do
// rmdir with either pod or plugin context.
//
// proxy does a relaxed check for prefix as c:\var\lib\kubelet, so we can do
// rmdir with either pod or plugin context.
func (mounter *csiProxyMounter) Rmdir(path string) error {
klog.V(4).Infof("Remove directory: %s", path)
rmdirRequest := &fs.RmdirRequest{
Expand Down Expand Up @@ -175,8 +176,9 @@ func (mounter *csiProxyMounter) IsMountPointMatch(mp mount.MountPoint, dir strin
}

// IsLikelyMountPoint - If the directory does not exists, the function will return os.ErrNotExist error.
// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target
// path is checked.
//
// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target
// path is checked.
func (mounter *csiProxyMounter) IsLikelyNotMountPoint(path string) (bool, error) {
klog.V(4).Infof("IsLikelyNotMountPoint: %s", path)
isExists, err := mounter.ExistsPath(path)
Expand Down
9 changes: 5 additions & 4 deletions pkg/smb/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ func newSMBVolume(name string, size int64, params map[string]string) (*smbVolume

// Get internal path where the volume is created
// The reason why the internal path is "workingDir/subDir/subDir" is because:
// * the semantic is actually "workingDir/volId/subDir" and volId == subDir.
// * we need a mount directory per volId because you can have multiple
// - the semantic is actually "workingDir/volId/subDir" and volId == subDir.
// - we need a mount directory per volId because you can have multiple
// CreateVolume calls in parallel and they may use the same underlying share.
// Instead of refcounting how many CreateVolume calls are using the same
// share, it's simpler to just do a mount per request.
Expand All @@ -365,8 +365,9 @@ func (d *Driver) smbVolToCSI(vol *smbVolume, parameters map[string]string) *csi.

// Given a CSI volume id, return a smbVolume
// sample volume Id:
// smb-server.default.svc.cluster.local/share#pvc-4729891a-f57e-4982-9c60-e9884af1be2f
// smb-server.default.svc.cluster.local/share#subdir#pvc-4729891a-f57e-4982-9c60-e9884af1be2f
//
// smb-server.default.svc.cluster.local/share#pvc-4729891a-f57e-4982-9c60-e9884af1be2f
// smb-server.default.svc.cluster.local/share#subdir#pvc-4729891a-f57e-4982-9c60-e9884af1be2f
func getSmbVolFromID(id string) (*smbVolume, error) {
segments := strings.Split(id, separator)
if len(segments) < 2 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/smb/fake_mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (f *fakeMounter) MountSensitive(source string, target string, fstype string
return nil
}

//IsLikelyNotMountPoint overrides mount.FakeMounter.IsLikelyNotMountPoint.
// IsLikelyNotMountPoint overrides mount.FakeMounter.IsLikelyNotMountPoint.
func (f *fakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
if strings.Contains(file, "error_is_likely") {
return false, fmt.Errorf("fake IsLikelyNotMountPoint: fake error")
Expand Down

0 comments on commit c679210

Please sign in to comment.