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 golint failures of test/e2e/storage #77777

Merged
merged 1 commit into from
May 11, 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
1 change: 0 additions & 1 deletion hack/.golint_failures
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions test/e2e/storage/csi_mock_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
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 {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/storage/detach_mounted.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
)

var (
// BusyBoxImage is the image URI of BusyBox.
BusyBoxImage = imageutils.GetE2EImage(imageutils.BusyBox)
durationForStuckMount = 110 * time.Second
)
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/storage/nfs_persistent_volume-disruptive.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ type disruptiveTest struct {
runTest testBody
}

const (
MinNodes = 2
)

var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() {

f := framework.NewDefaultFramework("disruptive-pv")
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/storage/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
37 changes: 19 additions & 18 deletions test/e2e/storage/persistent_volumes-local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
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)
}
// 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
Expand Down
7 changes: 3 additions & 4 deletions test/e2e/storage/volume_provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,15 +847,15 @@ 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,
Name: "Gluster Dynamic provisioner test",
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)
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions test/e2e/storage/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/

// This test is volumes test for configmap.

package storage

import (
Expand Down