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

Clean up test logs #190

Merged
merged 2 commits into from
Sep 30, 2019
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
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())))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it would be worth setting this via an environment variable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do like this, in case of error vlans are show in full so we are good, another option is to dump to files the full output and print the truncated ones.

// 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