Change Fail(fmt.Sprintf(...)) to Failf(...)

pull/6/head
Max Forbes 2015-07-23 16:03:34 -07:00
parent a4112ded7b
commit e704004a53
1 changed files with 25 additions and 25 deletions

View File

@ -77,8 +77,8 @@ func runLivenessTest(c *client.Client, ns string, podDescr *api.Pod, expectResta
} }
if restarts != expectRestart { if restarts != expectRestart {
Fail(fmt.Sprintf("pod %s/%s - expected restarts: %t, found restarts: %t", Failf("pod %s/%s - expected restarts: %t, found restarts: %t",
ns, podDescr.Name, expectRestart, restarts)) ns, podDescr.Name, expectRestart, restarts)
} }
} }
@ -89,7 +89,7 @@ func testHostIP(c *client.Client, ns string, pod *api.Pod) {
defer podClient.Delete(pod.Name, nil) defer podClient.Delete(pod.Name, nil)
_, err := podClient.Create(pod) _, err := podClient.Create(pod)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to create pod: %v", err)) Failf("Failed to create pod: %v", err)
} }
By("ensuring that pod is running and has a hostIP") By("ensuring that pod is running and has a hostIP")
// Wait for the pods to enter the running state. Waiting loops until the pods // Wait for the pods to enter the running state. Waiting loops until the pods
@ -167,7 +167,7 @@ var _ = Describe("Pods", func() {
defer podClient.Delete(pod.Name, nil) defer podClient.Delete(pod.Name, nil)
_, err := podClient.Create(pod) _, err := podClient.Create(pod)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Error creating a pod: %v", err)) Failf("Error creating a pod: %v", err)
} }
expectNoError(framework.WaitForPodRunning(pod.Name)) expectNoError(framework.WaitForPodRunning(pod.Name))
}) })
@ -209,13 +209,13 @@ var _ = Describe("Pods", func() {
By("setting up watch") By("setting up watch")
pods, err := podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), fields.Everything()) pods, err := podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), fields.Everything())
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to query for pods: %v", err)) Failf("Failed to query for pods: %v", err)
} }
Expect(len(pods.Items)).To(Equal(0)) Expect(len(pods.Items)).To(Equal(0))
w, err := podClient.Watch( w, err := podClient.Watch(
labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), fields.Everything(), pods.ListMeta.ResourceVersion) labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), fields.Everything(), pods.ListMeta.ResourceVersion)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to set up watch: %v", err)) Failf("Failed to set up watch: %v", err)
} }
By("submitting the pod to kubernetes") By("submitting the pod to kubernetes")
@ -225,13 +225,13 @@ var _ = Describe("Pods", func() {
defer podClient.Delete(pod.Name, nil) defer podClient.Delete(pod.Name, nil)
_, err = podClient.Create(pod) _, err = podClient.Create(pod)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to create pod: %v", err)) Failf("Failed to create pod: %v", err)
} }
By("verifying the pod is in kubernetes") By("verifying the pod is in kubernetes")
pods, err = podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), fields.Everything()) pods, err = podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), fields.Everything())
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to query for pods: %v", err)) Failf("Failed to query for pods: %v", err)
} }
Expect(len(pods.Items)).To(Equal(1)) Expect(len(pods.Items)).To(Equal(1))
@ -239,7 +239,7 @@ var _ = Describe("Pods", func() {
select { select {
case event, _ := <-w.ResultChan(): case event, _ := <-w.ResultChan():
if event.Type != watch.Added { if event.Type != watch.Added {
Fail(fmt.Sprintf("Failed to observe pod creation: %v", event)) Failf("Failed to observe pod creation: %v", event)
} }
case <-time.After(podStartTimeout): case <-time.After(podStartTimeout):
Fail("Timeout while waiting for pod creation") Fail("Timeout while waiting for pod creation")
@ -249,7 +249,7 @@ var _ = Describe("Pods", func() {
podClient.Delete(pod.Name, nil) podClient.Delete(pod.Name, nil)
pods, err = podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), fields.Everything()) pods, err = podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value})), fields.Everything())
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to delete pod: %v", err)) Failf("Failed to delete pod: %v", err)
} }
Expect(len(pods.Items)).To(Equal(0)) Expect(len(pods.Items)).To(Equal(0))
@ -376,7 +376,7 @@ var _ = Describe("Pods", func() {
defer framework.Client.Pods(framework.Namespace.Name).Delete(serverPod.Name, nil) defer framework.Client.Pods(framework.Namespace.Name).Delete(serverPod.Name, nil)
_, err := framework.Client.Pods(framework.Namespace.Name).Create(serverPod) _, err := framework.Client.Pods(framework.Namespace.Name).Create(serverPod)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to create serverPod: %v", err)) Failf("Failed to create serverPod: %v", err)
} }
expectNoError(framework.WaitForPodRunning(serverPod.Name)) expectNoError(framework.WaitForPodRunning(serverPod.Name))
@ -408,7 +408,7 @@ var _ = Describe("Pods", func() {
defer framework.Client.Services(framework.Namespace.Name).Delete(svc.Name) defer framework.Client.Services(framework.Namespace.Name).Delete(svc.Name)
_, err = framework.Client.Services(framework.Namespace.Name).Create(svc) _, err = framework.Client.Services(framework.Namespace.Name).Create(svc)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to create service: %v", err)) Failf("Failed to create service: %v", err)
} }
// Make a client pod that verifies that it has the service environment variables. // Make a client pod that verifies that it has the service environment variables.
@ -529,7 +529,7 @@ var _ = Describe("Pods", func() {
It("should support remote command execution", func() { It("should support remote command execution", func() {
clientConfig, err := loadConfig() clientConfig, err := loadConfig()
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to create client config: %v", err)) Failf("Failed to create client config: %v", err)
} }
podClient := framework.Client.Pods(framework.Namespace.Name) podClient := framework.Client.Pods(framework.Namespace.Name)
@ -558,7 +558,7 @@ var _ = Describe("Pods", func() {
By("submitting the pod to kubernetes") By("submitting the pod to kubernetes")
_, err = podClient.Create(pod) _, err = podClient.Create(pod)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to create pod: %v", err)) Failf("Failed to create pod: %v", err)
} }
defer func() { defer func() {
// We call defer here in case there is a problem with // We call defer here in case there is a problem with
@ -573,7 +573,7 @@ var _ = Describe("Pods", func() {
By("verifying the pod is in kubernetes") By("verifying the pod is in kubernetes")
pods, err := podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))) pods, err := podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value})))
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to query for pods: %v", err)) Failf("Failed to query for pods: %v", err)
} }
Expect(len(pods.Items)).To(Equal(1)) Expect(len(pods.Items)).To(Equal(1))
@ -590,18 +590,18 @@ var _ = Describe("Pods", func() {
e := remotecommand.New(req, clientConfig, []string{"whoami"}, nil, out, nil, false) e := remotecommand.New(req, clientConfig, []string{"whoami"}, nil, out, nil, false)
err = e.Execute() err = e.Execute()
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to execute command on host %s pod %s in container %s: %v", Failf("Failed to execute command on host %s pod %s in container %s: %v",
pod.Status.Host, pod.Name, pod.Spec.Containers[0].Name, err)) pod.Status.Host, pod.Name, pod.Spec.Containers[0].Name, err)
} }
if e, a := "root\n", out.String(); e != a { if e, a := "root\n", out.String(); e != a {
Fail(fmt.Sprintf("exec: whoami: expected '%s', got '%s'", e, a)) Failf("exec: whoami: expected '%s', got '%s'", e, a)
} }
}) })
It("should support port forwarding", func() { It("should support port forwarding", func() {
clientConfig, err := loadConfig() clientConfig, err := loadConfig()
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to create client config: %v", err)) Failf("Failed to create client config: %v", err)
} }
podClient := framework.Client.Pods(framework.Namespace.Name) podClient := framework.Client.Pods(framework.Namespace.Name)
@ -631,7 +631,7 @@ var _ = Describe("Pods", func() {
By("submitting the pod to kubernetes") By("submitting the pod to kubernetes")
_, err = podClient.Create(pod) _, err = podClient.Create(pod)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to create pod: %v", err)) Failf("Failed to create pod: %v", err)
} }
defer func() { defer func() {
// We call defer here in case there is a problem with // We call defer here in case there is a problem with
@ -646,7 +646,7 @@ var _ = Describe("Pods", func() {
By("verifying the pod is in kubernetes") By("verifying the pod is in kubernetes")
pods, err := podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))) pods, err := podClient.List(labels.SelectorFromSet(labels.Set(map[string]string{"time": value})))
if err != nil { if err != nil {
Fail(fmt.Sprintf("Failed to query for pods: %v", err)) Failf("Failed to query for pods: %v", err)
} }
Expect(len(pods.Items)).To(Equal(1)) Expect(len(pods.Items)).To(Equal(1))
@ -663,7 +663,7 @@ var _ = Describe("Pods", func() {
stopChan := make(chan struct{}) stopChan := make(chan struct{})
pf, err := portforward.New(req, clientConfig, []string{"5678:80"}, stopChan) pf, err := portforward.New(req, clientConfig, []string{"5678:80"}, stopChan)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Error creating port forwarder: %s", err)) Failf("Error creating port forwarder: %s", err)
} }
errorChan := make(chan error) errorChan := make(chan error)
@ -676,11 +676,11 @@ var _ = Describe("Pods", func() {
resp, err := http.Get("http://localhost:5678/") resp, err := http.Get("http://localhost:5678/")
if err != nil { if err != nil {
Fail(fmt.Sprintf("Error with http get to localhost:5678: %s", err)) Failf("Error with http get to localhost:5678: %s", err)
} }
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
Fail(fmt.Sprintf("Error reading response body: %s", err)) Failf("Error reading response body: %s", err)
} }
titleRegex := regexp.MustCompile("<title>(.+)</title>") titleRegex := regexp.MustCompile("<title>(.+)</title>")
@ -689,7 +689,7 @@ var _ = Describe("Pods", func() {
Fail("Unable to locate page title in response HTML") Fail("Unable to locate page title in response HTML")
} }
if e, a := "Welcome to nginx on Debian!", matches[1]; e != a { if e, a := "Welcome to nginx on Debian!", matches[1]; e != a {
Fail(fmt.Sprintf("<title>: expected '%s', got '%s'", e, a)) Failf("<title>: expected '%s', got '%s'", e, a)
} }
}) })
*/ */