Merge pull request #74586 from danielqsj/patch3

fix golint failures for test/e2e/cloud|kubectl|servicecatalog
pull/564/head
Kubernetes Prow Robot 2019-02-26 14:08:16 -08:00 committed by GitHub
commit 493b261057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 385 additions and 385 deletions

View File

@ -650,7 +650,6 @@ test/e2e/apps
test/e2e/auth test/e2e/auth
test/e2e/autoscaling test/e2e/autoscaling
test/e2e/chaosmonkey test/e2e/chaosmonkey
test/e2e/cloud
test/e2e/common test/e2e/common
test/e2e/framework test/e2e/framework
test/e2e/framework/providers/gce test/e2e/framework/providers/gce
@ -658,14 +657,12 @@ test/e2e/framework/providers/kubemark
test/e2e/instrumentation test/e2e/instrumentation
test/e2e/instrumentation/logging test/e2e/instrumentation/logging
test/e2e/instrumentation/monitoring test/e2e/instrumentation/monitoring
test/e2e/kubectl
test/e2e/lifecycle test/e2e/lifecycle
test/e2e/lifecycle/bootstrap test/e2e/lifecycle/bootstrap
test/e2e/network 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 cloud
import "k8s.io/kubernetes/test/e2e/framework" import "k8s.io/kubernetes/test/e2e/framework"
// SIGDescribe annotates the test with the SIG label.
func SIGDescribe(text string, body func()) bool { func SIGDescribe(text string, body func()) bool {
return framework.KubeDescribe("[sig-cloud-provider] "+text, body) return framework.KubeDescribe("[sig-cloud-provider] "+text, body)
} }

View File

