X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ci-management.git;a=blobdiff_plain;f=jjb%2Fshell%2Frun_bluval.sh;h=cc88171e40d38d68e5af208b5843339bd66856bb;hp=5f0c4dbdb4c06f22a11c392d3a5d923ebf19d401;hb=d7af068323b683653c1e3537c3b55c8a57a25f08;hpb=7cb83b7f5818727f5293fc02b96d5e5f065a78a1 diff --git a/jjb/shell/run_bluval.sh b/jjb/shell/run_bluval.sh index 5f0c4db..cc88171 100755 --- a/jjb/shell/run_bluval.sh +++ b/jjb/shell/run_bluval.sh @@ -10,17 +10,31 @@ set -e set -o errexit set -o pipefail +export PATH=$PATH:/home/jenkins/.local/bin cwd=$(pwd) +current_user=$(whoami) is_optional="false" info () { logger -s -t "run_blu_val.info" "$*" } +has_substring() { + [ "$1" != "${2/$1/}" ] +} + +change_res_owner() { +# change owner of results created by root in container + if [ -d "$results_dir" ] + then + sudo chown -R "$current_user" "$results_dir" + fi +} + usage() { - echo "usage: $0 -n " >&2 - echo "[-r results dir">&2 + echo "usage: $0" >&2 + echo "[-n ">&2 echo "[-b blueprint definition">&2 echo "[-k k8s config dir">&2 echo "[-j k8s master">&2 @@ -58,7 +72,6 @@ while getopts "j:k:u:s:b:l:r:n:ov:" optchar; do s) ssh_key=${OPTARG} ;; b) blueprint_yaml=${OPTARG} ;; l) blueprint_layer=${OPTARG} ;; - r) results_dir=${OPTARG} ;; n) blueprint_name=${OPTARG} ;; u) sh_user=${OPTARG} ;; o) is_optional="true" ;; @@ -71,6 +84,7 @@ while getopts "j:k:u:s:b:l:r:n:ov:" optchar; do done # Blueprint name is mandatory +blueprint_name=${blueprint_name:-$BLUEPRINT} if [ -z "$blueprint_name" ] then usage @@ -88,7 +102,7 @@ mkdir -p "$k8s_config_dir" # Testing configuration version=${version:-$VERSION} -results_dir=${results_dir:-$cwd/results} +results_dir=$cwd/results k8s_master=${k8s_master:-$K8S_MASTER_IP} ssh_user=${sh_user:-$K8S_SSH_USER} blueprint_layer=${blueprint_layer:-$LAYER} @@ -112,19 +126,14 @@ then fi fi -if [ ! -d "$cwd/validation" ] -then - git clone http://gerrit.akraino.org/r/validation -fi - if [[ -n $blueprint_yaml ]] then - cp "$blueprint_yaml" ./validation/bluval/ + cp "$blueprint_yaml" ./bluval/ fi -volumes_path="$cwd/validation/bluval/volumes.yaml" +volumes_path="$cwd/bluval/volumes.yaml" #update information in volumes yaml -sed -i -e "/kube_config_dir/{n; s@local: ''@local: '$k8s_config_dir'@}" -e "/blueprint_dir/{n; s@local: ''@local: '$cwd/validation/bluval/'@}" -e "/results_dir/{n; s@local: ''@local: '$results_dir'@}" "$volumes_path" +sed -i -e "/kube_config_dir/{n; s@local: ''@local: '$k8s_config_dir'@}" -e "/blueprint_dir/{n; s@local: ''@local: '$cwd/bluval/'@}" -e "/results_dir/{n; s@local: ''@local: '$results_dir'@}" "$volumes_path" if [[ -n $blueprint_layer ]] then @@ -134,5 +143,33 @@ if [ "$is_optional" == "true" ] || [ "$OPTIONAL" == "yes" ] then options+=" -o" fi + +printf 'ok / PASS /\nerror / FAIL /\n' > ./bluval/rules.txt + +set +e +# even if the script fails we need to change the owner of results # shellcheck disable=SC2086 -python3 validation/bluval/blucon.py $options "$blueprint_name" +python3 bluval/blucon.py $options "$blueprint_name" + +if [ $? -ne 0 ]; then + change_res_owner + error "Bluval validation FAIL " +fi +set -e + +change_res_owner +if has_substring "$NODE_NAME" "snd-" +then + echo "In sandbox the logs are not pushed" +else + TIMESTAMP=$(date +'%Y%m%d-%H%M%S') + NEXUS_URL=https://nexus.akraino.org/ + NEXUS_PATH="${LAB_SILO}/bluval_results/${blueprint_name}/${VERSION}/${TIMESTAMP}" + BUILD_URL="${JENKINS_HOSTNAME}/job/${JOB_NAME}/${BUILD_NUMBER}/" + zip -r results.zip ./results + lftools deploy nexus-zip "$NEXUS_URL" logs "$NEXUS_PATH" results.zip +fi + +rm results.zip +rm -f ~/.netrc +