Merge pull request #93176 from yuzhiquan/fix-hostpath-test

Fix for host path test case
This commit is contained in:
Kubernetes Prow Robot 2020-09-02 22:57:40 -07:00 committed by GitHub
commit adac1bfb8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -160,7 +160,7 @@ func (plugin *hostPathPlugin) NewDeleter(spec *volume.Spec) (volume.Deleter, err
func (plugin *hostPathPlugin) NewProvisioner(options volume.VolumeOptions) (volume.Provisioner, error) {
if !plugin.config.ProvisioningEnabled {
return nil, fmt.Errorf("Provisioning in volume plugin %q is disabled", plugin.GetPluginName())
return nil, fmt.Errorf("provisioning in volume plugin %q is disabled", plugin.GetPluginName())
}
return newProvisioner(options, plugin.host, plugin)
}
@ -341,7 +341,7 @@ func getVolumeSource(spec *volume.Spec) (*v1.HostPathVolumeSource, bool, error)
return spec.PersistentVolume.Spec.HostPath, spec.ReadOnly, nil
}
return nil, false, fmt.Errorf("Spec does not reference an HostPath volume type")
return nil, false, fmt.Errorf("spec does not reference an HostPath volume type")
}
type hostPathTypeChecker interface {

View File

@ -52,11 +52,11 @@ func TestCanSupport(t *testing.T) {
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(volume.VolumeConfig{}), nil /* prober */, volumetest.NewFakeVolumeHost(t, "fake", nil, nil))
plug, err := plugMgr.FindPluginByName("kubernetes.io/host-path")
plug, err := plugMgr.FindPluginByName(hostPathPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
if plug.GetPluginName() != "kubernetes.io/host-path" {
if plug.GetPluginName() != hostPathPluginName {
t.Errorf("Wrong name: %s", plug.GetPluginName())
}
if !plug.CanSupport(&volume.Spec{Volume: &v1.Volume{VolumeSource: v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{}}}}) {
@ -74,9 +74,9 @@ func TestGetAccessModes(t *testing.T) {
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(volume.VolumeConfig{}), nil /* prober */, volumetest.NewFakeVolumeHost(t, "/tmp/fake", nil, nil))
plug, err := plugMgr.FindPersistentPluginByName("kubernetes.io/host-path")
plug, err := plugMgr.FindPersistentPluginByName(hostPathPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
if len(plug.GetAccessModes()) != 1 || plug.GetAccessModes()[0] != v1.ReadWriteOnce {
t.Errorf("Expected %s PersistentVolumeAccessMode", v1.ReadWriteOnce)
@ -109,7 +109,7 @@ func TestDeleter(t *testing.T) {
spec := &volume.Spec{PersistentVolume: &v1.PersistentVolume{Spec: v1.PersistentVolumeSpec{PersistentVolumeSource: v1.PersistentVolumeSource{HostPath: &v1.HostPathVolumeSource{Path: tempPath}}}}}
plug, err := plugMgr.FindDeletablePluginBySpec(spec)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
deleter, err := plug.NewDeleter(spec)
if err != nil {
@ -230,9 +230,9 @@ func TestPlugin(t *testing.T) {
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(volume.VolumeConfig{}), nil /* prober */, volumetest.NewFakeVolumeHost(t, "fake", nil, nil))
plug, err := plugMgr.FindPluginByName("kubernetes.io/host-path")
plug, err := plugMgr.FindPluginByName(hostPathPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
volPath := "/tmp/vol1"