fix staticcheck in test/e2e/common directory

This commit is contained in:
tanjunchen 2019-10-10 14:48:04 +08:00
parent ebb7b17f4d
commit 33dda68788
9 changed files with 17 additions and 27 deletions

View File

@ -81,7 +81,6 @@ test/e2e/apimachinery
test/e2e/apps test/e2e/apps
test/e2e/auth test/e2e/auth
test/e2e/autoscaling test/e2e/autoscaling
test/e2e/common
test/e2e/instrumentation/logging/stackdriver test/e2e/instrumentation/logging/stackdriver
test/e2e/instrumentation/monitoring test/e2e/instrumentation/monitoring
test/e2e/lifecycle test/e2e/lifecycle

View File

@ -70,7 +70,6 @@ var (
KindRC = schema.GroupVersionKind{Version: "v1", Kind: "ReplicationController"} KindRC = schema.GroupVersionKind{Version: "v1", Kind: "ReplicationController"}
KindDeployment = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "Deployment"} KindDeployment = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "Deployment"}
KindReplicaSet = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "ReplicaSet"} KindReplicaSet = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "ReplicaSet"}
subresource = "scale"
) )
/* /*
@ -472,7 +471,6 @@ func runServiceAndWorkloadForResourceConsumer(c clientset.Interface, ns, name st
switch kind { switch kind {
case KindRC: case KindRC:
framework.ExpectNoError(framework.RunRC(rcConfig)) framework.ExpectNoError(framework.RunRC(rcConfig))
break
case KindDeployment: case KindDeployment:
dpConfig := testutils.DeploymentConfig{ dpConfig := testutils.DeploymentConfig{
RCConfig: rcConfig, RCConfig: rcConfig,
@ -481,14 +479,12 @@ func runServiceAndWorkloadForResourceConsumer(c clientset.Interface, ns, name st
dpConfig.NodeDumpFunc = framework.DumpNodeDebugInfo dpConfig.NodeDumpFunc = framework.DumpNodeDebugInfo
dpConfig.ContainerDumpFunc = framework.LogFailedContainers dpConfig.ContainerDumpFunc = framework.LogFailedContainers
framework.ExpectNoError(testutils.RunDeployment(dpConfig)) framework.ExpectNoError(testutils.RunDeployment(dpConfig))
break
case KindReplicaSet: case KindReplicaSet:
rsConfig := testutils.ReplicaSetConfig{ rsConfig := testutils.ReplicaSetConfig{
RCConfig: rcConfig, RCConfig: rcConfig,
} }
ginkgo.By(fmt.Sprintf("creating replicaset %s in namespace %s", rsConfig.Name, rsConfig.Namespace)) ginkgo.By(fmt.Sprintf("creating replicaset %s in namespace %s", rsConfig.Name, rsConfig.Namespace))
framework.ExpectNoError(replicaset.RunReplicaSet(rsConfig)) framework.ExpectNoError(replicaset.RunReplicaSet(rsConfig))
break
default: default:
framework.Failf(invalidKind) framework.Failf(invalidKind)
} }

View File

@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"time" "time"
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/uuid"

View File

@ -104,7 +104,7 @@ var _ = framework.KubeDescribe("Probing container", func() {
p, err := podClient.Get(p.Name, metav1.GetOptions{}) p, err := podClient.Get(p.Name, metav1.GetOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
isReady, err := testutils.PodRunningReady(p) isReady, _ := testutils.PodRunningReady(p)
gomega.Expect(isReady).NotTo(gomega.BeTrue(), "pod should be not ready") gomega.Expect(isReady).NotTo(gomega.BeTrue(), "pod should be not ready")
restartCount := getRestartCount(p) restartCount := getRestartCount(p)
@ -269,7 +269,7 @@ func GetContainerStartedTime(p *v1.Pod, containerName string) (time.Time, error)
continue continue
} }
if status.State.Running == nil { if status.State.Running == nil {
return time.Time{}, fmt.Errorf("Container is not running") return time.Time{}, fmt.Errorf("container is not running")
} }
return status.State.Running.StartedAt.Time, nil return status.State.Running.StartedAt.Time, nil
} }
@ -282,7 +282,7 @@ func GetTransitionTimeForReadyCondition(p *v1.Pod) (time.Time, error) {
return cond.LastTransitionTime.Time, nil return cond.LastTransitionTime.Time, nil
} }
} }
return time.Time{}, fmt.Errorf("No ready condition can be found for pod") return time.Time{}, fmt.Errorf("no ready condition can be found for pod")
} }
func getRestartCount(p *v1.Pod) int { func getRestartCount(p *v1.Pod) int {

View File

@ -377,8 +377,7 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
} }
ginkgo.By("creating the pod with failed condition") ginkgo.By("creating the pod with failed condition")
var podClient *framework.PodClient var podClient *framework.PodClient = f.PodClient()
podClient = f.PodClient()
pod = podClient.Create(pod) pod = podClient.Create(pod)
err := e2epod.WaitTimeoutForPodRunningInNamespace(f.ClientSet, pod.Name, pod.Namespace, framework.PodStartShortTimeout) err := e2epod.WaitTimeoutForPodRunningInNamespace(f.ClientSet, pod.Name, pod.Namespace, framework.PodStartShortTimeout)
@ -469,8 +468,7 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
} }
ginkgo.By("creating the pod") ginkgo.By("creating the pod")
var podClient *framework.PodClient var podClient *framework.PodClient = f.PodClient()
podClient = f.PodClient()
pod = podClient.Create(pod) pod = podClient.Create(pod)
ginkgo.By("waiting for pod running") ginkgo.By("waiting for pod running")
@ -607,8 +605,7 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
// Start pod // Start pod
ginkgo.By(fmt.Sprintf("Creating pod %s", pod.Name)) ginkgo.By(fmt.Sprintf("Creating pod %s", pod.Name))
var podClient *framework.PodClient var podClient *framework.PodClient = f.PodClient()
podClient = f.PodClient()
pod = podClient.Create(pod) pod = podClient.Create(pod)
defer func() { defer func() {
e2epod.DeletePodWithWait(f.ClientSet, pod) e2epod.DeletePodWithWait(f.ClientSet, pod)
@ -640,9 +637,7 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
}) })
func testPodFailSubpath(f *framework.Framework, pod *v1.Pod) { func testPodFailSubpath(f *framework.Framework, pod *v1.Pod) {
var podClient *framework.PodClient = f.PodClient()
var podClient *framework.PodClient
podClient = f.PodClient()
pod = podClient.Create(pod) pod = podClient.Create(pod)
defer func() { defer func() {

View File

@ -21,7 +21,7 @@ import (
"time" "time"
"github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog" "k8s.io/klog"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"

View File

@ -26,7 +26,7 @@ import (
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
v1 "k8s.io/api/core/v1" "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -263,7 +263,7 @@ var _ = framework.KubeDescribe("Pods", func() {
select { select {
case <-listCompleted: case <-listCompleted:
select { select {
case event, _ := <-w.ResultChan(): case event := <-w.ResultChan():
if event.Type != watch.Added { if event.Type != watch.Added {
framework.Failf("Failed to observe pod creation: %v", event) framework.Failf("Failed to observe pod creation: %v", event)
} }
@ -313,7 +313,7 @@ var _ = framework.KubeDescribe("Pods", func() {
timer := time.After(framework.DefaultPodDeletionTimeout) timer := time.After(framework.DefaultPodDeletionTimeout)
for !deleted { for !deleted {
select { select {
case event, _ := <-w.ResultChan(): case event := <-w.ResultChan():
switch event.Type { switch event.Type {
case watch.Deleted: case watch.Deleted:
lastPod = event.Object.(*v1.Pod) lastPod = event.Object.(*v1.Pod)
@ -604,10 +604,10 @@ var _ = framework.KubeDescribe("Pods", func() {
buf.Write(msg[1:]) buf.Write(msg[1:])
} }
if buf.Len() == 0 { if buf.Len() == 0 {
return fmt.Errorf("Unexpected output from server") return fmt.Errorf("unexpected output from server")
} }
if !strings.Contains(buf.String(), "remote execution test") { if !strings.Contains(buf.String(), "remote execution test") {
return fmt.Errorf("Expected to find 'remote execution test' in %q", buf.String()) return fmt.Errorf("expected to find 'remote execution test' in %q", buf.String())
} }
return nil return nil
}, time.Minute, 10*time.Second).Should(gomega.BeNil()) }, time.Minute, 10*time.Second).Should(gomega.BeNil())

View File

@ -86,7 +86,7 @@ var _ = ginkgo.Describe("[sig-storage] Projected combined", func() {
}, },
} }
f.TestContainerOutput("Check all projections for projected volume plugin", pod, 0, []string{ f.TestContainerOutput("Check all projections for projected volume plugin", pod, 0, []string{
fmt.Sprintf("%s", podName), podName,
"secret-value-1", "secret-value-1",
"configmap-value-1", "configmap-value-1",
}) })

View File

@ -124,7 +124,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
framework.SkipIfNodeOSDistroIs("windows") framework.SkipIfNodeOSDistroIs("windows")
name := "explicit-nonroot-uid" name := "explicit-nonroot-uid"
pod := makeNonRootPod(name, rootImage, pointer.Int64Ptr(1234)) pod := makeNonRootPod(name, rootImage, pointer.Int64Ptr(1234))
pod = podClient.Create(pod) podClient.Create(pod)
podClient.WaitForSuccess(name, framework.PodStartTimeout) podClient.WaitForSuccess(name, framework.PodStartTimeout)
framework.ExpectNoError(podClient.MatchContainerOutput(name, name, "1234")) framework.ExpectNoError(podClient.MatchContainerOutput(name, name, "1234"))
@ -144,7 +144,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
ginkgo.It("should run with an image specified user ID", func() { ginkgo.It("should run with an image specified user ID", func() {
name := "implicit-nonroot-uid" name := "implicit-nonroot-uid"
pod := makeNonRootPod(name, nonRootImage, nil) pod := makeNonRootPod(name, nonRootImage, nil)
pod = podClient.Create(pod) podClient.Create(pod)
podClient.WaitForSuccess(name, framework.PodStartTimeout) podClient.WaitForSuccess(name, framework.PodStartTimeout)
framework.ExpectNoError(podClient.MatchContainerOutput(name, name, "1234")) framework.ExpectNoError(podClient.MatchContainerOutput(name, name, "1234"))