mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
fix golint failures of test/e2e/storage
This commit is contained in:
parent
b03367bd88
commit
01d38fec16
@ -610,7 +610,6 @@ test/e2e/network
|
|||||||
test/e2e/node
|
test/e2e/node
|
||||||
test/e2e/scalability
|
test/e2e/scalability
|
||||||
test/e2e/scheduling
|
test/e2e/scheduling
|
||||||
test/e2e/storage
|
|
||||||
test/e2e/storage/drivers
|
test/e2e/storage/drivers
|
||||||
test/e2e/storage/testsuites
|
test/e2e/storage/testsuites
|
||||||
test/e2e/storage/utils
|
test/e2e/storage/utils
|
||||||
|
@ -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 fmt.Errorf("number of found volume attributes does not match, expected %d, got %d", len(expectedAttributes), foundAttributes.Len())
|
||||||
}
|
}
|
||||||
return nil
|
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 {
|
func waitForCSIDriver(cs clientset.Interface, driverName string) error {
|
||||||
@ -774,7 +773,7 @@ func waitForCSIDriver(cs clientset.Interface, driverName string) error {
|
|||||||
return err
|
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) {
|
func destroyCSIDriver(cs clientset.Interface, driverName string) {
|
||||||
|
@ -35,6 +35,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// BusyBoxImage is the image URI of BusyBox.
|
||||||
BusyBoxImage = imageutils.GetE2EImage(imageutils.BusyBox)
|
BusyBoxImage = imageutils.GetE2EImage(imageutils.BusyBox)
|
||||||
durationForStuckMount = 110 * time.Second
|
durationForStuckMount = 110 * time.Second
|
||||||
)
|
)
|
||||||
|
@ -39,10 +39,6 @@ type disruptiveTest struct {
|
|||||||
runTest testBody
|
runTest testBody
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
MinNodes = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() {
|
var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() {
|
||||||
|
|
||||||
f := framework.NewDefaultFramework("disruptive-pv")
|
f := framework.NewDefaultFramework("disruptive-pv")
|
||||||
@ -60,7 +56,7 @@ var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() {
|
|||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
// To protect the NFS volume pod from the kubelet restart, we isolate it on its own node.
|
// 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")
|
framework.SkipIfProviderIs("local")
|
||||||
|
|
||||||
c = f.ClientSet
|
c = f.ClientSet
|
||||||
|
@ -421,9 +421,8 @@ var _ = utils.SIGDescribe("Pod Disks", func() {
|
|||||||
err = cs.CoreV1().Pods(ns).Evict(evictTarget)
|
err = cs.CoreV1().Pods(ns).Evict(evictTarget)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
} else {
|
|
||||||
return true, nil
|
|
||||||
}
|
}
|
||||||
|
return true, nil
|
||||||
})
|
})
|
||||||
framework.ExpectNoError(err, fmt.Sprintf("failed to evict host0Pod after %v", podEvictTimeout))
|
framework.ExpectNoError(err, fmt.Sprintf("failed to evict host0Pod after %v", podEvictTimeout))
|
||||||
}
|
}
|
||||||
|
@ -59,27 +59,30 @@ type localTestConfig struct {
|
|||||||
type localVolumeType string
|
type localVolumeType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// default local volume type, aka a directory
|
// DirectoryLocalVolumeType is the default local volume type, aka a directory
|
||||||
DirectoryLocalVolumeType localVolumeType = "dir"
|
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"
|
DirectoryLinkLocalVolumeType localVolumeType = "dir-link"
|
||||||
// like DirectoryLocalVolumeType but bind mounted
|
// DirectoryBindMountedLocalVolumeType is like DirectoryLocalVolumeType
|
||||||
|
// but bind mounted
|
||||||
DirectoryBindMountedLocalVolumeType localVolumeType = "dir-bindmounted"
|
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
|
// Note that bind mounting at symbolic link actually mounts at directory it
|
||||||
// links to.
|
// links to.
|
||||||
DirectoryLinkBindMountedLocalVolumeType localVolumeType = "dir-link-bindmounted"
|
DirectoryLinkBindMountedLocalVolumeType localVolumeType = "dir-link-bindmounted"
|
||||||
// creates a tmpfs and mounts it
|
// TmpfsLocalVolumeType creates a tmpfs and mounts it
|
||||||
TmpfsLocalVolumeType localVolumeType = "tmpfs"
|
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"
|
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"
|
BlockLocalVolumeType localVolumeType = "block"
|
||||||
// Creates a local file serving as the backing for block device., formats it,
|
// BlockFsWithFormatLocalVolumeType creates a local file serving as the backing for block device,
|
||||||
// and mounts it to use as FS mode local volume.
|
// formats it, and mounts it to use as FS mode local volume.
|
||||||
BlockFsWithFormatLocalVolumeType localVolumeType = "blockfswithformat"
|
BlockFsWithFormatLocalVolumeType localVolumeType = "blockfswithformat"
|
||||||
// Creates a local file serving as the backing for block device. do not format it manually,
|
// BlockFsWithoutFormatLocalVolumeType creates a local file serving as the backing for block device,
|
||||||
// and mounts it to use as FS mode local volume.
|
// does not format it manually, and mounts it to use as FS mode local volume.
|
||||||
BlockFsWithoutFormatLocalVolumeType localVolumeType = "blockfswithoutformat"
|
BlockFsWithoutFormatLocalVolumeType localVolumeType = "blockfswithoutformat"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1003,21 +1006,19 @@ func createWriteCmd(testDir string, testFile string, writeTestFileContent string
|
|||||||
// Cleanup the file containing testFileContent.
|
// Cleanup the file containing testFileContent.
|
||||||
deleteTestFileCmd := fmt.Sprintf("rm %s", testFilePath)
|
deleteTestFileCmd := fmt.Sprintf("rm %s", testFilePath)
|
||||||
return fmt.Sprintf("%s && %s && %s && %s", writeTestFileCmd, sudoCmd, writeBlockCmd, deleteTestFileCmd)
|
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 {
|
func createReadCmd(testFileDir string, testFile string, volumeType localVolumeType) string {
|
||||||
if volumeType == BlockLocalVolumeType {
|
if volumeType == BlockLocalVolumeType {
|
||||||
// Create the command to read the beginning of the block device and print it in ascii.
|
// 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)
|
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
|
// Read testFile and evaluate whether it contains the testFileContent
|
||||||
|
@ -847,7 +847,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
|
|||||||
framework.SkipIfProviderIs("gke")
|
framework.SkipIfProviderIs("gke")
|
||||||
ginkgo.By("creating a Gluster DP server Pod")
|
ginkgo.By("creating a Gluster DP server Pod")
|
||||||
pod := startGlusterDpServerPod(c, ns)
|
pod := startGlusterDpServerPod(c, ns)
|
||||||
serverUrl := "http://" + pod.Status.PodIP + ":8081"
|
serverURL := "http://" + pod.Status.PodIP + ":8081"
|
||||||
ginkgo.By("creating a StorageClass")
|
ginkgo.By("creating a StorageClass")
|
||||||
test := testsuites.StorageClassTest{
|
test := testsuites.StorageClassTest{
|
||||||
Client: c,
|
Client: c,
|
||||||
@ -855,7 +855,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
|
|||||||
Provisioner: "kubernetes.io/glusterfs",
|
Provisioner: "kubernetes.io/glusterfs",
|
||||||
ClaimSize: "2Gi",
|
ClaimSize: "2Gi",
|
||||||
ExpectedSize: "2Gi",
|
ExpectedSize: "2Gi",
|
||||||
Parameters: map[string]string{"resturl": serverUrl},
|
Parameters: map[string]string{"resturl": serverURL},
|
||||||
}
|
}
|
||||||
suffix := fmt.Sprintf("glusterdptest")
|
suffix := fmt.Sprintf("glusterdptest")
|
||||||
test.Class = newStorageClass(test, ns, suffix)
|
test.Class = newStorageClass(test, ns, suffix)
|
||||||
@ -1206,9 +1206,8 @@ func waitForProvisionedVolumesDeleted(c clientset.Interface, scName string) ([]*
|
|||||||
}
|
}
|
||||||
if len(remainingPVs) > 0 {
|
if len(remainingPVs) > 0 {
|
||||||
return false, nil // Poll until no PVs remain
|
return false, nil // Poll until no PVs remain
|
||||||
} else {
|
|
||||||
return true, nil // No PVs remain
|
|
||||||
}
|
}
|
||||||
|
return true, nil // No PVs remain
|
||||||
})
|
})
|
||||||
return remainingPVs, err
|
return remainingPVs, err
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// This test is volumes test for configmap.
|
// This test is volumes test for configmap.
|
||||||
|
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Loading…
Reference in New Issue
Block a user