X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ci-management.git;a=blobdiff_plain;f=jjb%2Fshell%2Frun_bluval.sh;h=ac3df5fa46ba9b1e5abc6cf7acdb8c8c5d68bd00;hp=5870ed99e40650245dfa5af6e7383b392cf359b3;hb=2f1d9c5a56df4004bf18f25158ab2e7ba4235697;hpb=c14b86987c50050a85f0394bf8d3eca89a0c64b7 diff --git a/jjb/shell/run_bluval.sh b/jjb/shell/run_bluval.sh index 5870ed9..ac3df5f 100755 --- a/jjb/shell/run_bluval.sh +++ b/jjb/shell/run_bluval.sh @@ -12,20 +12,24 @@ set -o errexit set -o pipefail cwd=$(pwd) +current_user=$(whoami) is_optional="false" -finish() { - # Fix ownership of output files - user_id=$(stat -c '%u:%g' $cwd) - sudo chown -R ${user_id} $results_dir -} - info () { logger -s -t "run_blu_val.info" "$*" } +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 "usage: $0" >&2 + echo "[-n ">&2 echo "[-r results dir">&2 echo "[-b blueprint definition">&2 echo "[-k k8s config dir">&2 @@ -77,6 +81,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 @@ -118,21 +123,14 @@ then fi fi -trap finish EXIT - -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 @@ -142,5 +140,19 @@ 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 failed!" +fi + +set -e + +change_res_owner