mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +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:
		@@ -577,7 +577,6 @@ test/e2e/common
 | 
				
			|||||||
test/e2e/lifecycle/bootstrap
 | 
					test/e2e/lifecycle/bootstrap
 | 
				
			||||||
test/e2e/scalability
 | 
					test/e2e/scalability
 | 
				
			||||||
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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,13 +42,18 @@ import (
 | 
				
			|||||||
	uexec "k8s.io/utils/exec"
 | 
						uexec "k8s.io/utils/exec"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// KubeletOpt type definition
 | 
				
			||||||
type KubeletOpt string
 | 
					type KubeletOpt string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	NodeStateTimeout            = 1 * time.Minute
 | 
						// NodeStateTimeout defines Timeout
 | 
				
			||||||
	KStart           KubeletOpt = "start"
 | 
						NodeStateTimeout = 1 * time.Minute
 | 
				
			||||||
	KStop            KubeletOpt = "stop"
 | 
						// KStart defines start value
 | 
				
			||||||
	KRestart         KubeletOpt = "restart"
 | 
						KStart KubeletOpt = "start"
 | 
				
			||||||
 | 
						// KStop defines stop value
 | 
				
			||||||
 | 
						KStop KubeletOpt = "stop"
 | 
				
			||||||
 | 
						// KRestart defines restart value
 | 
				
			||||||
 | 
						KRestart KubeletOpt = "restart"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					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)
 | 
						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)
 | 
				
			||||||
@@ -278,7 +283,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)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -330,6 +335,7 @@ func RunInPodWithVolume(c clientset.Interface, ns, claimName, command string) {
 | 
				
			|||||||
	framework.ExpectNoError(e2epod.WaitForPodSuccessInNamespaceSlow(c, pod.Name, pod.Namespace))
 | 
						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 {
 | 
					func StartExternalProvisioner(c clientset.Interface, ns string, externalPluginName string) *v1.Pod {
 | 
				
			||||||
	podClient := c.CoreV1().Pods(ns)
 | 
						podClient := c.CoreV1().Pods(ns)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -403,6 +409,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,
 | 
				
			||||||
@@ -450,6 +457,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
 | 
				
			||||||
@@ -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) {
 | 
					func CheckReadWriteToPath(pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) {
 | 
				
			||||||
	if volMode == v1.PersistentVolumeBlock {
 | 
						if volMode == v1.PersistentVolumeBlock {
 | 
				
			||||||
		// random -> file1
 | 
							// 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 {
 | 
					func genBinDataFromSeed(len int, seed int64) []byte {
 | 
				
			||||||
	binData := make([]byte, len)
 | 
						binData := make([]byte, len)
 | 
				
			||||||
	rand.Seed(seed)
 | 
						rand.Seed(seed)
 | 
				
			||||||
@@ -504,6 +514,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 {
 | 
				
			||||||
@@ -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))
 | 
						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 {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user