jjb/common: lava-jobs: create device name aliases 85/11985/1
authorLoys Ollivier <lollivier@baylibre.com>
Wed, 15 Nov 2017 09:24:09 +0000 (10:24 +0100)
committerLoys Ollivier <lollivier@baylibre.com>
Wed, 15 Nov 2017 09:24:09 +0000 (10:24 +0100)
The previous version would fail to find some boards if the device names
were different between lava, AGL, releng.
This version creates a device alias table. And uses this table with the
correct name for each component (AGL, lava, releng).

Change-Id: Ief064c5ff9edb2d824e80549148ee0ab40ebcddf
Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
jjb/common/include-agl-lava-jobs-submit.sh
jjb/common/include-agl-lava-labs-prepare.sh
jjb/common/include-agl-run-test-short.sh

index be2830a..b63ed2e 100644 (file)
@@ -12,71 +12,53 @@ if [ ! -e $JOB_FILE ]; then
 fi
 JOB_BASE=$(basename $JOB_FILE .yaml)
 
-# find device_type from job file
-line=$(grep ^device_type: $JOB_FILE | tr -d '[:space:]')
-__device_type=${line/device_type:/}
-echo "Found device_type $__device_type in LAVA job $JOB_FILE"
+# Need to hack the LAVA device-type name in the job file
+JOB_FILE_NEW="${JOB_BASE}_${LAVA_LAB}.yaml"
+cat $JOB_FILE | sed "s/device_type: $releng_device/device_type: $lava_device/" > $JOB_FILE_NEW
 
-declare -A dt_aliases
-dt_aliases=(
-    [raspberrypi3-uboot]="bcm2837-rpi-3-b-32b"
-    [bcm2837-rpi-3-b-32b]="raspberrypi3-uboot"
-)
-device_types=$__device_type
-device_types+=" "
-device_types+=${dt_aliases[$__device_type]}
-
-for device_type in $device_types; do
-    # Need to hack the real device-type name in the job file
-    JOB_FILE_NEW="${JOB_BASE}_${LAVA_LAB}.yaml"
-    cat $JOB_FILE | sed "s/device_type: $__device_type/device_type: $device_type/" > $JOB_FILE_NEW
-
-    #
-    # LAVA job submit, get job ID from lava-tool output
-    #
-    JOB_STATUS="${JOB_BASE}_${LAVA_LAB}.status"
-    lava-tool submit-job $full_url $JOB_FILE_NEW |tee $JOB_STATUS
-    # Printing the job URL in the log
-    grep "submitted as job:" $JOB_STATUS
-    job_id=$(grep "submitted as job:" $JOB_STATUS | sed 's/.*\/\([0-9]*$\)/\1/')
+#
+# LAVA job submit, get job ID from lava-tool output
+#
+JOB_STATUS="${JOB_BASE}_${LAVA_LAB}.status"
+lava-tool submit-job $full_url $JOB_FILE_NEW |tee $JOB_STATUS
+# Printing the job URL in the log
+grep "submitted as job:" $JOB_STATUS
+job_id=$(grep "submitted as job:" $JOB_STATUS | sed 's/.*\/\([0-9]*$\)/\1/')
 
-    #
-    # LAVA wait job events, wait for job to finish
-    #
-    lava-tool wait-job-events --job-id $job_id $full_url
+#
+# LAVA wait job events, wait for job to finish
+#
+lava-tool wait-job-events --job-id $job_id $full_url
 
-    #
-    # LAVA job details, get job status from lava-tool output
-    #
-    lava-tool job-details $full_url $job_id | tee $JOB_STATUS
+#
+# LAVA job details, get job status from lava-tool output
+#
+lava-tool job-details $full_url $job_id | tee $JOB_STATUS
 
-    IFS=':'
-    line=$(grep "^status:" $JOB_STATUS | tr -d '[:space:]')
-    arr=($line)
-    status=${arr[1]}
-    IFS=${OFS}
+IFS=':'
+line=$(grep "^status:" $JOB_STATUS | tr -d '[:space:]')
+arr=($line)
+status=${arr[1]}
+IFS=${OFS}
 
