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

Fix some unreasonable places int csi ut #80848

Merged
merged 1 commit into from Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/volume/csi/csi_mounter_test.go
Expand Up @@ -84,10 +84,10 @@ func TestMounterGetPath(t *testing.T) {
}
csiMounter := mounter.(*csiMountMgr)

path := csiMounter.GetPath()
Copy link
Member Author

Choose a reason for hiding this comment

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

path is collided with the package name path

mountPath := csiMounter.GetPath()

if tc.path != path {
t.Errorf("expecting path %s, got %s", tc.path, path)
if tc.path != mountPath {
t.Errorf("expecting path %s, got %s", tc.path, mountPath)
}
}
}
Expand Down Expand Up @@ -215,10 +215,10 @@ func MounterSetUpTests(t *testing.T, podInfoEnabled bool) {
t.Errorf("default value of file system type was overridden by type %s", csiMounter.spec.PersistentVolume.Spec.CSI.FSType)
}

path := csiMounter.GetPath()
if _, err := os.Stat(path); err != nil {
mountPath := csiMounter.GetPath()
if _, err := os.Stat(mountPath); err != nil {
if os.IsNotExist(err) {
t.Errorf("SetUp() failed, volume path not created: %s", path)
t.Errorf("SetUp() failed, volume path not created: %s", mountPath)
} else {
t.Errorf("SetUp() failed: %v", err)
}
Expand Down
18 changes: 8 additions & 10 deletions pkg/volume/csi/csi_plugin_test.go
Expand Up @@ -549,12 +549,11 @@ func TestPluginNewMounter(t *testing.T) {
}

for _, test := range tests {
plug, tmpDir := newTestPlugin(t, nil)
defer os.RemoveAll(tmpDir)

registerFakePlugin(testDriver, "endpoint", []string{"1.2.0"}, t)

t.Run(test.name, func(t *testing.T) {
plug, tmpDir := newTestPlugin(t, nil)
defer os.RemoveAll(tmpDir)

registerFakePlugin(testDriver, "endpoint", []string{"1.2.0"}, t)
mounter, err := plug.NewMounter(
test.spec,
&api.Pod{ObjectMeta: meta.ObjectMeta{UID: test.podUID, Namespace: test.namespace}},
Expand Down Expand Up @@ -668,12 +667,11 @@ func TestPluginNewMounterWithInline(t *testing.T) {
}

for _, test := range tests {
plug, tmpDir := newTestPlugin(t, nil)
defer os.RemoveAll(tmpDir)

registerFakePlugin(testDriver, "endpoint", []string{"1.2.0"}, t)

t.Run(test.name, func(t *testing.T) {
plug, tmpDir := newTestPlugin(t, nil)
defer os.RemoveAll(tmpDir)

registerFakePlugin(testDriver, "endpoint", []string{"1.2.0"}, t)
mounter, err := plug.NewMounter(
test.spec,
&api.Pod{ObjectMeta: meta.ObjectMeta{UID: test.podUID, Namespace: test.namespace}},
Expand Down
42 changes: 22 additions & 20 deletions pkg/volume/csi/expander_test.go
Expand Up @@ -64,31 +64,33 @@ func TestNodeExpand(t *testing.T) {
},
}
for _, tc := range tests {
plug, tmpDir := newTestPlugin(t, nil)
defer os.RemoveAll(tmpDir)
t.Run(tc.name, func(t *testing.T) {
plug, tmpDir := newTestPlugin(t, nil)
defer os.RemoveAll(tmpDir)

spec := volume.NewSpecFromPersistentVolume(makeTestPV("test-pv", 10, "expandable", "test-vol"), false)
spec := volume.NewSpecFromPersistentVolume(makeTestPV("test-pv", 10, "expandable", "test-vol"), false)

newSize, _ := resource.ParseQuantity("20Gi")
newSize, _ := resource.ParseQuantity("20Gi")

resizeOptions := volume.NodeResizeOptions{
VolumeSpec: spec,
NewSize: newSize,
DeviceMountPath: "/foo/bar",
CSIVolumePhase: tc.volumePhase,
}
csiSource, _ := getCSISourceFromSpec(resizeOptions.VolumeSpec)
resizeOptions := volume.NodeResizeOptions{
VolumeSpec: spec,
NewSize: newSize,
DeviceMountPath: "/foo/bar",
CSIVolumePhase: tc.volumePhase,
}
csiSource, _ := getCSISourceFromSpec(resizeOptions.VolumeSpec)

csClient := setupClientWithExpansion(t, tc.nodeStageSet, tc.nodeExpansion)
csClient := setupClientWithExpansion(t, tc.nodeStageSet, tc.nodeExpansion)

ok, err := plug.nodeExpandWithClient(resizeOptions, csiSource, csClient)
if ok != tc.success {
if err != nil {
t.Errorf("For %s : expected %v got %v with %v", tc.name, tc.success, ok, err)
} else {
t.Errorf("For %s : expected %v got %v", tc.name, tc.success, ok)
}
ok, err := plug.nodeExpandWithClient(resizeOptions, csiSource, csClient)
if ok != tc.success {
if err != nil {
t.Errorf("For %s : expected %v got %v with %v", tc.name, tc.success, ok, err)
} else {
t.Errorf("For %s : expected %v got %v", tc.name, tc.success, ok)
}

}
}
})
}
}