Skip to content

Commit adac1bf

Browse files
authored
Merge pull request kubernetes#93176 from yuzhiquan/fix-hostpath-test
Fix for host path test case
2 parents 0b92e8b + aca107e commit adac1bf

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pkg/volume/hostpath/host_path.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (plugin *hostPathPlugin) NewDeleter(spec *volume.Spec) (volume.Deleter, err
160160

161161
func (plugin *hostPathPlugin) NewProvisioner(options volume.VolumeOptions) (volume.Provisioner, error) {
162162
if !plugin.config.ProvisioningEnabled {
163-
return nil, fmt.Errorf("Provisioning in volume plugin %q is disabled", plugin.GetPluginName())
163+
return nil, fmt.Errorf("provisioning in volume plugin %q is disabled", plugin.GetPluginName())
164164
}
165165
return newProvisioner(options, plugin.host, plugin)
166166
}
@@ -341,7 +341,7 @@ func getVolumeSource(spec *volume.Spec) (*v1.HostPathVolumeSource, bool, error)
341341
return spec.PersistentVolume.Spec.HostPath, spec.ReadOnly, nil
342342
}
343343

344-
return nil, false, fmt.Errorf("Spec does not reference an HostPath volume type")
344+
return nil, false, fmt.Errorf("spec does not reference an HostPath volume type")
345345
}
346346

347347
type hostPathTypeChecker interface {

pkg/volume/hostpath/host_path_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ func TestCanSupport(t *testing.T) {
5252
plugMgr := volume.VolumePluginMgr{}
5353
plugMgr.InitPlugins(ProbeVolumePlugins(volume.VolumeConfig{}), nil /* prober */, volumetest.NewFakeVolumeHost(t, "fake", nil, nil))
5454

55-
plug, err := plugMgr.FindPluginByName("kubernetes.io/host-path")
55+
plug, err := plugMgr.FindPluginByName(hostPathPluginName)
5656
if err != nil {
57-
t.Errorf("Can't find the plugin by name")
57+
t.Fatal("Can't find the plugin by name")
5858
}
59-
if plug.GetPluginName() != "kubernetes.io/host-path" {
59+
if plug.GetPluginName() != hostPathPluginName {
6060
t.Errorf("Wrong name: %s", plug.GetPluginName())
6161
}
6262
if !plug.CanSupport(&volume.Spec{Volume: &v1.Volume{VolumeSource: v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{}}}}) {
@@ -74,9 +74,9 @@ func TestGetAccessModes(t *testing.T) {
7474
plugMgr := volume.VolumePluginMgr{}
7575
plugMgr.InitPlugins(ProbeVolumePlugins(volume.VolumeConfig{}), nil /* prober */, volumetest.NewFakeVolumeHost(t, "/tmp/fake", nil, nil))
7676

77-
plug, err := plugMgr.FindPersistentPluginByName("kubernetes.io/host-path")
77+
plug, err := plugMgr.FindPersistentPluginByName(hostPathPluginName)
7878
if err != nil {
79-
t.Errorf("Can't find the plugin by name")
79+
t.Fatal("Can't find the plugin by name")
8080
}
8181
if len(plug.GetAccessModes()) != 1 || plug.GetAccessModes()[0] != v1.ReadWriteOnce {
8282
t.Errorf("Expected %s PersistentVolumeAccessMode", v1.ReadWriteOnce)
@@ -109,7 +109,7 @@ func TestDeleter(t *testing.T) {
109109
spec := &volume.Spec{PersistentVolume: &v1.PersistentVolume{Spec: v1.PersistentVolumeSpec{PersistentVolumeSource: v1.PersistentVolumeSource{HostPath: &v1.HostPathVolumeSource{Path: tempPath}}}}}
110110
plug, err := plugMgr.FindDeletablePluginBySpec(spec)
111111
if err != nil {
112-
t.Errorf("Can't find the plugin by name")
112+
t.Fatal("Can't find the plugin by name")
113113
}
114114
deleter, err := plug.NewDeleter(spec)
115115
if err != nil {
@@ -230,9 +230,9 @@ func TestPlugin(t *testing.T) {
230230
plugMgr := volume.VolumePluginMgr{}
231231
plugMgr.InitPlugins(ProbeVolumePlugins(volume.VolumeConfig{}), nil /* prober */, volumetest.NewFakeVolumeHost(t, "fake", nil, nil))
232232

233-
plug, err := plugMgr.FindPluginByName("kubernetes.io/host-path")
233+
plug, err := plugMgr.FindPluginByName(hostPathPluginName)
234234
if err != nil {
235-
t.Errorf("Can't find the plugin by name")
235+
t.Fatal("Can't find the plugin by name")
236236
}
237237

238238
volPath := "/tmp/vol1"

0 commit comments

Comments
 (0)