-    echo "LAVA job $job_id completed with status: $status"
+echo "LAVA job $job_id completed with status: $status"
 
-    echo "####"
-    echo "#### Start: Output from LAVA job $job_id ####"
-    echo "####"
+echo "####"
+echo "#### Start: Output from LAVA job $job_id ####"
+echo "####"
 
-    JOB_OUTPUT="${JOB_BASE}_output.yaml"
-    JOB_LOG="${JOB_BASE}_output.log"
-    curl -s -o $JOB_OUTPUT $full_url/scheduler/job/$job_id/log_file/plain
-    cat $JOB_OUTPUT | grep '"target",' | sed -e 's#- {"dt".*"lvl".*"msg":."##g' -e 's#"}$##g' | tee $JOB_LOG
+JOB_OUTPUT="${JOB_BASE}_output.yaml"
+JOB_LOG="${JOB_BASE}_output.log"
+curl -s -o $JOB_OUTPUT $full_url/scheduler/job/$job_id/log_file/plain
+cat $JOB_OUTPUT | grep '"target",' | sed -e 's#- {"dt".*"lvl".*"msg":."##g' -e 's#"}$##g' | tee $JOB_LOG
 
-    echo "####"
-    echo "#### End: Output from LAVA job $job_id ####"
-    echo "####"
+echo "####"
+echo "#### End: Output from LAVA job $job_id ####"
+echo "####"
 
-    # after one successful submit, we're done
-    if [ x"$status" = x"Complete" ]; then
-        exit 0
-    else
-        continue
-    fi
-done
+# after one successful submit, we're done
+if [ x"$status" = x"Complete" ]; then
+    exit 0
+fi
 
 exit 1
index cde6539..b7acd0a 100644 (file)
@@ -31,6 +31,21 @@ cat <<EOF >  ~/.local/share/python_keyring/keyringrc.cfg
 default-keyring=keyring.backends.file.PlaintextKeyring
 EOF
 
+declare -A agl_lava_releng_aliases
+agl_lava_releng_aliases=(
+    [raspberrypi3]="raspberrypi3-uboot;raspberrypi3"
+    [qemux86-64]="qemu;qemux86-64"
+    [m3ulcb-nogfx]="r8a7796-m3ulcb;m3ulcb"
+)
+
+OFS=${IFS}
+IFS=';'
+arr=(${agl_lava_releng_aliases[$MACHINE]})
+IFS=${OFS}
+lava_device=${arr[0]}
+releng_device=${arr[1]}
+# And agl_device=${MACHINE}
+
 for lab in "${!labs[@]}"; do
     val=${labs[$lab]}
     OFS=${IFS}
@@ -67,8 +82,8 @@ for lab in "${!labs[@]}"; do
     rm -f $token_file
 
     # Find the LAVA Lab that has the device available to run the job
-    echo -n "Checking for $__MACHINE at $full_url... "
-    line=$(lava-tool devices-list $full_url |grep $__MACHINE | tr -d '[:space:]')
+    echo -n "Checking for $lava_device at $full_url... "
+    line=$(lava-tool devices-list $full_url |grep $lava_device | tr -d '[:space:]')
     if [ -z "$line" ]; then
         echo "not found."
         continue
index 7db7ec5..ba0cdeb 100644 (file)
@@ -21,7 +21,7 @@ if [ ! -z $RELENG ] && \
     echo "## Check version of python-jinja2: "
     pip show jinja2
     CREATE_ARGS=""
-    CREATE_ARGS+="--machine ${__MACHINE} "
+    CREATE_ARGS+="--machine ${releng_device} "
     CREATE_ARGS+="--url ci "
     [[ ! -z $GERRIT_CHANGE_NUMBER ]] && CREATE_ARGS+="--changeid $GERRIT_CHANGE_NUMBER "
     [[ ! -z $GERRIT_PATCHSET_NUMBER ]] && CREATE_ARGS+="--patchset $GERRIT_PATCHSET_NUMBER "