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

Flake 26210: verbosely print StatusError in proxy e2e test #26422

Merged
merged 1 commit into from
May 27, 2016
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
15 changes: 10 additions & 5 deletions test/e2e/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/testapi"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/util/intstr"
Expand Down Expand Up @@ -209,12 +210,12 @@ func proxyContext(version string) {
}

wg := sync.WaitGroup{}
errors := []string{}
errs := []string{}
errLock := sync.Mutex{}
recordError := func(s string) {
errLock.Lock()
defer errLock.Unlock()
errors = append(errors, s)
errs = append(errs, s)
}
for i := 0; i < proxyAttempts; i++ {
for path, val := range expectations {
Expand All @@ -223,7 +224,11 @@ func proxyContext(version string) {
defer wg.Done()
body, status, d, err := doProxy(f, path)
if err != nil {
recordError(fmt.Sprintf("%v: path %v gave error: %v", i, path, err))
if serr, ok := err.(*errors.StatusError); ok {
recordError(fmt.Sprintf("%v: path %v gave status error: %+v", i, path, serr.Status()))
} else {
recordError(fmt.Sprintf("%v: path %v gave error: %v", i, path, err))
}
return
}
if status != http.StatusOK {
Expand All @@ -242,15 +247,15 @@ func proxyContext(version string) {
}
wg.Wait()

if len(errors) != 0 {
if len(errs) != 0 {
body, err := f.Client.Pods(f.Namespace.Name).GetLogs(pods[0].Name, &api.PodLogOptions{}).Do().Raw()
if err != nil {
framework.Logf("Error getting logs for pod %s: %v", pods[0].Name, err)
} else {
framework.Logf("Pod %s has the following error logs: %s", pods[0].Name, body)
}

Fail(strings.Join(errors, "\n"))
Fail(strings.Join(errs, "\n"))
}
})
}
Expand Down