Skip to content

Commit

Permalink
e2e: Dump stdout and describe ksvc (#659)
Browse files Browse the repository at this point in the history
if the service create/update command execution failed
  • Loading branch information
navidshaikh authored Feb 12, 2020
1 parent e031917 commit 3019f68
Showing 1 changed file with 17 additions and 1 deletion.
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

0 comments on commit 3019f68

Please sign in to comment.