diff options
author | 2019-04-02 10:49:17 +0200 | |
---|---|---|
committer | 2019-04-29 16:33:51 +0200 | |
commit | 00a7f42b60833d481f6476fee453c1192a395a0b (patch) | |
tree | 1ad6df6399dbcaf6fb89224724ec2d8bf0ff5007 /jjb/common/include-agl-lava-jobs-submit.sh | |
parent | 3d2d6114b0dda535e5515d2e083d8e59f821b93a (diff) |
Replace lava-tool with lavacli
In order to move totally to lavacli, this patch:
- Apply changes to submit jobs using lavacli. As the blocking call
(--block) no longer exists with lavacli, so had to replace that with
a polling loop.
- Replace lava-tool with lavacli in the polling part in the labs-prepare
file, which checks the device status and availability.
Different changes tested at Baylibre.
Change-Id: I25b1ad4b47ae09a158e1e1cf42e30da5e6aa8b57
Signed-off-by: Khouloud Touil <ktouil@baylibre.com>
Diffstat (limited to 'jjb/common/include-agl-lava-jobs-submit.sh')
-rw-r--r-- | jjb/common/include-agl-lava-jobs-submit.sh | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/jjb/common/include-agl-lava-jobs-submit.sh b/jjb/common/include-agl-lava-jobs-submit.sh index 22dc0c3b..30f11ee3 100644 --- a/jjb/common/include-agl-lava-jobs-submit.sh +++ b/jjb/common/include-agl-lava-jobs-submit.sh @@ -20,24 +20,48 @@ cat $JOB_FILE | sed "s/device_type: $releng_device$/device_type: $lava_device/" # LAVA job submit, get job ID from lava-tool output # JOB_STATUS="${JOB_BASE}_${LAVA_LAB}.status" -lava-tool submit-job --block $full_url $JOB_FILE_NEW |tee $JOB_STATUS + +job_id=$(lavacli -i $lab jobs submit $JOB_FILE_NEW) +if [ $? -ne 0 ]; then + echo "ERROR: job submission error" + exit 1 +fi # 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/') +echo "THe job id is: ${job_id}" +JOB_URL="${url}scheduler/job/${job_id}" +echo "Submitted as job: $JOB_URL" # -# LAVA job details, get job status from lava-tool output +# LAVA job details, get job status from lavacli output # -lava-tool job-details $full_url $job_id | tee $JOB_STATUS - -IFS=':' -line=$(grep "^status:" $JOB_STATUS) -line=$(echo "$line" | tr -d '[:space:]') -arr=($line) -status=${arr[1]} -IFS=${OFS} +# There is no version of blocking call (--block) for lavacli +# If the job didn't finish after JOB_TIMEOUT, will exit and display +# an error message +# example: lava-slave crash +if [ -z $JOB_TIMEOUT ] + # if the JOB_TIMEOUT is not set, it's 1 hour by default + JOB_TIMEOUT=360 +fi -echo "LAVA job $job_id completed with status: $status" +for i in $(seq 1 $JOB_TIMEOUT); do + lavacli -i $lab jobs show $job_id --yaml > $JOB_STATUS + if [ $? -ne 0 ];then + # be patient in case of a temporary error + sleep 10 + continue + fi + state=$(grep ^state: $JOB_STATUS| cut -d' ' -f2) + if [ $state == "Finished" ]; then + status=$(grep ^Health: $JOB_STATUS| cut -d' ' -f2) + echo "LAVA job $job_id completed with status: $status" + break + fi + sleep 10 +done +if [ $i -ge $JOB_TIMEOUT ];then + echo "ERROR: job did not finished before 1 hour" + exit 1 +fi echo "####" echo "#### Start: Output from LAVA job $job_id ####" |