Skip to content

Commit

Permalink
Clean up test logs (#190)
Browse files Browse the repository at this point in the history
* Truncate commands outputs to 500 chars

* Format k8s logs so we get a proper new line for nmstate
  • Loading branch information
qinqon authored and phoracek committed Sep 30, 2019
1 parent e88e525 commit 3cdda76
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os/exec"
"strings"
"testing"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 3cdda76

Please sign in to comment.