mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #78148 from endyman/fix-golint-test/e2e/storage/utils
fix golint errors in test/e2e/storage/utils
This commit is contained in:
commit
08922a1399
@ -577,7 +577,6 @@ test/e2e/common
|
||||
test/e2e/lifecycle/bootstrap
|
||||
test/e2e/scalability
|
||||
test/e2e/storage/testsuites
|
||||
test/e2e/storage/utils
|
||||
test/e2e/storage/vsphere
|
||||
test/e2e_kubeadm
|
||||
test/e2e_node
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
@ -42,13 +42,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 (
|
||||
@ -207,7 +212,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)
|
||||
@ -278,7 +283,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)
|
||||
}
|
||||
@ -330,6 +335,7 @@ func RunInPodWithVolume(c clientset.Interface, ns, claimName, command string) {
|
||||
framework.ExpectNoError(e2epod.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)
|
||||
|
||||
@ -403,6 +409,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,
|
||||
@ -450,6 +457,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
|
||||
@ -466,6 +474,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
|
||||
@ -492,6 +501,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)
|
||||
@ -504,6 +514,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 {
|
||||
@ -518,6 +529,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 {
|
||||
|
Loading…
Reference in New Issue
Block a user