ci-platform-jjb: CIBT: add support for multiple LAVA labs 79/9479/3
authorKevin Hilman <khilman@baylibre.com>
Mon, 22 May 2017 22:43:03 +0000 (22:43 +0000)
committerKevin Hilman <khilman@baylibre.com>
Mon, 22 May 2017 23:00:02 +0000 (23:00 +0000)
Currently, support for boot testing using LAVA is hard-coded to a
single LAVA lab (in include-agl-run-test-short.sh)

Add an additional step/script for preparing the authentication
environment for multiple LAVA labs.

Once validated, the LAVA support can be removed from the
"run-test-short" script.

Change-Id: I5faa12b5234369d63ad392ec8dc47a5542856c5a
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
jjb/ci-AGL-verify/ci-platform-jjb.yaml
jjb/common/include-agl-lava-labs-prepare.sh [new file with mode: 0644]

index 54265ab..e391282 100644 (file)
           - ../common/include-agl-repo.sh
           - ../common/include-agl-select.sh
           - ../common/include-agl-run-test-prepare.sh
+          - ../common/include-agl-lava-labs-prepare.sh
           - ../common/include-agl-run-test-short.sh
 
     publishers:
diff --git a/jjb/common/include-agl-lava-labs-prepare.sh b/jjb/common/include-agl-lava-labs-prepare.sh
new file mode 100644 (file)
index 0000000..876127c
--- /dev/null
@@ -0,0 +1,59 @@
+# (c) 2017 Kevin Hilman <khilman@baylibre.com>
+# License GPLv2
+
+#
+# Setup LAVA API authentication tokens for various LAVA labs
+#
+# Uses user/token pairs from Jenkins secrets
+#
+declare -A labs
+labs=(
+    [agl]="https://porter.automotivelinux.org/;$LAB_AGL_USER;$LAB_AGL_TOKEN"
+    [baylibre]="http://lava.baylibre.com:10080/;$LAB_BAYLIBRE_USER;$LAB_BAYLIBRE_TOKEN"
+    [baylibre_seattle]="http://lava.ished.com/;$LAB_BAYLIBRE_SEATTLE_USER;$LAB_BAYLIBRE_SEATTLE_TOKEN"
+    )
+
+#
+# Ensure python_keyring is set to plaintext.  Required for
+# non-interactive use
+#
+echo "default keyring config"
+mkdir -p ~/.local/share/python_keyring/
+cat <<EOF >  ~/.local/share/python_keyring/keyringrc.cfg
+[backend]
+default-keyring=keyring.backends.file.PlaintextKeyring
+EOF
+
+for lab in "${!labs[@]}"; do
+    val=${labs[$lab]}
+    OFS=${IFS}
+    IFS=';'
+    arr=(${labs[$lab]})
+    IFS=${OFS}
+
+    url=${arr[0]}
+    user=${arr[1]}
+    token=${arr[2]}
+    token_file=$HOME/.local/lab-$lab-token
+
+    if [ -z ${user} ]; then
+       echo "WARNING: Lab ${lab}: missing user. Ignoring."
+       continue
+    fi
+    if [ -z ${token} ]; then
+       echo "WARNING: Lab ${lab}: missing token. Ignoring."
+       continue
+    fi
+
+    # 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
+    if [ $? != 0 ]; then
+       echo "ERROR: Lab ${lab}: lava-tool auth-add failed."
+    fi
+    rm -f $token_file
+done