aboutsummaryrefslogtreecommitdiffstats
path: root/jjb/common
diff options
context:
space:
mode:
authorLoys Ollivier <lollivier@baylibre.com>2017-11-07 15:35:21 +0100
committerLoys Ollivier <lollivier@baylibre.com>2017-11-07 15:54:28 +0100
commit41f2a94135443b239d3335949726b4223d8c2f3d (patch)
tree052e1a32cc23ae77f8c6dcd42883067e26eaa5dd /jjb/common
parentbe498bcfdd7c0c2a3e47de0d8f6a04d9ef455662 (diff)
CIBT find the LAVA lab before calling releng
Add some logic to lava-labs-prepare: - Search for the machine in the list of labs - export the lab name if found Call releng with the corresponding lab name in run-test-short Send the job directly to the corresponding lab in lava-jobs-submit. Keep the 'checking for device' in this script as well, just to make sure the device is still available and can run the job. Otherwise the script could be blocked there if the device status changes. Change-Id: I50646b7fdb607cb9245a1d31e644eee45a2a2356 Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
Diffstat (limited to 'jjb/common')
-rw-r--r--jjb/common/include-agl-lava-jobs-submit.sh36
-rw-r--r--jjb/common/include-agl-lava-labs-prepare.sh33
-rw-r--r--jjb/common/include-agl-run-test-short.sh13
3 files changed, 60 insertions, 22 deletions
diff --git a/jjb/common/include-agl-lava-jobs-submit.sh b/jjb/common/include-agl-lava-jobs-submit.sh
index 3ebe8834..e7aed028 100644
--- a/jjb/common/include-agl-lava-jobs-submit.sh
+++ b/jjb/common/include-agl-lava-jobs-submit.sh
@@ -26,13 +26,11 @@ device_types=$__device_type
device_types+=" "
device_types+=${dt_aliases[$__device_type]}
-# iterate over available labs
-for lab in "${!labs[@]}"; do
- for device_type in $device_types; do
- val=${labs[$lab]}
+for device_type in $device_types; do
+ val=${labs[$LAVA_LAB]}
OFS=${IFS}
IFS=';'
- arr=(${labs[$lab]})
+ arr=(${labs[$LAVA_LAB]})
IFS=${OFS}
url=${arr[0]}
@@ -44,8 +42,8 @@ for lab in "${!labs[@]}"; do
echo -n "Checking for $device_type at $full_url... "
line=$(lava-tool devices-list $full_url |grep $device_type | tr -d '[:space:]')
if [ -z "$line" ]; then
- echo "not found."
- continue
+ echo "not found."
+ continue
fi
IFS='|'
arr=($line)
@@ -55,26 +53,26 @@ for lab in "${!labs[@]}"; do
# device is only available if "idle" or "running"
device_available=0
if [ x"$device_status" = x"idle" ]; then
- device_available=1
+ device_available=1
elif [ x"$device_status" = x"running" ]; then
- device_available=1;
+ device_available=1;
fi
if [ $device_available = 0 ]; then
- echo " Not Available. Status: $device_status"
- continue
+ echo " Not Available. Status: $device_status"
+ continue
else
- echo " Found and available. Status: $device_status"
+ echo " Found and available. Status: $device_status"
fi
-
+
# Need to hack the real device-type name in the job file
- JOB_FILE_NEW="${JOB_BASE}_${lab}.yaml"
+ 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 and status from lava-tool output
#
- JOB_STATUS="${JOB_BASE}_${lab}.status"
+ JOB_STATUS="${JOB_BASE}_${LAVA_LAB}.status"
lava-tool submit-job --block $full_url $JOB_FILE_NEW |tee $JOB_STATUS
IFS=':'
@@ -103,13 +101,13 @@ for lab in "${!labs[@]}"; do
# after one successful submit, we're done
if [ x"$status" = x"Complete" ]; then
- exit 0
+ exit 0
else
- continue
+ continue
fi
- done
done
-# if we get here, none of the labs had a successful completion
+# If we get here there was an issue in submitting the job to the lab
+# Most probably the device got retired, offlined, reserved in the lab
exit 1
diff --git a/jjb/common/include-agl-lava-labs-prepare.sh b/jjb/common/include-agl-lava-labs-prepare.sh
index e36fa662..bc590600 100644
--- a/jjb/common/include-agl-lava-labs-prepare.sh
+++ b/jjb/common/include-agl-lava-labs-prepare.sh
@@ -13,6 +13,9 @@ labs=(
# [baylibre_seattle]="http://lava.ished.com/;$LAB_BAYLIBRE_SEATTLE_USER;$LAB_BAYLIBRE_SEATTLE_TOKEN"
)
+echo "## ${MACHINE} ##"
+__MACHINE=${MACHINE%-nogfx}
+
#
# Ensure python_keyring is set to plaintext. Required for
# non-interactive use
@@ -48,7 +51,7 @@ for lab in "${!labs[@]}"; do
# LAVA URL with username
full_url=${url/:\/\//:\/\/${user}\@}
echo "LAVA auth-add for lab: $lab, URL: $full_url"
-
+
# LAVA auth using token
echo ${token} > $token_file
lava-tool auth-add --token $token_file $full_url
@@ -56,4 +59,32 @@ for lab in "${!labs[@]}"; do
echo "ERROR: Lab ${lab}: lava-tool auth-add failed."
fi
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:]')
+ if [ -z "$line" ]; then
+ echo "not found."
+ continue
+ fi
+ IFS='|'
+ arr=($line)
+ device_status=${arr[2]}
+ IFS=${OFS}
+
+ # device is only available if "idle" or "running"
+ device_available=0
+ if [ x"$device_status" = x"idle" ]; then
+ device_available=1
+ elif [ x"$device_status" = x"running" ]; then
+ device_available=1;
+ fi
+
+ if [ $device_available = 0 ]; then
+ echo " Not Available. Status: $device_status"
+ continue
+ else
+ echo " Found and available. Status: $device_status"
+ export LAVA_LAB=$lab
+ fi
done
diff --git a/jjb/common/include-agl-run-test-short.sh b/jjb/common/include-agl-run-test-short.sh
index 83bfc18c..fda2da9e 100644
--- a/jjb/common/include-agl-run-test-short.sh
+++ b/jjb/common/include-agl-run-test-short.sh
@@ -5,10 +5,19 @@
## Run SHORT CI test
################################################################################
-
set -x
+#
+# LAVA lab names for releng-scripts
+#
+declare -A lava_labs
+lava_labs=(
+ [agl]="lab-agl-core"
+ [baylibre]="lab-baylibre-legacy"
+ )
+
echo "## ${MACHINE} ##"
+echo "# ${lava_labs[$LAVA_LAB]} #"
cd $REPODIR
# WIP: use $RELENG for subset of boards
@@ -29,7 +38,7 @@ if [ ! -z $RELENG ] && \
[[ -e output/repo-manifest-r.txt.sha1 ]] && BUILD_VERSION+="-$(cat output/repo-manifest-r.txt.sha1)"
CREATE_ARGS+="--name AGL-gerrit "
CREATE_ARGS+="--build-version $BUILD_VERSION "
- CREATE_ARGS+="--callback lab-baylibre-legacy "
+ CREATE_ARGS+="--callback ${lava_labs[$LAVA_LAB]} "
CREATE_ARGS+="--test all"
$RELENG/utils/create-jobs.py ${CREATE_ARGS} > testjob.yaml
cat testjob.yaml