Skip to content

Commit

Permalink
OCM-11096 | ci: Fix the result reporting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
xueli181114 committed Sep 12, 2024
1 parent 70aaede commit 359cf5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion tests/prow_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,14 @@ upload_junit_result () {
exit 1
fi
filePath=$1
fileParantPath=$(dirname $filePath)
uploadDir=$2
archiveDir=$3
filename=$(echo "${filePath%.*}" | awk -F "/" '{print $NF}')
fullFileName=$(basename $filePath)
tarPath=${uploadDir}/${filename}.tar.gz
echo "[CI] going to zip the junit file $filePath to $tarPath"
tar -zcvf $tarPath $filePath
tar -C $fileParantPath -zcvf $tarPath $fullFileName
echo "[CI] archiving the the testing result"
# copy the junit.tar.gz to ARTIFACT_DIR
cp $tarPath ${archiveDir}
Expand Down
24 changes: 12 additions & 12 deletions tests/utils/exec/reportportal/report_portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path"
"path/filepath"
"regexp"
"strings"

Expand Down Expand Up @@ -133,7 +134,7 @@ func GenerateReportXMLFile() (int, int, map[string][]Testcase, map[string][]Test
passedNum := 0
issuedNum := 0

xmlFileList := ListFiles(config.Test.ArtifactDir, ".xml")
xmlFileList := ListFiles(config.Test.OutputDir, ".xml")
for _, xmlFile := range xmlFileList {
xmlFilename := path.Base(xmlFile)
xmlFilePrefix := strings.TrimSuffix(xmlFilename, ".xml")
Expand Down Expand Up @@ -183,21 +184,20 @@ func GenerateReportXMLFile() (int, int, map[string][]Testcase, map[string][]Test
return passedNum, issuedNum, issuedTCList, successedTCList
}

func ListFiles(dir string, subfix string) []string {
func ListFiles(dir string, suffix string) []string {
var Files []string
fs, err := os.ReadDir(dir)
if err != nil {
panic(fmt.Sprintf("Failed to open the directory %s: %v\n", dir, err))
if _, err := os.Stat(dir); err != nil {
panic(fmt.Sprintf("provided dir %s not exist", dir))
}
for _, f := range fs {
if path.Ext(f.Name()) != subfix {
continue
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(info.Name(), suffix) {
Files = append(Files, path)
}

filename := path.Join(dir, f.Name())
Files = append(Files, filename)
return nil
})
if err != nil {
panic(fmt.Sprintf("Failed to open the directory %s: %v\n", dir, err))
}

return Files
}

Expand Down

0 comments on commit 359cf5f

Please sign in to comment.