mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Fix golint errors in test/e2e/common
- Add comments for exported types - Replace Uid with UID
This commit is contained in:
parent
97d40890d0
commit
2e63bad5a3
@ -30,10 +30,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// ContainerStatusRetryTimeout represents polling threshold before giving up to get the container status
|
||||
ContainerStatusRetryTimeout = time.Minute * 5
|
||||
// ContainerStatusPollInterval represents duration between polls to get the container status
|
||||
ContainerStatusPollInterval = time.Second * 1
|
||||
)
|
||||
|
||||
// ConformanceContainer defines the types for running container conformance test cases
|
||||
// One pod one container
|
||||
type ConformanceContainer struct {
|
||||
Container v1.Container
|
||||
@ -46,6 +49,7 @@ type ConformanceContainer struct {
|
||||
PodSecurityContext *v1.PodSecurityContext
|
||||
}
|
||||
|
||||
// Create creates the defined conformance container
|
||||
func (cc *ConformanceContainer) Create() {
|
||||
cc.podName = cc.Container.Name + string(uuid.NewUUID())
|
||||
imagePullSecrets := []v1.LocalObjectReference{}
|
||||
@ -69,10 +73,12 @@ func (cc *ConformanceContainer) Create() {
|
||||
cc.PodClient.Create(pod)
|
||||
}
|
||||
|
||||
// Delete deletes the defined conformance container
|
||||
func (cc *ConformanceContainer) Delete() error {
|
||||
return cc.PodClient.Delete(context.TODO(), cc.podName, *metav1.NewDeleteOptions(0))
|
||||
}
|
||||
|
||||
// IsReady returns whether this container is ready and error if any
|
||||
func (cc *ConformanceContainer) IsReady() (bool, error) {
|
||||
pod, err := cc.PodClient.Get(context.TODO(), cc.podName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
@ -81,6 +87,7 @@ func (cc *ConformanceContainer) IsReady() (bool, error) {
|
||||
return podutil.IsPodReady(pod), nil
|
||||
}
|
||||
|
||||
// GetPhase returns the phase of the pod lifecycle and error if any
|
||||
func (cc *ConformanceContainer) GetPhase() (v1.PodPhase, error) {
|
||||
pod, err := cc.PodClient.Get(context.TODO(), cc.podName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
@ -89,6 +96,7 @@ func (cc *ConformanceContainer) GetPhase() (v1.PodPhase, error) {
|
||||
return pod.Status.Phase, nil
|
||||
}
|
||||
|
||||
// GetStatus returns the details of the current status of this container and error if any
|
||||
func (cc *ConformanceContainer) GetStatus() (v1.ContainerStatus, error) {
|
||||
pod, err := cc.PodClient.Get(context.TODO(), cc.podName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
@ -101,6 +109,7 @@ func (cc *ConformanceContainer) GetStatus() (v1.ContainerStatus, error) {
|
||||
return statuses[0], nil
|
||||
}
|
||||
|
||||
// Present returns whether this pod is present and error if any
|
||||
func (cc *ConformanceContainer) Present() (bool, error) {
|
||||
_, err := cc.PodClient.Get(context.TODO(), cc.podName, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
@ -112,15 +121,21 @@ func (cc *ConformanceContainer) Present() (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// ContainerState represents different states of its lifecycle
|
||||
type ContainerState string
|
||||
|
||||
const (
|
||||
ContainerStateWaiting ContainerState = "Waiting"
|
||||
ContainerStateRunning ContainerState = "Running"
|
||||
// ContainerStateWaiting represents 'Waiting' container state
|
||||
ContainerStateWaiting ContainerState = "Waiting"
|
||||
// ContainerStateRunning represents 'Running' container state
|
||||
ContainerStateRunning ContainerState = "Running"
|
||||
// ContainerStateTerminated represents 'Terminated' container state
|
||||
ContainerStateTerminated ContainerState = "Terminated"
|
||||
ContainerStateUnknown ContainerState = "Unknown"
|
||||
// ContainerStateUnknown represents 'Unknown' container state
|
||||
ContainerStateUnknown ContainerState = "Unknown"
|
||||
)
|
||||
|
||||
// GetContainerState returns current state the container represents among its lifecyle
|
||||
func GetContainerState(state v1.ContainerState) ContainerState {
|
||||
if state.Waiting != nil {
|
||||
return ContainerStateWaiting
|
||||
|
@ -420,6 +420,7 @@ var _ = framework.KubeDescribe("Probing container", func() {
|
||||
})
|
||||
})
|
||||
|
||||
// GetContainerStartedTime returns the time when the given container started and error if any
|
||||
func GetContainerStartedTime(p *v1.Pod, containerName string) (time.Time, error) {
|
||||
for _, status := range p.Status.ContainerStatuses {
|
||||
if status.Name != containerName {
|
||||
@ -433,6 +434,7 @@ func GetContainerStartedTime(p *v1.Pod, containerName string) (time.Time, error)
|
||||
return time.Time{}, fmt.Errorf("cannot find container named %q", containerName)
|
||||
}
|
||||
|
||||
// GetTransitionTimeForReadyCondition returns the time when the given pod became ready and error if any
|
||||
func GetTransitionTimeForReadyCondition(p *v1.Pod) (time.Time, error) {
|
||||
for _, cond := range p.Status.Conditions {
|
||||
if cond.Type == v1.PodReady {
|
||||
@ -570,6 +572,7 @@ func (b webserverProbeBuilder) build() *v1.Probe {
|
||||
return probe
|
||||
}
|
||||
|
||||
// RunLivenessTest verifies the number of restarts for pod with given expected number of restarts
|
||||
func RunLivenessTest(f *framework.Framework, pod *v1.Pod, expectNumRestarts int, timeout time.Duration) {
|
||||
podClient := f.PodClient()
|
||||
ns := f.Namespace.Name
|
||||
|
@ -39,7 +39,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
nonRootUid = int64(1001)
|
||||
nonRootUID = int64(1001)
|
||||
)
|
||||
|
||||
var _ = ginkgo.Describe("[sig-storage] EmptyDir volumes", func() {
|
||||
@ -57,11 +57,11 @@ var _ = ginkgo.Describe("[sig-storage] EmptyDir volumes", func() {
|
||||
})
|
||||
|
||||
ginkgo.It("new files should be created with FSGroup ownership when container is non-root", func() {
|
||||
doTestSetgidFSGroup(f, nonRootUid, v1.StorageMediumMemory)
|
||||
doTestSetgidFSGroup(f, nonRootUID, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
ginkgo.It("nonexistent volume subPath should have the correct mode and owner using FSGroup", func() {
|
||||
doTestSubPathFSGroup(f, nonRootUid, v1.StorageMediumMemory)
|
||||
doTestSubPathFSGroup(f, nonRootUID, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
ginkgo.It("files with FSGroup ownership should support (root,0644,tmpfs)", func() {
|
||||
@ -124,7 +124,7 @@ var _ = ginkgo.Describe("[sig-storage] EmptyDir volumes", func() {
|
||||
This test is marked LinuxOnly since Windows does not support setting specific file permissions, or running as UID / GID, or the medium = 'Memory'.
|
||||
*/
|
||||
framework.ConformanceIt("should support (non-root,0644,tmpfs) [LinuxOnly] [NodeConformance]", func() {
|
||||
doTest0644(f, nonRootUid, v1.StorageMediumMemory)
|
||||
doTest0644(f, nonRootUID, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
/*
|
||||
@ -134,7 +134,7 @@ var _ = ginkgo.Describe("[sig-storage] EmptyDir volumes", func() {
|
||||
This test is marked LinuxOnly since Windows does not support setting specific file permissions, or running as UID / GID, or the medium = 'Memory'.
|
||||
*/
|
||||
framework.ConformanceIt("should support (non-root,0666,tmpfs) [LinuxOnly] [NodeConformance]", func() {
|
||||
doTest0666(f, nonRootUid, v1.StorageMediumMemory)
|
||||
doTest0666(f, nonRootUID, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
/*
|
||||
@ -144,7 +144,7 @@ var _ = ginkgo.Describe("[sig-storage] EmptyDir volumes", func() {
|
||||
This test is marked LinuxOnly since Windows does not support setting specific file permissions, or running as UID / GID, or the medium = 'Memory'.
|
||||
*/
|
||||
framework.ConformanceIt("should support (non-root,0777,tmpfs) [LinuxOnly] [NodeConformance]", func() {
|
||||
doTest0777(f, nonRootUid, v1.StorageMediumMemory)
|
||||
doTest0777(f, nonRootUID, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
/*
|
||||
@ -194,7 +194,7 @@ var _ = ginkgo.Describe("[sig-storage] EmptyDir volumes", func() {
|
||||
This test is marked LinuxOnly since Windows does not support setting specific file permissions, or running as UID / GID.
|
||||
*/
|
||||
framework.ConformanceIt("should support (non-root,0644,default) [LinuxOnly] [NodeConformance]", func() {
|
||||
doTest0644(f, nonRootUid, v1.StorageMediumDefault)
|
||||
doTest0644(f, nonRootUID, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
/*
|
||||
@ -204,7 +204,7 @@ var _ = ginkgo.Describe("[sig-storage] EmptyDir volumes", func() {
|
||||
This test is marked LinuxOnly since Windows does not support setting specific file permissions, or running as UID / GID.
|
||||
*/
|
||||
framework.ConformanceIt("should support (non-root,0666,default) [LinuxOnly] [NodeConformance]", func() {
|
||||
doTest0666(f, nonRootUid, v1.StorageMediumDefault)
|
||||
doTest0666(f, nonRootUID, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
/*
|
||||
@ -214,7 +214,7 @@ var _ = ginkgo.Describe("[sig-storage] EmptyDir volumes", func() {
|
||||
This test is marked LinuxOnly since Windows does not support setting specific file permissions, or running as UID / GID.
|
||||
*/
|
||||
framework.ConformanceIt("should support (non-root,0777,default) [LinuxOnly] [NodeConformance]", func() {
|
||||
doTest0777(f, nonRootUid, v1.StorageMediumDefault)
|
||||
doTest0777(f, nonRootUID, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
/*
|
||||
|
@ -36,6 +36,7 @@ const (
|
||||
etcHostsOriginalPath = "/etc/hosts-original"
|
||||
)
|
||||
|
||||
// KubeletManagedHostConfig defines the types for running managed etc hosts test cases
|
||||
type KubeletManagedHostConfig struct {
|
||||
hostNetworkPod *v1.Pod
|
||||
pod *v1.Pod
|
||||
|
Loading…
Reference in New Issue
Block a user