Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deflake "Pods should contain environment variables for services" e2e test #4445

Merged
merged 1 commit into from
Feb 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions test/e2e/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package e2e
import (
"fmt"
"strconv"
"strings"
"time"

"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
Expand Down Expand Up @@ -274,7 +275,6 @@ var _ = Describe("Pods", func() {
},
},
}
time.Sleep(2)
_, err = c.Services(api.NamespaceDefault).Create(svc)
if err != nil {
Fail(fmt.Sprintf("Failed to create service: %v", err))
Expand All @@ -297,7 +297,7 @@ var _ = Describe("Pods", func() {
{
Name: "env3cont",
Image: "busybox",
Command: []string{"sh", "-c", "env"},
Command: []string{"sh", "-c", "env; sleep 600"},
},
},
RestartPolicy: api.RestartPolicy{
Expand All @@ -314,7 +314,7 @@ var _ = Describe("Pods", func() {
}()

// Wait for client pod to complete.
expectNoError(waitForPodSuccess(c, clientPod.Name, clientPod.Spec.Containers[0].Name, 60*time.Second))
expectNoError(waitForPodRunning(c, clientPod.Name, 60*time.Second))

// Grab its logs. Get host first.
clientPodStatus, err := c.Pods(api.NamespaceDefault).Get(clientPod.Name)
Expand All @@ -325,6 +325,7 @@ var _ = Describe("Pods", func() {
clientPodStatus.Status.Host, clientPodStatus.Name, clientPodStatus.Spec.Containers[0].Name, err))
var logs []byte
start := time.Now()

// Sometimes the actual containers take a second to get started, try to get logs for 60s
for time.Now().Sub(start) < (60 * time.Second) {
logs, err = c.Get().
Expand All @@ -334,15 +335,16 @@ var _ = Describe("Pods", func() {
Suffix("containerLogs", api.NamespaceDefault, clientPodStatus.Name, clientPodStatus.Spec.Containers[0].Name).
Do().
Raw()
if err != nil {
fmt.Sprintf("clientPod logs:%v\n", string(logs))
By(fmt.Sprintf("clientPod logs:%v\n", string(logs)))
if strings.Contains(string(logs), "Internal Error") {
By(fmt.Sprintf("Failed to get logs from host %s pod %s container %s: %v",
clientPodStatus.Status.Host, clientPodStatus.Name, clientPodStatus.Spec.Containers[0].Name, err))
clientPodStatus.Status.Host, clientPodStatus.Name, clientPodStatus.Spec.Containers[0].Name, string(logs)))
time.Sleep(5 * time.Second)
continue
}
break
}
fmt.Sprintf("clientPod logs:%v\n", string(logs))

toFind := []string{
"FOOSERVICE_SERVICE_HOST=",
Expand Down