From 57daab8b59be9f90dc18394e31453216e3f40ac9 Mon Sep 17 00:00:00 2001 From: Charlie Chiang Date: Thu, 11 Aug 2022 01:43:21 +0800 Subject: [PATCH] optimize ci logs Signed-off-by: Charlie Chiang --- test/e2e-test/addon-test/main.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/test/e2e-test/addon-test/main.go b/test/e2e-test/addon-test/main.go index aa6f6830..66ee3262 100644 --- a/test/e2e-test/addon-test/main.go +++ b/test/e2e-test/addon-test/main.go @@ -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 } @@ -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 } @@ -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)) +}