fix golint failures for test/e2e/servicecatalog

This commit is contained in:
danielqsj 2019-02-26 17:06:18 +08:00
parent 84aeafee7b
commit 9ea1b3d86d
3 changed files with 34 additions and 34 deletions

View File

@ -665,7 +665,6 @@ test/e2e/network
test/e2e/node test/e2e/node
test/e2e/scalability test/e2e/scalability
test/e2e/scheduling test/e2e/scheduling
test/e2e/servicecatalog
test/e2e/storage test/e2e/storage
test/e2e/storage/drivers test/e2e/storage/drivers
test/e2e/storage/testsuites test/e2e/storage/testsuites

View File

@ -18,6 +18,7 @@ package servicecatalog
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-service-catalog] "+text, body) return ginkgo.Describe("[sig-service-catalog] "+text, body)
} }

View File

@ -30,8 +30,8 @@ import (
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" "github.com/onsi/gomega"
imageutils "k8s.io/kubernetes/test/utils/image" imageutils "k8s.io/kubernetes/test/utils/image"
) )
@ -39,7 +39,7 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
f := framework.NewDefaultFramework("podpreset") f := framework.NewDefaultFramework("podpreset")
var podClient *framework.PodClient var podClient *framework.PodClient
BeforeEach(func() { ginkgo.BeforeEach(func() {
// only run on gce for the time being til we find an easier way to update // only run on gce for the time being til we find an easier way to update
// the admission controllers used on the others // the admission controllers used on the others
framework.SkipUnlessProviderIs("gce") framework.SkipUnlessProviderIs("gce")
@ -47,8 +47,8 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
}) })
// Simplest case: all pods succeed promptly // Simplest case: all pods succeed promptly
It("should create a pod preset", func() { ginkgo.It("should create a pod preset", func() {
By("Creating a pod preset") ginkgo.By("Creating a pod preset")
pip := &settings.PodPreset{ pip := &settings.PodPreset{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -77,9 +77,9 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
if errors.IsNotFound(err) { if errors.IsNotFound(err) {
framework.Skipf("podpresets requires k8s.io/api/settings/v1alpha1 to be enabled") framework.Skipf("podpresets requires k8s.io/api/settings/v1alpha1 to be enabled")
} }
Expect(err).NotTo(HaveOccurred()) gomega.Expect(err).NotTo(gomega.HaveOccurred())
By("creating the pod") ginkgo.By("creating the pod")
name := "pod-preset-pod" name := "pod-preset-pod"
value := strconv.Itoa(time.Now().Nanosecond()) value := strconv.Itoa(time.Now().Nanosecond())
pod := &v1.Pod{ pod := &v1.Pod{
@ -102,30 +102,30 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
}, },
} }
By("setting up watch") ginkgo.By("setting up watch")
selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value})) selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
options := metav1.ListOptions{LabelSelector: selector.String()} options := metav1.ListOptions{LabelSelector: selector.String()}
pods, err := podClient.List(options) pods, err := podClient.List(options)
Expect(err).NotTo(HaveOccurred(), "failed to query for pod") gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to query for pod")
Expect(len(pods.Items)).To(Equal(0)) gomega.Expect(len(pods.Items)).To(gomega.Equal(0))
options = metav1.ListOptions{ options = metav1.ListOptions{
LabelSelector: selector.String(), LabelSelector: selector.String(),
ResourceVersion: pods.ListMeta.ResourceVersion, ResourceVersion: pods.ListMeta.ResourceVersion,
} }
w, err := podClient.Watch(options) w, err := podClient.Watch(options)
Expect(err).NotTo(HaveOccurred(), "failed to set up watch") gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to set up watch")
By("submitting the pod to kubernetes") ginkgo.By("submitting the pod to kubernetes")
podClient.Create(pod) podClient.Create(pod)
By("verifying the pod is in kubernetes") ginkgo.By("verifying the pod is in kubernetes")
selector = labels.SelectorFromSet(labels.Set(map[string]string{"time": value})) selector = labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
options = metav1.ListOptions{LabelSelector: selector.String()} options = metav1.ListOptions{LabelSelector: selector.String()}
pods, err = podClient.List(options) pods, err = podClient.List(options)
Expect(err).NotTo(HaveOccurred(), "failed to query for pod") gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to query for pod")
Expect(len(pods.Items)).To(Equal(1)) gomega.Expect(len(pods.Items)).To(gomega.Equal(1))
By("verifying pod creation was observed") ginkgo.By("verifying pod creation was observed")
select { select {
case event, _ := <-w.ResultChan(): case event, _ := <-w.ResultChan():
if event.Type != watch.Added { if event.Type != watch.Added {
@ -139,10 +139,10 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
// may be carried out immediately rather than gracefully. // may be carried out immediately rather than gracefully.
framework.ExpectNoError(f.WaitForPodRunning(pod.Name)) framework.ExpectNoError(f.WaitForPodRunning(pod.Name))
By("ensuring pod is modified") ginkgo.By("ensuring pod is modified")
// save the running pod // save the running pod
pod, err = podClient.Get(pod.Name, metav1.GetOptions{}) pod, err = podClient.Get(pod.Name, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred(), "failed to GET scheduled pod") gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to GET scheduled pod")
// check the annotation is there // check the annotation is there
if _, ok := pod.Annotations["podpreset.admission.kubernetes.io/podpreset-hello"]; !ok { if _, ok := pod.Annotations["podpreset.admission.kubernetes.io/podpreset-hello"]; !ok {
@ -155,8 +155,8 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
} }
}) })
It("should not modify the pod on conflict", func() { ginkgo.It("should not modify the pod on conflict", func() {
By("Creating a pod preset") ginkgo.By("Creating a pod preset")
pip := &settings.PodPreset{ pip := &settings.PodPreset{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -185,9 +185,9 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
if errors.IsNotFound(err) { if errors.IsNotFound(err) {
framework.Skipf("podpresets requires k8s.io/api/settings/v1alpha1 to be enabled") framework.Skipf("podpresets requires k8s.io/api/settings/v1alpha1 to be enabled")
} }
Expect(err).NotTo(HaveOccurred()) gomega.Expect(err).NotTo(gomega.HaveOccurred())
By("creating the pod") ginkgo.By("creating the pod")
name := "pod-preset-pod" name := "pod-preset-pod"
value := strconv.Itoa(time.Now().Nanosecond()) value := strconv.Itoa(time.Now().Nanosecond())
originalPod := &v1.Pod{ originalPod := &v1.Pod{
@ -211,30 +211,30 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
}, },
} }
By("setting up watch") ginkgo.By("setting up watch")
selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value})) selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
options := metav1.ListOptions{LabelSelector: selector.String()} options := metav1.ListOptions{LabelSelector: selector.String()}
pods, err := podClient.List(options) pods, err := podClient.List(options)
Expect(err).NotTo(HaveOccurred(), "failed to query for pod") gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to query for pod")
Expect(len(pods.Items)).To(Equal(0)) gomega.Expect(len(pods.Items)).To(gomega.Equal(0))
options = metav1.ListOptions{ options = metav1.ListOptions{
LabelSelector: selector.String(), LabelSelector: selector.String(),
ResourceVersion: pods.ListMeta.ResourceVersion, ResourceVersion: pods.ListMeta.ResourceVersion,
} }
w, err := podClient.Watch(options) w, err := podClient.Watch(options)
Expect(err).NotTo(HaveOccurred(), "failed to set up watch") gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to set up watch")
By("submitting the pod to kubernetes") ginkgo.By("submitting the pod to kubernetes")
podClient.Create(originalPod) podClient.Create(originalPod)
By("verifying the pod is in kubernetes") ginkgo.By("verifying the pod is in kubernetes")
selector = labels.SelectorFromSet(labels.Set(map[string]string{"time": value})) selector = labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
options = metav1.ListOptions{LabelSelector: selector.String()} options = metav1.ListOptions{LabelSelector: selector.String()}
pods, err = podClient.List(options) pods, err = podClient.List(options)
Expect(err).NotTo(HaveOccurred(), "failed to query for pod") gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to query for pod")
Expect(len(pods.Items)).To(Equal(1)) gomega.Expect(len(pods.Items)).To(gomega.Equal(1))
By("verifying pod creation was observed") ginkgo.By("verifying pod creation was observed")
select { select {
case event, _ := <-w.ResultChan(): case event, _ := <-w.ResultChan():
if event.Type != watch.Added { if event.Type != watch.Added {
@ -248,10 +248,10 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
// may be carried out immediately rather than gracefully. // may be carried out immediately rather than gracefully.
framework.ExpectNoError(f.WaitForPodRunning(originalPod.Name)) framework.ExpectNoError(f.WaitForPodRunning(originalPod.Name))
By("ensuring pod is modified") ginkgo.By("ensuring pod is modified")
// save the running pod // save the running pod
pod, err := podClient.Get(originalPod.Name, metav1.GetOptions{}) pod, err := podClient.Get(originalPod.Name, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred(), "failed to GET scheduled pod") gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to GET scheduled pod")
// check the annotation is not there // check the annotation is not there
if _, ok := pod.Annotations["podpreset.admission.kubernetes.io/podpreset-hello"]; ok { if _, ok := pod.Annotations["podpreset.admission.kubernetes.io/podpreset-hello"]; ok {