diff --git a/test/e2e/utils.go b/test/e2e/utils.go index 4d2bc8fe6..a5259323d 100644 --- a/test/e2e/utils.go +++ b/test/e2e/utils.go @@ -5,6 +5,7 @@ import ( "context" "fmt" "io" + "io/ioutil" "os/exec" "strings" "testing" @@ -57,12 +58,13 @@ func writePodsLogs(namespace string, sinceTime time.Time, writer io.Writer) erro continue } defer podLogs.Close() - _, err = io.Copy(writer, podLogs) + rawLogs, err := ioutil.ReadAll(podLogs) if err != nil { - io.WriteString(writer, fmt.Sprintf("error in copy information from podLogs to buf: %v\n", err)) + io.WriteString(writer, fmt.Sprintf("error reading kubernetes-nmstate logs: %v\n", err)) continue } - + formattedLogs := strings.Replace(string(rawLogs), "\\n", "\n", -1) + io.WriteString(writer, formattedLogs) } return nil } @@ -223,7 +225,7 @@ func run(node string, command ...string) (string, error) { cmd.Stderr = &stderr cmd.Stdout = &stdout err := cmd.Run() - GinkgoWriter.Write([]byte(stdout.String() + stderr.String() + "\n")) + GinkgoWriter.Write([]byte(fmt.Sprintf("stdout: %.500s...\n, stderr %s\n", stdout.String(), stderr.String()))) // Remove first two lines from output, ssh.sh add garbage there outputLines := strings.Split(stdout.String(), "\n") output := strings.Join(outputLines[2:], "\n")