fix golint errors in test/e2e/storage/utils

This commit is contained in:
Nils Domrose 2019-05-21 08:28:30 +02:00 committed by Nils Domrose
parent 1ae2a5d0f6
commit d14c2cca8a
4 changed files with 27 additions and 15 deletions

View File

@ -597,7 +597,6 @@ test/e2e/lifecycle/bootstrap
test/e2e/scalability test/e2e/scalability
test/e2e/storage/drivers test/e2e/storage/drivers
test/e2e/storage/testsuites test/e2e/storage/testsuites
test/e2e/storage/utils
test/e2e/storage/vsphere test/e2e/storage/vsphere
test/e2e_kubeadm test/e2e_kubeadm
test/e2e_node test/e2e_node

View File

@ -18,6 +18,7 @@ package utils
import "github.com/onsi/ginkgo" import "github.com/onsi/ginkgo"
// SIGDescribe annotates the test with the SIG label.
func SIGDescribe(text string, body func()) bool { func SIGDescribe(text string, body func()) bool {
return ginkgo.Describe("[sig-storage] "+text, body) return ginkgo.Describe("[sig-storage] "+text, body)
} }

View File

@ -36,23 +36,23 @@ import (
type LocalVolumeType string type LocalVolumeType string
const ( const (
// A simple directory as local volume // LocalVolumeDirectory reprensents a simple directory as local volume
LocalVolumeDirectory LocalVolumeType = "dir" 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" LocalVolumeDirectoryLink LocalVolumeType = "dir-link"
// Like LocalVolumeDirectory but bind mounted // LocalVolumeDirectoryBindMounted is like LocalVolumeDirectory but bind mounted
LocalVolumeDirectoryBindMounted LocalVolumeType = "dir-bindmounted" 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 // Note that bind mounting at symbolic link actually mounts at directory it
// links to // links to
LocalVolumeDirectoryLinkBindMounted LocalVolumeType = "dir-link-bindmounted" 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" 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" LocalVolumeBlock LocalVolumeType = "block"
// Filesystem backed by a block device // LocalVolumeBlockFS represents a filesystem backed by a block device
LocalVolumeBlockFS LocalVolumeType = "blockfs" 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" LocalVolumeGCELocalSSD LocalVolumeType = "gce-localssd-scsi-fs"
) )

View File

@ -40,12 +40,17 @@ import (
uexec "k8s.io/utils/exec" uexec "k8s.io/utils/exec"
) )
// KubeletOpt type definition
type KubeletOpt string type KubeletOpt string
const ( const (
// NodeStateTimeout defines Timeout
NodeStateTimeout = 1 * time.Minute NodeStateTimeout = 1 * time.Minute
// KStart defines start value
KStart KubeletOpt = "start" KStart KubeletOpt = "start"
// KStop defines stop value
KStop KubeletOpt = "stop" KStop KubeletOpt = "stop"
// KRestart defines restart value
KRestart KubeletOpt = "restart" KRestart KubeletOpt = "restart"
) )
@ -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) 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. // 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) { func TestVolumeUnmountsFromDeletedPodWithForceOption(c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, forceDelete bool, checkSubpath bool) {
nodeIP, err := framework.GetHostExternalAddress(c, clientPod) nodeIP, err := framework.GetHostExternalAddress(c, clientPod)
@ -276,7 +281,7 @@ func TestVolumeUnmountsFromDeletedPod(c clientset.Interface, f *framework.Framew
TestVolumeUnmountsFromDeletedPodWithForceOption(c, f, clientPod, false, false) 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) { func TestVolumeUnmountsFromForceDeletedPod(c clientset.Interface, f *framework.Framework, clientPod *v1.Pod) {
TestVolumeUnmountsFromDeletedPodWithForceOption(c, f, clientPod, true, false) 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)) 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 { func StartExternalProvisioner(c clientset.Interface, ns string, externalPluginName string) *v1.Pod {
podClient := c.CoreV1().Pods(ns) podClient := c.CoreV1().Pods(ns)
@ -401,6 +407,7 @@ func StartExternalProvisioner(c clientset.Interface, ns string, externalPluginNa
return pod return pod
} }
// PrivilegedTestPSPClusterRoleBinding test Pod Security Policy Role bindings
func PrivilegedTestPSPClusterRoleBinding(client clientset.Interface, func PrivilegedTestPSPClusterRoleBinding(client clientset.Interface,
namespace string, namespace string,
teardown bool, 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) { func CheckVolumeModeOfPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) {
if volMode == v1.PersistentVolumeBlock { if volMode == v1.PersistentVolumeBlock {
// Check if block exists // 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) { func CheckReadWriteToPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) {
if volMode == v1.PersistentVolumeBlock { if volMode == v1.PersistentVolumeBlock {
// random -> file1 // 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 { func genBinDataFromSeed(len int, seed int64) []byte {
binData := make([]byte, len) binData := make([]byte, len)
rand.Seed(seed) rand.Seed(seed)
@ -502,6 +512,7 @@ func genBinDataFromSeed(len int, seed int64) []byte {
return binData return binData
} }
// CheckReadFromPath validate that file can be properly read.
func CheckReadFromPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string, len int, seed int64) { func CheckReadFromPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string, len int, seed int64) {
var pathForVolMode string var pathForVolMode string
if volMode == v1.PersistentVolumeBlock { 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)) 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) { func CheckWriteToPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string, len int, seed int64) {
var pathForVolMode string var pathForVolMode string
if volMode == v1.PersistentVolumeBlock { if volMode == v1.PersistentVolumeBlock {