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

e2e: Dump stdout and describe ksvc #659

Merged
merged 1 commit into from
Feb 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,31 @@ func runCLIWithOpts(cli string, args []string, opts runOpts, logger Logger) (str
err := cmd.Run()
if err != nil {
err = fmt.Errorf("Execution error: stderr: '%s' error: '%s'", stderr.String(), err)

if !opts.AllowError {
fmt.Println("================[[Error]]=================")
fmt.Println(stdout.String())
dumpKsvc(args, logger)
logger.Fatalf("Failed to successfully execute '%s': %v", cmdCLIDesc(cli, args), err)
}
}

return stdout.String(), err
}

func dumpKsvc(args []string, logger Logger) {
if args[0] == "service" {
opts := runOpts{AllowError: true}
ns := args[len(args)-1]
out, err := runCLIWithOpts("kubectl", []string{"-n", ns, "describe", "ksvc", args[2]}, opts, logger)
fmt.Println(err)
fmt.Println(out)
out, err = runCLIWithOpts("kubectl", []string{"-n", ns, "get", "ksvc", args[2], "-oyaml"}, opts, logger)
fmt.Println(err)
fmt.Println(out)
fmt.Println("================[[Error]]=================")
}
}

func cmdCLIDesc(cli string, args []string) string {
return fmt.Sprintf("%s %s", cli, strings.Join(args, " "))
}
Expand Down