Skip to content

Commit

Permalink
Merge pull request kubernetes#6204 from pmorie/secrets-e2e
Browse files Browse the repository at this point in the history
Fix log retrieval in secrets e2e
  • Loading branch information
vmarmol committed Mar 31, 2015
2 parents 5112825 + f0a49c3 commit 95c8e79
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions test/e2e/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ var _ = Describe("Secrets", func() {
}

By(fmt.Sprintf("Creating a pod to consume secret %v", secret.Name))
// Make a client pod that verifies that it has the service environment variables.
clientName := "client-secrets-" + string(util.NewUUID())
clientPod := &api.Pod{
// Make a pod that verifies that it has the service environment variables.
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: clientName,
Name: "pod-secrets-" + string(util.NewUUID()),
},
Spec: api.PodSpec{
Volumes: []api.Volume{
Expand All @@ -90,7 +89,7 @@ var _ = Describe("Secrets", func() {
{
Name: "catcont",
Image: "busybox",
Command: []string{"sh", "-c", "cat /etc/secret-volume/data-1; sleep 600"},
Command: []string{"sh", "-c", "cat /etc/secret-volume/data-1"},
VolumeMounts: []api.VolumeMount{
{
Name: volumeName,
Expand All @@ -104,20 +103,20 @@ var _ = Describe("Secrets", func() {
},
}

defer c.Pods(ns).Delete(clientPod.Name)
if _, err := c.Pods(ns).Create(clientPod); err != nil {
defer c.Pods(ns).Delete(pod.Name)
if _, err := c.Pods(ns).Create(pod); err != nil {
Failf("Failed to create pod: %v", err)
}
// Wait for client pod to complete.
expectNoError(waitForPodRunning(c, clientPod.Name))
expectNoError(waitForPodSuccess(c, pod.Name, "catcont"))

// Grab its logs. Get host first.
clientPodStatus, err := c.Pods(ns).Get(clientPod.Name)
podStatus, err := c.Pods(ns).Get(pod.Name)
if err != nil {
Failf("Failed to get clientPod to know host: %v", err)
Failf("Failed to get pod to know host: %v", err)
}
By(fmt.Sprintf("Trying to get logs from host %s pod %s container %s: %v",
clientPodStatus.Status.Host, clientPodStatus.Name, clientPodStatus.Spec.Containers[0].Name, err))
podStatus.Status.Host, podStatus.Name, podStatus.Spec.Containers[0].Name, err))
var logs []byte
start := time.Now()

Expand All @@ -126,15 +125,15 @@ var _ = Describe("Secrets", func() {
logs, err = c.Get().
Prefix("proxy").
Resource("minions").
Name(clientPodStatus.Status.Host).
Suffix("containerLogs", ns, clientPodStatus.Name, clientPodStatus.Spec.Containers[0].Name).
Name(podStatus.Status.Host).
Suffix("containerLogs", ns, podStatus.Name, podStatus.Spec.Containers[0].Name).
Do().
Raw()
fmt.Sprintf("clientPod logs:%v\n", string(logs))
By(fmt.Sprintf("clientPod logs:%v\n", string(logs)))
fmt.Sprintf("pod logs:%v\n", string(logs))
By(fmt.Sprintf("pod 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, string(logs)))
podStatus.Status.Host, podStatus.Name, podStatus.Spec.Containers[0].Name, string(logs)))
time.Sleep(5 * time.Second)
continue
}
Expand Down

0 comments on commit 95c8e79

Please sign in to comment.