fix golint failures of test/e2e/storage

This commit is contained in:
SataQiu 2019-05-11 23:30:17 +08:00
parent b03367bd88
commit 01d38fec16
8 changed files with 31 additions and 36 deletions

View File

@ -610,7 +610,6 @@ test/e2e/network
test/e2e/node
test/e2e/scalability
test/e2e/scheduling
test/e2e/storage
test/e2e/storage/drivers
test/e2e/storage/testsuites
test/e2e/storage/utils

View File

@ -756,12 +756,11 @@ func checkPodInfo(cs clientset.Interface, namespace, driverPodName, driverContai
return fmt.Errorf("number of found volume attributes does not match, expected %d, got %d", len(expectedAttributes), foundAttributes.Len())
}
return nil
} else {
}
if foundAttributes.Len() != 0 {
return fmt.Errorf("some unexpected volume attributes were found: %+v", foundAttributes.List())
}
return nil
}
}
func waitForCSIDriver(cs clientset.Interface, driverName string) error {
@ -774,7 +773,7 @@ func waitForCSIDriver(cs clientset.Interface, driverName string) error {
return err
}
}
return fmt.Errorf("gave up after waiting %v for CSIDriver %q.", timeout, driverName)
return fmt.Errorf("gave up after waiting %v for CSIDriver %q", timeout, driverName)
}
func destroyCSIDriver(cs clientset.Interface, driverName string) {

View File

@ -35,6 +35,7 @@ import (
)
var (
// BusyBoxImage is the image URI of BusyBox.
BusyBoxImage = imageutils.GetE2EImage(imageutils.BusyBox)
durationForStuckMount = 110 * time.Second
)

View File

@ -39,10 +39,6 @@ type disruptiveTest struct {
runTest testBody
}
const (
MinNodes = 2
)
var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() {
f := framework.NewDefaultFramework("disruptive-pv")
@ -60,7 +56,7 @@ var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() {
ginkgo.BeforeEach(func() {
// To protect the NFS volume pod from the kubelet restart, we isolate it on its own node.
framework.SkipUnlessNodeCountIsAtLeast(MinNodes)
framework.SkipUnlessNodeCountIsAtLeast(minNodes)
framework.SkipIfProviderIs("local")
c = f.ClientSet

View File

@ -421,9 +421,8 @@ var _ = utils.SIGDescribe("Pod Disks", func() {
err = cs.CoreV1().Pods(ns).Evict(evictTarget)
if err != nil {
return false, nil
} else {
return true, nil
}
return true, nil
})
framework.ExpectNoError(err, fmt.Sprintf("failed to evict host0Pod after %v", podEvictTimeout))
}

View File

@ -59,27 +59,30 @@ type localTestConfig struct {
type localVolumeType string
const (
// default local volume type, aka a directory
// DirectoryLocalVolumeType is the default local volume type, aka a directory
DirectoryLocalVolumeType localVolumeType = "dir"
// like DirectoryLocalVolumeType but it's a symbolic link to directory
// DirectoryLinkLocalVolumeType is like DirectoryLocalVolumeType,
// but it's a symbolic link to directory
DirectoryLinkLocalVolumeType localVolumeType = "dir-link"
// like DirectoryLocalVolumeType but bind mounted
// DirectoryBindMountedLocalVolumeType is like DirectoryLocalVolumeType
// but bind mounted
DirectoryBindMountedLocalVolumeType localVolumeType = "dir-bindmounted"
// like DirectoryLocalVolumeType but it's a symbolic link to self bind mounted directory
// DirectoryLinkBindMountedLocalVolumeType is like DirectoryLocalVolumeType,
// but it's a symbolic link to self bind mounted directory
// Note that bind mounting at symbolic link actually mounts at directory it
// links to.
DirectoryLinkBindMountedLocalVolumeType localVolumeType = "dir-link-bindmounted"
// creates a tmpfs and mounts it
// TmpfsLocalVolumeType creates a tmpfs and mounts it
TmpfsLocalVolumeType localVolumeType = "tmpfs"
// tests based on local ssd at /mnt/disks/by-uuid/
// GCELocalSSDVolumeType tests based on local ssd at /mnt/disks/by-uuid/
GCELocalSSDVolumeType localVolumeType = "gce-localssd-scsi-fs"
// Creates a local file, formats it, and maps it as a block device.
// BlockLocalVolumeType creates a local file, formats it, and maps it as a block device.
BlockLocalVolumeType localVolumeType = "block"
// Creates a local file serving as the backing for block device., formats it,
// and mounts it to use as FS mode local volume.
// BlockFsWithFormatLocalVolumeType creates a local file serving as the backing for block device,
// formats it, and mounts it to use as FS mode local volume.
BlockFsWithFormatLocalVolumeType localVolumeType = "blockfswithformat"
// Creates a local file serving as the backing for block device. do not format it manually,
// and mounts it to use as FS mode local volume.
// BlockFsWithoutFormatLocalVolumeType creates a local file serving as the backing for block device,
// does not format it manually, and mounts it to use as FS mode local volume.
BlockFsWithoutFormatLocalVolumeType localVolumeType = "blockfswithoutformat"
)
@ -1003,21 +1006,19 @@ func createWriteCmd(testDir string, testFile string, writeTestFileContent string
// Cleanup the file containing testFileContent.
deleteTestFileCmd := fmt.Sprintf("rm %s", testFilePath)
return fmt.Sprintf("%s && %s && %s && %s", writeTestFileCmd, sudoCmd, writeBlockCmd, deleteTestFileCmd)
} else {
}
testFilePath := filepath.Join(testDir, testFile)
return fmt.Sprintf("mkdir -p %s; echo %s > %s", testDir, writeTestFileContent, testFilePath)
}
}
func createReadCmd(testFileDir string, testFile string, volumeType localVolumeType) string {
if volumeType == BlockLocalVolumeType {
// Create the command to read the beginning of the block device and print it in ascii.
return fmt.Sprintf("hexdump -n 100 -e '100 \"%%_p\"' %s | head -1", testFileDir)
} else {
}
// Create the command to read (aka cat) a file.
testFilePath := filepath.Join(testFileDir, testFile)
return fmt.Sprintf("cat %s", testFilePath)
}
}
// Read testFile and evaluate whether it contains the testFileContent

View File

@ -847,7 +847,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
framework.SkipIfProviderIs("gke")
ginkgo.By("creating a Gluster DP server Pod")
pod := startGlusterDpServerPod(c, ns)
serverUrl := "http://" + pod.Status.PodIP + ":8081"
serverURL := "http://" + pod.Status.PodIP + ":8081"
ginkgo.By("creating a StorageClass")
test := testsuites.StorageClassTest{
Client: c,
@ -855,7 +855,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
Provisioner: "kubernetes.io/glusterfs",
ClaimSize: "2Gi",
ExpectedSize: "2Gi",
Parameters: map[string]string{"resturl": serverUrl},
Parameters: map[string]string{"resturl": serverURL},
}
suffix := fmt.Sprintf("glusterdptest")
test.Class = newStorageClass(test, ns, suffix)
@ -1206,9 +1206,8 @@ func waitForProvisionedVolumesDeleted(c clientset.Interface, scName string) ([]*
}
if len(remainingPVs) > 0 {
return false, nil // Poll until no PVs remain
} else {
return true, nil // No PVs remain
}
return true, nil // No PVs remain
})
return remainingPVs, err
}

View File

@ -15,6 +15,7 @@ limitations under the License.
*/
// This test is volumes test for configmap.
package storage
import (