diff options
author | Brian Freeman <bf1936@att.com> | 2019-08-20 13:13:58 -0500 |
---|---|---|
committer | Daniel Rose <dr695h@att.com> | 2019-08-21 17:12:16 +0000 |
commit | 48d30546f897c3980186b886fa0635ca47bc500e (patch) | |
tree | 6d2ab89e6978ad38f09edab051c2c5c55ce40805 /deployment/onap-lab-ci/scripts/process-robot.sh | |
parent | 7138060f1d84cf233a56e72403ca19113a553a95 (diff) |
Ingest onap-lab-ci jjb's
Issue-ID: INT-1215
Change-Id: I448fb7a147daa26d760df6c83fef75aa69f05879
Signed-off-by: Brian Freeman <bf1936@att.com>
Diffstat (limited to 'deployment/onap-lab-ci/scripts/process-robot.sh')
-rwxr-xr-x | deployment/onap-lab-ci/scripts/process-robot.sh | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/deployment/onap-lab-ci/scripts/process-robot.sh b/deployment/onap-lab-ci/scripts/process-robot.sh new file mode 100755 index 000000000..e902bf3e8 --- /dev/null +++ b/deployment/onap-lab-ci/scripts/process-robot.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +if [ "$#" -ne 3 ]; then + echo "$0 <output.xml> <job> <build>" + exit 1 +fi +ROBOT_OUTPUT=$1 +JOB=$2 +BUILD=$3 + +INFLUX_ENDPOINT='http://10.145.123.16:8086/write?db=robot' + +TMP_XML=/tmp/output-$JOB-$BUILD.xml + +if [ ! -f $TMP_XML ]; then + xmlstarlet ed -d '//kw' -d '//timeout' -d '//tags' $ROBOT_OUTPUT | tr -d '\n' > $TMP_XML + + # Canonicalize Robot suite names + sed -i 's/ONAP.Verify/ONAP_CI/g' $TMP_XML + sed -i 's/ONAP.Daily/ONAP_CI/g' $TMP_XML + sed -i 's/OpenECOMP.ETE/ONAP_CI/g' $TMP_XML +fi + + +TIMESTR=$(xmlstarlet sel -t -v "/robot/@generated" $TMP_XML) +TIME=$(date -d "${TIMESTR}Z" +%s%N) + +POINTS_FILE=/tmp/points-$JOB-$BUILD.txt +rm -f $POINTS_FILE + +# test +xmlstarlet sel -t -m "//test" -c "." -n $TMP_XML | while read test; do + NAME=$(echo "$test" | xmlstarlet sel -t -v "/test/@name" | tr ' ' '_' | xmlstarlet unesc) + if [ "PASS" = $(echo "$test" | xmlstarlet sel -t -v "/test/status/@status" ) ]; then + PASS=1 + FAIL=0 + else + PASS=0 + FAIL=1 + fi + STARTTIME=$(date -d "$(echo $test | xmlstarlet sel -t -v "/test/status/@starttime")Z" +%s%N) + ENDTIME=$(date -d "$(echo $test | xmlstarlet sel -t -v "/test/status/@endtime")Z" +%s%N) + echo test,job=$JOB,name=$NAME build=$BUILD,pass=$PASS,fail=$FAIL,starttime=$STARTTIME,endtime=$ENDTIME $TIME | tee -a $POINTS_FILE +done + +# suite +xmlstarlet sel -t -m "/robot/statistics/suite/stat" -c "." -n $TMP_XML | while read suite; do + ID=$(echo "$suite" | xmlstarlet sel -t -v "/stat/@id" ) + STATUS=$(xmlstarlet sel -t -m "//suite[@id=\"$ID\"]/status" -c "." -n $TMP_XML) + STARTTIMESTR=$(echo $STATUS | xmlstarlet sel -t -v "/status/@starttime") + ENDTIMESTR=$(echo $STATUS | xmlstarlet sel -t -v "/status/@endtime") + NAME=$(echo "$suite" | xmlstarlet sel -t -m "/stat" -v . | tr ' ' '_' | xmlstarlet unesc) + PASS=$(echo "$suite" | xmlstarlet sel -t -v "/stat/@pass" ) + FAIL=$(echo "$suite" | xmlstarlet sel -t -v "/stat/@fail" ) + if [ "$STARTTIMESTR" != "N/A" ] && [ "$ENDTIMESTR" != "N/A" ]; then + STARTTIME=$(date -d "${STARTTIMESTR}Z" +%s%N) + ENDTIME=$(date -d "${ENDTIMESTR}Z" +%s%N) + echo suite,job=$JOB,name=$NAME build=$BUILD,pass=$PASS,fail=$FAIL,starttime=$STARTTIME,endtime=$ENDTIME $TIME | tee -a $POINTS_FILE + else + echo suite,job=$JOB,name=$NAME build=$BUILD,pass=$PASS,fail=$FAIL $TIME | tee -a $POINTS_FILE + fi +done + +# tag +xmlstarlet sel -t -m "/robot/statistics/tag/stat" -c "." -n $TMP_XML | while read tag; do + NAME=$(echo "$tag" | xmlstarlet sel -t -m "/stat" -v . | tr ' ' '_' | xmlstarlet unesc) + PASS=$(echo "$tag" | xmlstarlet sel -t -v "/stat/@pass" ) + FAIL=$(echo "$tag" | xmlstarlet sel -t -v "/stat/@fail" ) + echo tag,job=$JOB,name=$NAME build=$BUILD,pass=$PASS,fail=$FAIL $TIME | tee -a $POINTS_FILE +done + +curl -i $INFLUX_ENDPOINT --data-binary @$POINTS_FILE |