Skip to content

Commit

Permalink
prune junit xml files in ci harness
Browse files Browse the repository at this point in the history
Over time the size of our junit xml has exploded to the point where
test-grid fails to process them. We still have the original/full
*.stdout files from where the junit xml files are generated from so the
junit xml files need NOT have the fill/exact output for
processing/display. So let us prune the large messages with an
indicator that we have "[... clipped...]" some of the content so folks
can see that they have to consult the full *.stdout files.

Signed-off-by: Davanum Srinivas <[email protected]>
  • Loading branch information
dims committed Mar 30, 2022
1 parent 917c361 commit d20df79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/prune-junit-xml/prunexml.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"encoding/xml"
"flag"
"fmt"
"io"
"os"
)
Expand Down Expand Up @@ -76,6 +77,7 @@ func main() {

if flag.NArg() > 0 {
for _, path := range flag.Args() {
fmt.Printf("processing junit xml file : %s\n", path)
xmlReader, err := os.Open(path)
if err != nil {
panic(err)
Expand All @@ -97,6 +99,7 @@ func main() {
if err != nil {
panic(err)
}
fmt.Println("done.")
}
}
}
Expand All @@ -106,12 +109,14 @@ func pruneXML(suites *JUnitTestSuites, maxBytes int) {
for _, testcase := range suite.TestCases {
if testcase.SkipMessage != nil {
if len(testcase.SkipMessage.Message) > maxBytes {
fmt.Printf("clipping skip message in test case : %s\n", testcase.Name)
testcase.SkipMessage.Message = "[... clipped...]" +
testcase.SkipMessage.Message[len(testcase.SkipMessage.Message)-maxBytes:]
}
}
if testcase.Failure != nil {
if len(testcase.Failure.Contents) > maxBytes {
fmt.Printf("clipping failure message in test case : %s\n", testcase.Name)
testcase.Failure.Contents = "[... clipped...]" +
testcase.Failure.Contents[len(testcase.Failure.Contents)-maxBytes:]
}
Expand Down
8 changes: 8 additions & 0 deletions hack/make-rules/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ produceJUnitXMLReport() {
rm "${junit_filename_prefix}"*.stdout
fi

if ! command -v prune-junit-xml >/dev/null 2>&1; then
kube::log::status "prune-junit-xml not found; installing from hack/tools"
pushd "${KUBE_ROOT}/cmd/prune-junit-xml" >/dev/null
GO111MODULE=on go install .
popd >/dev/null
fi
prune-junit-xml "${junit_xml_filename}"

kube::log::status "Saved JUnit XML test report to ${junit_xml_filename}"
}

Expand Down

0 comments on commit d20df79

Please sign in to comment.