Skip to content

Commit

Permalink
optimize ci logs
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Chiang <[email protected]>
  • Loading branch information
charlie0129 committed Aug 10, 2022
1 parent 597c491 commit 57daab8
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions test/e2e-test/addon-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,9 @@ func enableOneAddon(dir string) error {
return err
}
for {
tmp := make([]byte, 81920)
tmp := make([]byte, 102400)
_, err := stdout.Read(tmp)
// Remove enabling countdown, otherwise we cannot see anything in CI logs.
// There are unprintable characters everywhere and the log is huge.
str := strings.Map(func(r rune) rune {
if unicode.IsPrint(r) || r == '\n' {
return r
}
return -1
}, string(tmp))
str := convertToString(tmp)
if strings.Contains(str, "It is now in phase") {
continue
}
Expand Down Expand Up @@ -285,9 +278,10 @@ func disableOneAddon(addonName string) error {
return err
}
for {
tmp := make([]byte, 1024)
tmp := make([]byte, 102400)
_, err := stdout.Read(tmp)
fmt.Print(string(tmp))
str := convertToString(tmp)
fmt.Print(str)
if err != nil {
break
}
Expand Down Expand Up @@ -347,3 +341,15 @@ func checkPodStatus(namespace string) {
fmt.Println(err)
}
}

// convertToString converts []byte to string and removes unprintable characters
func convertToString(data []byte) string {
// Remove enabling countdown, otherwise we cannot see anything in CI logs.
// There are unprintable characters everywhere and the log is huge.
return strings.Map(func(r rune) rune {
if unicode.IsPrint(r) || r == '\n' {
return r
}
return -1
}, string(data))
}

0 comments on commit 57daab8

Please sign in to comment.