From ec93f69e3c3ea8316350ed8d152b67bd52587668 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Mon, 30 Sep 2019 10:06:02 +0200 Subject: [PATCH 1/2] Truncate commands outputs to 500 chars --- test/e2e/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/utils.go b/test/e2e/utils.go index 4d2bc8fe6..1633ab5be 100644 --- a/test/e2e/utils.go +++ b/test/e2e/utils.go @@ -223,7 +223,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") From 5e8974fec227f0c1fe9cd885df49c9ce5bc3883b Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Mon, 30 Sep 2019 10:34:14 +0200 Subject: [PATCH 2/2] Format k8s logs so we get a proper new line for nmstate --- test/e2e/utils.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/e2e/utils.go b/test/e2e/utils.go index 1633ab5be..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 }