aboutsummaryrefslogtreecommitdiffstats
path: root/jjb/common/include-agl-lava-labs-prepare.sh
diff options
context:
space:
mode:
Diffstat (limited to 'jjb/common/include-agl-lava-labs-prepare.sh')
-rw-r--r--jjb/common/include-agl-lava-labs-prepare.sh75
1 files changed, 47 insertions, 28 deletions
diff --git a/jjb/common/include-agl-lava-labs-prepare.sh b/jjb/common/include-agl-lava-labs-prepare.sh
index 938dcbe6..35d3541c 100644
--- a/jjb/common/include-agl-lava-labs-prepare.sh
+++ b/jjb/common/include-agl-lava-labs-prepare.sh
@@ -10,6 +10,10 @@
#
# Strucuture: [JENKINS_LAB_NAME]="LAB_URL;JENKINS_LAB_USER;JENKINS_LAB_TOKEN;RELENG_LAB_NAME"
#
+
+# Let the script handle errors nicely
+set +e
+
declare -A labs
labs=(
[agl]="https://lava.automotivelinux.org/;$LAB_AGL_USER;$LAB_AGL_TOKEN;lab-agl-core"
@@ -17,9 +21,6 @@ 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
@@ -31,23 +32,6 @@ 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"
- [porter-nogfx]="renesas-porter;renesas-porter"
- [dra7xx-evm]="dra7-evm;dra7xx-evm"
-)
-
-OFS=${IFS}
-IFS=';'
-arr=(${agl_lava_releng_aliases[$MACHINE]})
-IFS=${OFS}
-lava_device=${arr[0]}
-releng_device=${arr[1]}
-# And agl_device=${MACHINE}
-
device_available=0
for lab in "${!labs[@]}"; do
val=${labs[$lab]}
@@ -72,7 +56,8 @@ for lab in "${!labs[@]}"; do
fi
# LAVA URL with username
- full_url=${url/:\/\//:\/\/${user}\@}
+ lava_url=${url/:\/\//:\/\/${user}\@}
+ full_url=${lava_url}
full_url+="RPC2/" # entry point for XML-RPC API
echo "LAVA auth-add for lab: $lab, URL: $full_url"
@@ -87,7 +72,9 @@ for lab in "${!labs[@]}"; do
# Find the LAVA Lab that has the device available to run the job
echo -n "Checking for $lava_device at $full_url... "
- line=$(lava-tool devices-list $full_url |grep $lava_device | tr -d '[:space:]')
+ line=$(lava-tool devices-list $full_url | grep $lava_device)
+ line=$(echo "$line" | tr -d '[:space:]')
+
if [ -z "$line" ]; then
echo "not found."
continue
@@ -97,14 +84,43 @@ for lab in "${!labs[@]}"; do
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;
+ if [ x"$device_status" = x"reserved" ]; then
+ retries=10
+ else
+ retries=1
fi
+ # If the device is reserved poll it's status every minutes.
+ # The max polling time is set to $retries * 60 seconds = 10 minutes.
+ for i in `seq 1 $retries`
+ do
+ # device is only available if "idle" or "running"
+ device_available=0
+ if [ x"$device_status" = x"reserved" ]; then
+ sleep 60s
+ # Look if the status of the board has changed from reserved in the lab
+ echo -n "Checking for $lava_device at $full_url... "
+ line=$(lava-tool devices-list $full_url | grep $lava_device)
+ line=$(echo "$line" | tr -d '[:space:]')
+
+ if [ -z "$line" ]; then
+ echo "not found."
+ continue
+ fi
+ IFS='|'
+ arr=($line)
+ device_status=${arr[2]}
+ IFS=${OFS}
+ fi
+ if [ x"$device_status" = x"idle" ]; then
+ device_available=1
+ break
+ elif [ x"$device_status" = x"running" ]; then
+ device_available=1;
+ break
+ fi
+ done
+
if [ $device_available = 0 ]; then
echo " Not Available. Status: $device_status"
continue
@@ -120,3 +136,6 @@ if [ "$device_available" -eq 0 ]; then
echo "ERROR: device not found in any available lab."
exit 0
fi
+
+# Re-enable error detection
+set -e