[gnome-build-meta/sthursfield/james/openqa-master] openqa: Set pipefail and add API logging



commit ad9b7eee759fc26e653003dd72e6cdf107605c77
Author: Sam Thursfield <sam afuera me uk>
Date:   Mon Aug 9 15:43:55 2021 +0200

    openqa: Set pipefail and add API logging
    
    When things don't work, we of course need a log.
    
    Set pipefail so if the CLI fails, the script exits with failure.

 .gitlab-ci.yml                  | 1 +
 openqa/utils/setup_worker.sh    | 3 ++-
 openqa/utils/start_job.sh       | 3 ++-
 openqa/utils/teardown_worker.sh | 3 ++-
 openqa/utils/wait_for_job.sh    | 2 +-
 5 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d50c54a6..2f9b3e4a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -447,6 +447,7 @@ test-iso-installer-x86_64:
   artifacts:
     when: always
     paths:
+    - openqa.log
     - worker.log
     expire_in: '1 week'
   tags:
diff --git a/openqa/utils/setup_worker.sh b/openqa/utils/setup_worker.sh
index 65c5d8b1..9619ba35 100755
--- a/openqa/utils/setup_worker.sh
+++ b/openqa/utils/setup_worker.sh
@@ -5,6 +5,7 @@
 # On success, write the machine ID returned by server to stdout.
 
 set -eu
+set -o pipefail
 
 # Unique identifier for this machine, so we can tell the server to schedule
 # tests here.
@@ -31,4 +32,4 @@ openqa-cli api --apikey $OPENQA_API_KEY --apisecret $OPENQA_API_SECRET \
   settings[QEMUVGA]=virtio \
   settings[UEFI]=1 \
   settings[UEFI_PFLASH_CODE]=/usr/share/qemu/ovmf-x86_64-code.bin \
-  settings[WORKER_CLASS]=$worker_class | jq .id > /tmp/machine_id
+  settings[WORKER_CLASS]=$worker_class | tee --append openqa.log | jq .id > /tmp/machine_id
diff --git a/openqa/utils/start_job.sh b/openqa/utils/start_job.sh
index 0bb97eb7..79f5937f 100755
--- a/openqa/utils/start_job.sh
+++ b/openqa/utils/start_job.sh
@@ -5,6 +5,7 @@
 # On success, write the job ID returned by server to stdout.
 
 set -eu
+set -o pipefail
 
 worker_class=$1
 version=$2
@@ -19,4 +20,4 @@ openqa-cli api --apikey $OPENQA_API_KEY --apisecret $OPENQA_API_SECRET \
   ARCH=x86_64 \
   WORKER_CLASS=$worker_class \
   CASEDIR=$(pwd)/openqa \
-  NEEDLES_DIR=$OPENQA_NEEDLES_GIT#$OPENQA_NEEDLES_SHA | jq .ids[0]
+  NEEDLES_DIR=$OPENQA_NEEDLES_GIT#$OPENQA_NEEDLES_SHA | tee --append openqa.log | jq .ids[0]
diff --git a/openqa/utils/teardown_worker.sh b/openqa/utils/teardown_worker.sh
index 95870e5a..274555a8 100755
--- a/openqa/utils/teardown_worker.sh
+++ b/openqa/utils/teardown_worker.sh
@@ -3,8 +3,9 @@
 # Delete machine on $OPENQA_HOST.
 
 set -eu
+set -o pipefail
 
 machine_id=$1
 
 openqa-cli api --apikey $OPENQA_API_KEY --apisecret $OPENQA_API_SECRET \
-    --host $OPENQA_HOST -X DELETE machines/${machine_id}
+    --host $OPENQA_HOST -X DELETE machines/${machine_id} | tee --append openqa.log
diff --git a/openqa/utils/wait_for_job.sh b/openqa/utils/wait_for_job.sh
index d4046e3f..476096b7 100755
--- a/openqa/utils/wait_for_job.sh
+++ b/openqa/utils/wait_for_job.sh
@@ -19,7 +19,7 @@ state=$(job_check | jq .job.state)
 while [ "$state" != "\"done\"" ]; do sleep 10 && state=$(job_check | jq .job.state); done
 echo >&2 "Tests finished"
 
-result=$(job_check | jq .job.result)
+result=$(job_check | tee --append openqa.log | jq .job.result)
 if [ "$result" != "\"passed\"" ]; then
   echo >&2 "Test job ${job_id} *FAILED*"
   echo 1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]