diff options
Diffstat (limited to 'deployment/onap-lab-ci/scripts')
-rwxr-xr-x | deployment/onap-lab-ci/scripts/load_all.sh | 5 | ||||
-rwxr-xr-x | deployment/onap-lab-ci/scripts/load_influx.sh | 14 | ||||
-rwxr-xr-x | deployment/onap-lab-ci/scripts/mirror-nexus.sh | 28 | ||||
-rwxr-xr-x | deployment/onap-lab-ci/scripts/process-pods.sh | 37 | ||||
-rwxr-xr-x | deployment/onap-lab-ci/scripts/process-robot.sh | 72 |
5 files changed, 156 insertions, 0 deletions
diff --git a/deployment/onap-lab-ci/scripts/load_all.sh b/deployment/onap-lab-ci/scripts/load_all.sh new file mode 100755 index 000000000..230fa8b9d --- /dev/null +++ b/deployment/onap-lab-ci/scripts/load_all.sh @@ -0,0 +1,5 @@ +#!/bin/bash -x +./load_influx.sh tlab-heat-daily 1 104 +./load_influx.sh tlab-oom-daily 1 110 +./load_influx.sh windriver-heat-daily 1 106 +./load_influx.sh windriver-oom-daily 1 110 diff --git a/deployment/onap-lab-ci/scripts/load_influx.sh b/deployment/onap-lab-ci/scripts/load_influx.sh new file mode 100755 index 000000000..71948801a --- /dev/null +++ b/deployment/onap-lab-ci/scripts/load_influx.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ "$#" -ne 3 ]; then + echo "$0 <job> <start_build> <end_build>" + exit 1 +fi +JOB_NAME=$1 +START_BUILD=$2 +END_BUILD=$3 + +set -x +for BUILD_NUMBER in $(seq $START_BUILD $END_BUILD); do + ./process-robot.sh ~/jobs/$JOB_NAME/builds/$BUILD_NUMBER/robot-plugin/output.xml $JOB_NAME $BUILD_NUMBER +done diff --git a/deployment/onap-lab-ci/scripts/mirror-nexus.sh b/deployment/onap-lab-ci/scripts/mirror-nexus.sh new file mode 100755 index 000000000..94efaa10f --- /dev/null +++ b/deployment/onap-lab-ci/scripts/mirror-nexus.sh @@ -0,0 +1,28 @@ +#!/bin/bash + + +if [ "$#" -ne 1 ]; then + echo "$0 <repo>" + echo " where <repo> is releases or staging" + exit 1 +fi + +set -x +REPO=$1 + +LOG_DIR=/var/www/html/logs/mirror-nexus/$REPO/ +mkdir -p $LOG_DIR + +LOG_FILE=$LOG_DIR/$(date +%FT%TZ).log +TAR_FILE=$REPO-$(date +%F).tar + +MIRRORS_DIR=/var/www/html/mirrors/nexus.onap.org +REPO_DIR=$MIRRORS_DIR/$REPO +mkdir -p $REPO_DIR +cd $REPO_DIR + +wget -nv --mirror --random-wait --no-if-modified-since --no-parent -e robots=off --reject "index.html*" -nH --cut-dirs=3 "https://nexus.onap.org/content/repositories/$REPO/" -o /dev/stdout | sed -u "s|URL:https://nexus.onap.org/content/repositories/$REPO/||g" | sed -u 's| ->.*||g' > $LOG_FILE + +cd $MIRRORS_DIR +tar cvf $TAR_FILE.part $REPO/ +mv -b $TAR_FILE.part $TAR_FILE diff --git a/deployment/onap-lab-ci/scripts/process-pods.sh b/deployment/onap-lab-ci/scripts/process-pods.sh new file mode 100755 index 000000000..fada45419 --- /dev/null +++ b/deployment/onap-lab-ci/scripts/process-pods.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +if [ "$#" -ne 3 ]; then + echo "$0 <onap-pods.json> <job> <build>" + exit 1 +fi +JSON_OUTPUT=$1 +JOB=$2 +BUILD=$3 + +INFLUX_ENDPOINT='http://10.145.123.16:8086/write?db=robot' + + +TIME=$(date -r $JSON_OUTPUT +%s%N) + +POINTS_FILE=/tmp/points-$JOB-$BUILD-pods.txt +rm -f $POINTS_FILE + +cat $JSON_OUTPUT | jq -r '.items[] | ( (.status.containerStatuses[] | ( " "+.image + " " + (.restartCount | tostring) + " " + (.ready | tostring) ) ) ) + " " + .metadata.name ' | grep -e 'onap/' -e 'openecomp/' | sort | while read CONTAINER; do + IMAGE=$(echo $CONTAINER | cut -d ' ' -f 1 | sed -r 's#.*/(onap|openecomp)/##g') + RESTART_COUNT=$(echo $CONTAINER | cut -d ' ' -f 2) + READY=$(echo $CONTAINER | cut -d ' ' -f 3) + POD=$(echo $CONTAINER | cut -d ' ' -f 4) + + if [ "$READY" = "true" ] && [ "$RESTART_COUNT" -eq 0 ]; then + PASS=1 + FAIL=0 + else + PASS=0 + FAIL=1 + fi + + # currently assumes that no onap pod contains multiple containers of with the same image + echo container,job=$JOB,image=$IMAGE,pod=$POD build=$BUILD,restartCount=$RESTART_COUNT,ready=$READY,pass=$PASS,fail=$FAIL $TIME | tee -a $POINTS_FILE +done + +curl -i $INFLUX_ENDPOINT --data-binary @$POINTS_FILE 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 |