Skip to content

Commit c679210

Browse files
authored
Merge pull request #522 from andyzhangx/fix-TestLogGRPC-failure
test: fix TestLogGRPC ut failure
2 parents e044d84 + b6c05bc commit c679210

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

pkg/csi-common/server_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package csicommon
1919
import (
2020
"sync"
2121
"testing"
22+
"time"
2223

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

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

pkg/mounter/safe_mounter_v1beta_windows.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ func (mounter *csiProxyMounterV1Beta) Mount(source string, target string, fstype
118118

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

151152
// IsLikelyMountPoint - If the directory does not exists, the function will return os.ErrNotExist error.
152-
// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target
153-
// path is checked.
153+
//
154+
// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target
155+
// path is checked.
154156
func (mounter *csiProxyMounterV1Beta) IsLikelyNotMountPoint(path string) (bool, error) {
155157
klog.V(4).Infof("IsLikelyNotMountPoint: %s", path)
156158
isExists, err := mounter.ExistsPath(path)

pkg/mounter/safe_mounter_windows.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ func Split(r rune) bool {
145145

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

177178
// IsLikelyMountPoint - If the directory does not exists, the function will return os.ErrNotExist error.
178-
// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target
179-
// path is checked.
179+
//
180+
// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target
181+
// path is checked.
180182
func (mounter *csiProxyMounter) IsLikelyNotMountPoint(path string) (bool, error) {
181183
klog.V(4).Infof("IsLikelyNotMountPoint: %s", path)
182184
isExists, err := mounter.ExistsPath(path)

pkg/smb/controllerserver.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ func newSMBVolume(name string, size int64, params map[string]string) (*smbVolume
345345

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

366366
// Given a CSI volume id, return a smbVolume
367367
// sample volume Id:
368-
// smb-server.default.svc.cluster.local/share#pvc-4729891a-f57e-4982-9c60-e9884af1be2f
369-
// smb-server.default.svc.cluster.local/share#subdir#pvc-4729891a-f57e-4982-9c60-e9884af1be2f
368+
//
369+
// smb-server.default.svc.cluster.local/share#pvc-4729891a-f57e-4982-9c60-e9884af1be2f
370+
// smb-server.default.svc.cluster.local/share#subdir#pvc-4729891a-f57e-4982-9c60-e9884af1be2f
370371
func getSmbVolFromID(id string) (*smbVolume, error) {
371372
segments := strings.Split(id, separator)
372373
if len(segments) < 2 {

pkg/smb/fake_mounter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (f *fakeMounter) MountSensitive(source string, target string, fstype string
5252
return nil
5353
}
5454

55-
//IsLikelyNotMountPoint overrides mount.FakeMounter.IsLikelyNotMountPoint.
55+
// IsLikelyNotMountPoint overrides mount.FakeMounter.IsLikelyNotMountPoint.
5656
func (f *fakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
5757
if strings.Contains(file, "error_is_likely") {
5858
return false, fmt.Errorf("fake IsLikelyNotMountPoint: fake error")

0 commit comments

Comments
 (0)