From d14c2cca8a4b764f4ea9624fbc2cb4cce97bcd49 Mon Sep 17 00:00:00 2001 From: Nils Domrose Date: Tue, 21 May 2019 08:28:30 +0200 Subject: [PATCH] fix golint errors in test/e2e/storage/utils --- hack/.golint_failures | 1 - test/e2e/storage/utils/framework.go | 1 + test/e2e/storage/utils/local.go | 16 ++++++++-------- test/e2e/storage/utils/utils.go | 24 ++++++++++++++++++------ 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/hack/.golint_failures b/hack/.golint_failures index e587486e5db..46a58598f9c 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -597,7 +597,6 @@ test/e2e/lifecycle/bootstrap test/e2e/scalability test/e2e/storage/drivers test/e2e/storage/testsuites -test/e2e/storage/utils test/e2e/storage/vsphere test/e2e_kubeadm test/e2e_node diff --git a/test/e2e/storage/utils/framework.go b/test/e2e/storage/utils/framework.go index b8ea82b9bd2..9f4d530ad18 100644 --- a/test/e2e/storage/utils/framework.go +++ b/test/e2e/storage/utils/framework.go @@ -18,6 +18,7 @@ package utils import "github.com/onsi/ginkgo" +// SIGDescribe annotates the test with the SIG label. func SIGDescribe(text string, body func()) bool { return ginkgo.Describe("[sig-storage] "+text, body) } diff --git a/test/e2e/storage/utils/local.go b/test/e2e/storage/utils/local.go index 93a0a9ff1e4..5220ac636dd 100644 --- a/test/e2e/storage/utils/local.go +++ b/test/e2e/storage/utils/local.go @@ -36,23 +36,23 @@ import ( type LocalVolumeType string const ( - // A simple directory as local volume + // LocalVolumeDirectory reprensents a simple directory as local volume LocalVolumeDirectory LocalVolumeType = "dir" - // Like LocalVolumeDirectory but it's a symbolic link to directory + // LocalVolumeDirectoryLink is like LocalVolumeDirectory but it's a symbolic link to directory LocalVolumeDirectoryLink LocalVolumeType = "dir-link" - // Like LocalVolumeDirectory but bind mounted + // LocalVolumeDirectoryBindMounted is like LocalVolumeDirectory but bind mounted LocalVolumeDirectoryBindMounted LocalVolumeType = "dir-bindmounted" - // Like LocalVolumeDirectory but it's a symbolic link to self bind mounted directory + // LocalVolumeDirectoryLinkBindMounted is like LocalVolumeDirectory 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 LocalVolumeDirectoryLinkBindMounted LocalVolumeType = "dir-link-bindmounted" - // Use temporary filesystem as local volume + // LocalVolumeTmpfs represents a temporary filesystem to be used as local volume LocalVolumeTmpfs LocalVolumeType = "tmpfs" - // Block device, creates a local file, and maps it as a block device + // LocalVolumeBlock represents a Block device, creates a local file, and maps it as a block device LocalVolumeBlock LocalVolumeType = "block" - // Filesystem backed by a block device + // LocalVolumeBlockFS represents a filesystem backed by a block device LocalVolumeBlockFS LocalVolumeType = "blockfs" - // Use GCE Local SSD as local volume, this is a filesystem + // LocalVolumeGCELocalSSD represents a Filesystem backed by GCE Local SSD as local volume LocalVolumeGCELocalSSD LocalVolumeType = "gce-localssd-scsi-fs" ) diff --git a/test/e2e/storage/utils/utils.go b/test/e2e/storage/utils/utils.go index 6d40cf976f1..d8a6845c0ed 100644 --- a/test/e2e/storage/utils/utils.go +++ b/test/e2e/storage/utils/utils.go @@ -40,13 +40,18 @@ import ( uexec "k8s.io/utils/exec" ) +// KubeletOpt type definition type KubeletOpt string const ( - NodeStateTimeout = 1 * time.Minute - KStart KubeletOpt = "start" - KStop KubeletOpt = "stop" - KRestart KubeletOpt = "restart" + // NodeStateTimeout defines Timeout + NodeStateTimeout = 1 * time.Minute + // KStart defines start value + KStart KubeletOpt = "start" + // KStop defines stop value + KStop KubeletOpt = "stop" + // KRestart defines restart value + KRestart KubeletOpt = "restart" ) const ( @@ -205,7 +210,7 @@ func TestKubeletRestartsAndRestoresMount(c clientset.Interface, f *framework.Fra e2elog.Logf("Volume mount detected on pod %s and written file %s is readable post-restart.", clientPod.Name, file) } -// TestVolumeUnmountsFromDeletedPod tests that a volume unmounts if the client pod was deleted while the kubelet was down. +// TestVolumeUnmountsFromDeletedPodWithForceOption tests that a volume unmounts if the client pod was deleted while the kubelet was down. // forceDelete is true indicating whether the pod is forcefully deleted. func TestVolumeUnmountsFromDeletedPodWithForceOption(c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, forceDelete bool, checkSubpath bool) { nodeIP, err := framework.GetHostExternalAddress(c, clientPod) @@ -276,7 +281,7 @@ func TestVolumeUnmountsFromDeletedPod(c clientset.Interface, f *framework.Framew TestVolumeUnmountsFromDeletedPodWithForceOption(c, f, clientPod, false, false) } -// TestVolumeUnmountsFromFoceDeletedPod tests that a volume unmounts if the client pod was forcefully deleted while the kubelet was down. +// TestVolumeUnmountsFromForceDeletedPod tests that a volume unmounts if the client pod was forcefully deleted while the kubelet was down. func TestVolumeUnmountsFromForceDeletedPod(c clientset.Interface, f *framework.Framework, clientPod *v1.Pod) { TestVolumeUnmountsFromDeletedPodWithForceOption(c, f, clientPod, true, false) } @@ -328,6 +333,7 @@ func RunInPodWithVolume(c clientset.Interface, ns, claimName, command string) { framework.ExpectNoError(framework.WaitForPodSuccessInNamespaceSlow(c, pod.Name, pod.Namespace)) } +// StartExternalProvisioner create external provisioner pod func StartExternalProvisioner(c clientset.Interface, ns string, externalPluginName string) *v1.Pod { podClient := c.CoreV1().Pods(ns) @@ -401,6 +407,7 @@ func StartExternalProvisioner(c clientset.Interface, ns string, externalPluginNa return pod } +// PrivilegedTestPSPClusterRoleBinding test Pod Security Policy Role bindings func PrivilegedTestPSPClusterRoleBinding(client clientset.Interface, namespace string, teardown bool, @@ -448,6 +455,7 @@ func PrivilegedTestPSPClusterRoleBinding(client clientset.Interface, } } +// CheckVolumeModeOfPath check mode of volume func CheckVolumeModeOfPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) { if volMode == v1.PersistentVolumeBlock { // Check if block exists @@ -464,6 +472,7 @@ func CheckVolumeModeOfPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path st } } +// CheckReadWriteToPath check that path can b e read and written func CheckReadWriteToPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) { if volMode == v1.PersistentVolumeBlock { // random -> file1 @@ -490,6 +499,7 @@ func CheckReadWriteToPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path str } } +// genBinDataFromSeed generate binData with random seed func genBinDataFromSeed(len int, seed int64) []byte { binData := make([]byte, len) rand.Seed(seed) @@ -502,6 +512,7 @@ func genBinDataFromSeed(len int, seed int64) []byte { return binData } +// CheckReadFromPath validate that file can be properly read. func CheckReadFromPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string, len int, seed int64) { var pathForVolMode string if volMode == v1.PersistentVolumeBlock { @@ -516,6 +527,7 @@ func CheckReadFromPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string VerifyExecInPodSucceed(pod, fmt.Sprintf("dd if=%s bs=%d count=1 | sha256sum | grep -Fq %x", pathForVolMode, len, sum)) } +// CheckWriteToPath that file can be properly written. func CheckWriteToPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string, len int, seed int64) { var pathForVolMode string if volMode == v1.PersistentVolumeBlock {