@ -24,23 +24,23 @@ 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"
) )
var _ = SIGDescribe("[Feature:CloudProvider][Disruptive] Nodes", func() { var _ = SIGDescribe("[Feature:CloudProvider][Disruptive] Nodes", func() {
f := framework.NewDefaultFramework("cloudprovider") f := framework.NewDefaultFramework("cloudprovider")
var c clientset.Interface var c clientset.Interface
BeforeEach(func() { ginkgo.BeforeEach(func() {
// Only supported in AWS/GCE because those are the only cloud providers // Only supported in AWS/GCE because those are the only cloud providers
// where E2E test are currently running. // where E2E test are currently running.
framework.SkipUnlessProviderIs("aws", "gce", "gke") framework.SkipUnlessProviderIs("aws", "gce", "gke")
c = f.ClientSet c = f.ClientSet
}) })
It("should be deleted on API server if it doesn't exist in the cloud provider", func() { ginkgo.It("should be deleted on API server if it doesn't exist in the cloud provider", func() {
By("deleting a node on the cloud provider") ginkgo.By("deleting a node on the cloud provider")
nodeDeleteCandidates := framework.GetReadySchedulableNodesOrDie(c) nodeDeleteCandidates := framework.GetReadySchedulableNodesOrDie(c)
nodeToDelete := nodeDeleteCandidates.Items[0] nodeToDelete := nodeDeleteCandidates.Items[0]
@ -54,8 +54,8 @@ var _ = SIGDescribe("[Feature:CloudProvider][Disruptive] Nodes", func() {
} }
newNodes, err := framework.CheckNodesReady(c, len(origNodes.Items)-1, 5*time.Minute) newNodes, err := framework.CheckNodesReady(c, len(origNodes.Items)-1, 5*time.Minute)
Expect(err).To(BeNil()) gomega.Expect(err).To(gomega.BeNil())
Expect(len(newNodes)).To(Equal(len(origNodes.Items) - 1)) gomega.Expect(len(newNodes)).To(gomega.Equal(len(origNodes.Items) - 1))
_, err = c.CoreV1().Nodes().Get(nodeToDelete.Name, metav1.GetOptions{}) _, err = c.CoreV1().Nodes().Get(nodeToDelete.Name, metav1.GetOptions{})
if err == nil { if err == nil {

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,8 @@ import (
testutils "k8s.io/kubernetes/test/utils" testutils "k8s.io/kubernetes/test/utils"
imageutils "k8s.io/kubernetes/test/utils/image" imageutils "k8s.io/kubernetes/test/utils/image"
. "github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" "github.com/onsi/gomega"
) )
const ( const (
@ -116,6 +116,7 @@ func pfPod(expectedClientData, chunks, chunkSize, chunkIntervalMillis string, bi
} }
} }
// WaitForTerminatedContainer wait till a given container be terminated for a given pod.
func WaitForTerminatedContainer(f *framework.Framework, pod *v1.Pod, containerName string) error { func WaitForTerminatedContainer(f *framework.Framework, pod *v1.Pod, containerName string) error {
return framework.WaitForPodCondition(f.ClientSet, f.Namespace.Name, pod.Name, "container terminated", framework.PodStartTimeout, func(pod *v1.Pod) (bool, error) { return framework.WaitForPodCondition(f.ClientSet, f.Namespace.Name, pod.Name, "container terminated", framework.PodStartTimeout, func(pod *v1.Pod) (bool, error) {
if len(testutils.TerminatedContainers(pod)[containerName]) > 0 { if len(testutils.TerminatedContainers(pod)[containerName]) > 0 {
@ -199,7 +200,7 @@ func runPortForward(ns, podName string, port int) *portForwardCommand {
} }
func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) { func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
By("Creating the target pod") ginkgo.By("Creating the target pod")
pod := pfPod("", "10", "10", "100", fmt.Sprintf("%s", bindAddress)) pod := pfPod("", "10", "10", "100", fmt.Sprintf("%s", bindAddress))
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil { if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
framework.Failf("Couldn't create pod: %v", err) framework.Failf("Couldn't create pod: %v", err)
@ -208,21 +209,21 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
framework.Failf("Pod did not start running: %v", err) framework.Failf("Pod did not start running: %v", err)
} }
By("Running 'kubectl port-forward'") ginkgo.By("Running 'kubectl port-forward'")
cmd := runPortForward(f.Namespace.Name, pod.Name, 80) cmd := runPortForward(f.Namespace.Name, pod.Name, 80)
defer cmd.Stop() defer cmd.Stop()
By("Dialing the local port") ginkgo.By("Dialing the local port")
conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port)) conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port))
if err != nil { if err != nil {
framework.Failf("Couldn't connect to port %d: %v", cmd.port, err) framework.Failf("Couldn't connect to port %d: %v", cmd.port, err)
} }
defer func() { defer func() {
By("Closing the connection to the local port") ginkgo.By("Closing the connection to the local port")
conn.Close() conn.Close()
}() }()
By("Reading data from the local port") ginkgo.By("Reading data from the local port")
fromServer, err := ioutil.ReadAll(conn) fromServer, err := ioutil.ReadAll(conn)
if err != nil { if err != nil {
framework.Failf("Unexpected error reading data from the server: %v", err) framework.Failf("Unexpected error reading data from the server: %v", err)
@ -232,22 +233,22 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
framework.Failf("Expected %q from server, got %q", e, a) framework.Failf("Expected %q from server, got %q", e, a)
} }
By("Waiting for the target pod to stop running") ginkgo.By("Waiting for the target pod to stop running")
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil { if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
framework.Failf("Container did not terminate: %v", err) framework.Failf("Container did not terminate: %v", err)
} }
By("Verifying logs") ginkgo.By("Verifying logs")
Eventually(func() (string, error) { gomega.Eventually(func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester") return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester")
}, postStartWaitTimeout, podCheckInterval).Should(SatisfyAll( }, postStartWaitTimeout, podCheckInterval).Should(gomega.SatisfyAll(
ContainSubstring("Accepted client connection"), gomega.ContainSubstring("Accepted client connection"),
ContainSubstring("Done"), gomega.ContainSubstring("Done"),
)) ))
} }
func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) { func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
By("Creating the target pod") ginkgo.By("Creating the target pod")
pod := pfPod("abc", "1", "1", "1", fmt.Sprintf("%s", bindAddress)) pod := pfPod("abc", "1", "1", "1", fmt.Sprintf("%s", bindAddress))
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil { if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
framework.Failf("Couldn't create pod: %v", err) framework.Failf("Couldn't create pod: %v", err)
@ -256,35 +257,35 @@ func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
framework.Failf("Pod did not start running: %v", err) framework.Failf("Pod did not start running: %v", err)
} }
By("Running 'kubectl port-forward'") ginkgo.By("Running 'kubectl port-forward'")
cmd := runPortForward(f.Namespace.Name, pod.Name, 80) cmd := runPortForward(f.Namespace.Name, pod.Name, 80)
defer cmd.Stop() defer cmd.Stop()
By("Dialing the local port") ginkgo.By("Dialing the local port")
conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port)) conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port))
if err != nil { if err != nil {
framework.Failf("Couldn't connect to port %d: %v", cmd.port, err) framework.Failf("Couldn't connect to port %d: %v", cmd.port, err)
} }
By("Closing the connection to the local port") ginkgo.By("Closing the connection to the local port")
conn.Close() conn.Close()
By("Waiting for the target pod to stop running") ginkgo.By("Waiting for the target pod to stop running")
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil { if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
framework.Failf("Container did not terminate: %v", err) framework.Failf("Container did not terminate: %v", err)
} }
By("Verifying logs") ginkgo.By("Verifying logs")
Eventually(func() (string, error) { gomega.Eventually(func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester") return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester")
}, postStartWaitTimeout, podCheckInterval).Should(SatisfyAll( }, postStartWaitTimeout, podCheckInterval).Should(gomega.SatisfyAll(
ContainSubstring("Accepted client connection"), gomega.ContainSubstring("Accepted client connection"),
ContainSubstring("Expected to read 3 bytes from client, but got 0 instead"), gomega.ContainSubstring("Expected to read 3 bytes from client, but got 0 instead"),
)) ))
} }
func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework) { func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework) {
By("Creating the target pod") ginkgo.By("Creating the target pod")
pod := pfPod("abc", "10", "10", "100", fmt.Sprintf("%s", bindAddress)) pod := pfPod("abc", "10", "10", "100", fmt.Sprintf("%s", bindAddress))
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil { if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
framework.Failf("Couldn't create pod: %v", err) framework.Failf("Couldn't create pod: %v", err)
@ -293,11 +294,11 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
framework.Failf("Pod did not start running: %v", err) framework.Failf("Pod did not start running: %v", err)
} }
By("Running 'kubectl port-forward'") ginkgo.By("Running 'kubectl port-forward'")
cmd := runPortForward(f.Namespace.Name, pod.Name, 80) cmd := runPortForward(f.Namespace.Name, pod.Name, 80)
defer cmd.Stop() defer cmd.Stop()
By("Dialing the local port") ginkgo.By("Dialing the local port")
addr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port)) addr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port))
if err != nil { if err != nil {
framework.Failf("Error resolving tcp addr: %v", err) framework.Failf("Error resolving tcp addr: %v", err)
@ -307,17 +308,17 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
framework.Failf("Couldn't connect to port %d: %v", cmd.port, err) framework.Failf("Couldn't connect to port %d: %v", cmd.port, err)
} }
defer func() { defer func() {
By("Closing the connection to the local port") ginkgo.By("Closing the connection to the local port")
conn.Close() conn.Close()
}() }()
By("Sending the expected data to the local port") ginkgo.By("Sending the expected data to the local port")
fmt.Fprint(conn, "abc") fmt.Fprint(conn, "abc")
By("Closing the write half of the client's connection") ginkgo.By("Closing the write half of the client's connection")
conn.CloseWrite() conn.CloseWrite()
By("Reading data from the local port") ginkgo.By("Reading data from the local port")
fromServer, err := ioutil.ReadAll(conn) fromServer, err := ioutil.ReadAll(conn)
if err != nil { if err != nil {
framework.Failf("Unexpected error reading data from the server: %v", err) framework.Failf("Unexpected error reading data from the server: %v", err)
@ -327,26 +328,26 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
framework.Failf("Expected %q from server, got %q", e, a) framework.Failf("Expected %q from server, got %q", e, a)
} }
By("Waiting for the target pod to stop running") ginkgo.By("Waiting for the target pod to stop running")
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil { if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
framework.Failf("Container did not terminate: %v", err) framework.Failf("Container did not terminate: %v", err)
} }
By("Verifying logs") ginkgo.By("Verifying logs")
Eventually(func() (string, error) { gomega.Eventually(func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester") return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester")
}, postStartWaitTimeout, podCheckInterval).Should(SatisfyAll( }, postStartWaitTimeout, podCheckInterval).Should(gomega.SatisfyAll(
ContainSubstring("Accepted client connection"), gomega.ContainSubstring("Accepted client connection"),
ContainSubstring("Received expected client data"), gomega.ContainSubstring("Received expected client data"),
ContainSubstring("Done"), gomega.ContainSubstring("Done"),
)) ))
} }
func doTestOverWebSockets(bindAddress string, f *framework.Framework) { func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
config, err := framework.LoadConfig() config, err := framework.LoadConfig()
Expect(err).NotTo(HaveOccurred(), "unable to get base config") gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unable to get base config")
By("Creating the pod") ginkgo.By("Creating the pod")
pod := pfPod("def", "10", "10", "100", fmt.Sprintf("%s", bindAddress)) pod := pfPod("def", "10", "10", "100", fmt.Sprintf("%s", bindAddress))
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil { if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
framework.Failf("Couldn't create pod: %v", err) framework.Failf("Couldn't create pod: %v", err)
@ -369,7 +370,7 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
} }
defer ws.Close() defer ws.Close()
Eventually(func() error { gomega.Eventually(func() error {
channel, msg, err := wsRead(ws) channel, msg, err := wsRead(ws)
if err != nil { if err != nil {
return fmt.Errorf("Failed to read completely from websocket %s: %v", url.String(), err) return fmt.Errorf("Failed to read completely from websocket %s: %v", url.String(), err)
@ -381,9 +382,9 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
return fmt.Errorf("Received the wrong port: %d", p) return fmt.Errorf("Received the wrong port: %d", p)
} }
return nil return nil
}, time.Minute, 10*time.Second).Should(BeNil()) }, time.Minute, 10*time.Second).Should(gomega.BeNil())
Eventually(func() error { gomega.Eventually(func() error {
channel, msg, err := wsRead(ws) channel, msg, err := wsRead(ws)
if err != nil { if err != nil {
return fmt.Errorf("Failed to read completely from websocket %s: %v", url.String(), err) return fmt.Errorf("Failed to read completely from websocket %s: %v", url.String(), err)
@ -395,18 +396,18 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
return fmt.Errorf("Received the wrong port: %d", p) return fmt.Errorf("Received the wrong port: %d", p)
} }
return nil return nil
}, time.Minute, 10*time.Second).Should(BeNil()) }, time.Minute, 10*time.Second).Should(gomega.BeNil())
By("Sending the expected data to the local port") ginkgo.By("Sending the expected data to the local port")
err = wsWrite(ws, 0, []byte("def")) err = wsWrite(ws, 0, []byte("def"))
if err != nil { if err != nil {
framework.Failf("Failed to write to websocket %s: %v", url.String(), err) framework.Failf("Failed to write to websocket %s: %v", url.String(), err)
} }
By("Reading data from the local port") ginkgo.By("Reading data from the local port")
buf := bytes.Buffer{} buf := bytes.Buffer{}
expectedData := bytes.Repeat([]byte("x"), 100) expectedData := bytes.Repeat([]byte("x"), 100)
Eventually(func() error { gomega.Eventually(func() error {
channel, msg, err := wsRead(ws) channel, msg, err := wsRead(ws)
if err != nil { if err != nil {
return fmt.Errorf("Failed to read completely from websocket %s: %v", url.String(), err) return fmt.Errorf("Failed to read completely from websocket %s: %v", url.String(), err)
@ -419,14 +420,14 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
return fmt.Errorf("Expected %q from server, got %q", expectedData, buf.Bytes()) return fmt.Errorf("Expected %q from server, got %q", expectedData, buf.Bytes())
} }
return nil return nil
}, time.Minute, 10*time.Second).Should(BeNil()) }, time.Minute, 10*time.Second).Should(gomega.BeNil())
By("Verifying logs") ginkgo.By("Verifying logs")
Eventually(func() (string, error) { gomega.Eventually(func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester") return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester")
}, postStartWaitTimeout, podCheckInterval).Should(SatisfyAll( }, postStartWaitTimeout, podCheckInterval).Should(gomega.SatisfyAll(
ContainSubstring("Accepted client connection"), gomega.ContainSubstring("Accepted client connection"),
ContainSubstring("Received expected client data"), gomega.ContainSubstring("Received expected client data"),
)) ))
} }
@ -435,21 +436,21 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
framework.KubeDescribe("With a server listening on 0.0.0.0", func() { framework.KubeDescribe("With a server listening on 0.0.0.0", func() {
framework.KubeDescribe("that expects a client request", func() { framework.KubeDescribe("that expects a client request", func() {
It("should support a client that connects, sends NO DATA, and disconnects", func() { ginkgo.It("should support a client that connects, sends NO DATA, and disconnects", func() {
doTestMustConnectSendNothing("0.0.0.0", f) doTestMustConnectSendNothing("0.0.0.0", f)
}) })
It("should support a client that connects, sends DATA, and disconnects", func() { ginkgo.It("should support a client that connects, sends DATA, and disconnects", func() {
doTestMustConnectSendDisconnect("0.0.0.0", f) doTestMustConnectSendDisconnect("0.0.0.0", f)
}) })
}) })
framework.KubeDescribe("that expects NO client request", func() { framework.KubeDescribe("that expects NO client request", func() {
It("should support a client that connects, sends DATA, and disconnects", func() { ginkgo.It("should support a client that connects, sends DATA, and disconnects", func() {
doTestConnectSendDisconnect("0.0.0.0", f) doTestConnectSendDisconnect("0.0.0.0", f)
}) })
}) })
It("should support forwarding over websockets", func() { ginkgo.It("should support forwarding over websockets", func() {
doTestOverWebSockets("0.0.0.0", f) doTestOverWebSockets("0.0.0.0", f)
}) })
}) })
@ -457,21 +458,21 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
// kubectl port-forward may need elevated privileges to do its job. // kubectl port-forward may need elevated privileges to do its job.
framework.KubeDescribe("With a server listening on localhost", func() { framework.KubeDescribe("With a server listening on localhost", func() {
framework.KubeDescribe("that expects a client request", func() { framework.KubeDescribe("that expects a client request", func() {
It("should support a client that connects, sends NO DATA, and disconnects", func() { ginkgo.It("should support a client that connects, sends NO DATA, and disconnects", func() {
doTestMustConnectSendNothing("localhost", f) doTestMustConnectSendNothing("localhost", f)
}) })
It("should support a client that connects, sends DATA, and disconnects", func() { ginkgo.It("should support a client that connects, sends DATA, and disconnects", func() {
doTestMustConnectSendDisconnect("localhost", f) doTestMustConnectSendDisconnect("localhost", f)
}) })
}) })
framework.KubeDescribe("that expects NO client request", func() { framework.KubeDescribe("that expects NO client request", func() {
It("should support a client that connects, sends DATA, and disconnects", func() { ginkgo.It("should support a client that connects, sends DATA, and disconnects", func() {
doTestConnectSendDisconnect("localhost", f) doTestConnectSendDisconnect("localhost", f)
}) })
}) })
It("should support forwarding over websockets", func() { ginkgo.It("should support forwarding over websockets", func() {
doTestOverWebSockets("localhost", f) doTestOverWebSockets("localhost", f)
}) })
}) })

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 {