Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use one upload to script #499

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
13 changes: 5 additions & 8 deletions automated/android/apk-automation/apk-automation.yaml
Expand Up @@ -27,16 +27,13 @@ params:
APK_DIR: "./apks"
BASE_URL: "http://testdata.validation.linaro.org/apks/"
# Specify url and token for publishing artifacts.
ARTIFACTORIAL_URL: "https://archive.validation.linaro.org/artifacts/team/qa/"
# For safety reasons, please set 'ARTIFACTORIAL_TOKEN' variable in job definition with
# For safety reasons, please set 'ARTIFACTORIAL_TOKEN' or
# 'SQUAD_ARCHIVE_SUBMIT_TOKEN' variable in job definition with
# 'secrets' dictionary, and set job visibility to personal or group.
# Refer to https://validation.linaro.org/static/docs/v2/publishing-artifacts.html
ARTIFACTORIAL_TOKEN: ""
# The SQUAD url to be used to upload the result and log files.
# see https://squad.readthedocs.io/en/latest/intro.html#submitting-results.
# SQUAD_ARCHIVE_SUBMIT_TOKEN is used for uploading authentication,
# and must be defined by the submitter as one profile managed token
SQUAD_UPLOAD_URL: ""
UPLOAD_URL: "https://archive.validation.linaro.org/artifacts/team/qa/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to the interface change, it would be better to support all of them for a while and drop them after that period.
Like the current status, there are jobs using ARTIFACTORIAL_URL(old jobs not working at the moment) and SQUAD_UPLOAD_URL(work now), and then will submit jobs to support "UPLOAD_URL" if we have this PR merged right now, then the jobs with SQUAD_UPLOAD_URL will fail, and it needs to resubmit them again. if both SQUAD_UPLOAD_URL and UPLOAD_URL are supported here, then the current jobs will be able to run, and it's possible to submit new jobs with UPLOAD_URL as well. ARTIFACTORIAL_URL support will be the similar.


run:
steps:
Expand All @@ -45,7 +42,7 @@ run:
# Upload test output to artifactorial.
- cp "./output/${TEST_NAME}/result.txt" "./output/result.txt"
- tar caf "output-${TEST_NAME}.tar.xz" "./output"
- if [ -n "${SQUAD_UPLOAD_URL}" ]; then ../../utils/upload-to-squad.sh -a "output-${TEST_NAME}.tar.xz" -u "${SQUAD_UPLOAD_URL}"; fi
- if [ -z "${SQUAD_UPLOAD_URL}" ]; then ../../utils/upload-to-artifactorial.sh -a "output-${TEST_NAME}.tar.xz" -u "${ARTIFACTORIAL_URL}" -t "${ARTIFACTORIAL_TOKEN}"; fi
- if [ -n "${SQUAD_UPLOAD_URL}" ]; then UPLOAD_URL="${SQUAD_UPLOAD_URL}"; fi
- ../../utils/upload-artifacts.sh -a "output-${TEST_NAME}.tar.xz" -u "${UPLOAD_URL}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to support my concern, there could be done like this:

- if [ -n "${UPLOAD_URL}" ]; ../../utils/upload-artifacts.sh -a "output-${TEST_NAME}.tar.xz" -u "${UPLOAD_URL}"; fi
- if [ -n "${SQUAD_UPLOAD_URL}" ]; ../../utils/upload-artifacts.sh -a "output-${TEST_NAME}.tar.xz" -u "${SQUAD_UPLOAD_URL}"; fi

And after like several weeks or a month, drop the SQUAD_UPLOAD_URL line when no SQUAD_UPLOAD_URL jobs will be run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, to keep it around for a while. Good catch.

# Send test result to LAVA.
- ../../utils/send-to-lava.sh "./output/result.txt"
14 changes: 7 additions & 7 deletions automated/android/boottime/boottime.yaml
Expand Up @@ -31,19 +31,19 @@ params:
OPERATION: "COLLECT"
COLLECT_NO: "1"
# Specify url and token for file uploading.
URL: "https://archive.validation.linaro.org/artifacts/team/qa/"
TOKEN: ""
# For safety reasons, please set 'ARTIFACTORIAL_TOKEN' or
# 'SQUAD_ARCHIVE_SUBMIT_TOKEN' variable in job definition with
# 'secrets' dictionary, and set job visibility to personal or group.
# Refer to https://validation.linaro.org/static/docs/v2/publishing-artifacts.html
# The SQUAD url to be used to upload the result and log files.
# see https://squad.readthedocs.io/en/latest/intro.html#submitting-results.
# SQUAD_ARCHIVE_SUBMIT_TOKEN is used for uploading authentication,
# and must be defined by the submitter as one profile managed token
SQUAD_UPLOAD_URL: ""
UPLOAD_URL: "https://archive.validation.linaro.org/artifacts/team/qa/"

run:
steps:
- cd ./automated/android/boottime
- ./boottime.sh -S "${SKIP_INSTALL}" -t "${BOOT_TIMEOUT}" -o "${OPERATION}" -n "${COLLECT_NO}" -v "${ANDROID_VERSION}"
- if [ -n "${SQUAD_UPLOAD_URL}" ] && [ "${OPERATION}" = "ANALYZE" ]; then ../../utils/upload-to-squad.sh -a "output/boottime.tgz" -u "${SQUAD_UPLOAD_URL}"; fi
- if [ -z "${SQUAD_UPLOAD_URL}" ] && [ "${OPERATION}" = "ANALYZE" ]; then ../../utils/upload-to-artifactorial.sh -a "output/boottime.tgz" -u "${URL}" -t "${TOKEN}"; fi
- if [ -n "${SQUAD_UPLOAD_URL}" ]; then UPLOAD_URL="${SQUAD_UPLOAD_URL}"; fi
- ../../utils/upload-artifacts.sh -a "output/boottime.tgz" -u "${UPLOAD_URL}"
- ../../utils/send-to-lava.sh ./output/boot_result.txt
- ../../utils/send-to-lava.sh ./output/result.txt
16 changes: 8 additions & 8 deletions automated/android/noninteractive-tradefed/tradefed.yaml
Expand Up @@ -25,14 +25,14 @@ params:
TEST_PATH: "android-cts"
# Specify result format: aggregated or atomic
RESULTS_FORMAT: "aggregated"
# Specify url and token for publishing artifacts.
# For safety reasons, please set 'ARTIFACTORIAL_TOKEN' or
# 'SQUAD_ARCHIVE_SUBMIT_TOKEN' variable in job definition with
# 'secrets' dictionary, and set job visibility to personal or group.
# Refer to https://validation.linaro.org/static/docs/v2/publishing-artifacts.html
# The SQUAD url to be used to upload the result and log files.
# see https://squad.readthedocs.io/en/latest/intro.html#submitting-results.
# SQUAD_ARCHIVE_SUBMIT_TOKEN is used for uploading authentication,
# and must be defined by the submitter as one profile managed token
SQUAD_UPLOAD_URL: ""
# Specify url and token for file uploading.
URL: "https://archive.validation.linaro.org/artifacts/team/qa/"
TOKEN: ""
UPLOAD_URL: "https://archive.validation.linaro.org/artifacts/team/qa/"
AP_SSID: ""
AP_KEY: ""
# Specify the failures number to be printed
Expand Down Expand Up @@ -70,8 +70,8 @@ run:
- sudo dmesg > ./output/dmesg-host.txt || true
- if ! tar caf tradefed-output-$(date +%Y%m%d%H%M%S).tar.xz ./output; then error_fatal "tradefed - failed to collect results and log files [$ANDROID_SERIAL]"; fi
- ATTACHMENT=$(ls tradefed-output-*.tar.xz)
- if [ -n "${SQUAD_UPLOAD_URL}" ]; then ../../utils/upload-to-squad.sh -a "${ATTACHMENT}" -u "${SQUAD_UPLOAD_URL}"; fi
- if [ -z "${SQUAD_UPLOAD_URL}" ]; then ../../utils/upload-to-artifactorial.sh -a "${ATTACHMENT}" -u "${URL}" -t "${TOKEN}"; fi
- if [ -n "${SQUAD_UPLOAD_URL}" ]; then UPLOAD_URL="${SQUAD_UPLOAD_URL}"; fi
- ../../utils/upload-artifacts.sh -a "${ATTACHMENT}" -u "${UPLOAD_URL}"
# Send test result to LAVA.
- ../../utils/send-to-lava.sh ./output/result.txt
- userdel testuser -f -r || true
Expand Down
1 change: 1 addition & 0 deletions automated/utils/upload-artifacts.sh
27 changes: 18 additions & 9 deletions automated/utils/upload-to-artifactorial.sh
@@ -1,7 +1,7 @@
#!/bin/sh

ATTACHMENT=""
ARTIFACTORIAL_URL=""
URL=""
ARTIFACTORIAL_TOKEN=""
CURL_VERBOSE_FLAG=""
FAILURE_RETURN_VALUE=0
Expand All @@ -23,15 +23,15 @@ usage() {
while getopts ":a:u:t:vr" opt; do
case "${opt}" in
a) ATTACHMENT="${OPTARG}" ;;
u) ARTIFACTORIAL_URL="${OPTARG}" ;;
u) URL="${OPTARG}" ;;
t) ARTIFACTORIAL_TOKEN="${OPTARG}" ;;
v) CURL_VERBOSE_FLAG="-v" ;;
r) FAILURE_RETURN_VALUE=1 ;;
*) usage ;;
esac
done

if [ -z "${ARTIFACTORIAL_URL}" ]; then
if [ -z "${URL}" ]; then
echo "test-attachment skip"
command -v lava-test-case > /dev/null 2>&1 && lava-test-case "test-attachment" --result "skip"
exit 0
Expand All @@ -41,18 +41,27 @@ if command -v lava-test-reference > /dev/null 2>&1; then
# If 'ARTIFACTORIAL_TOKEN' defined in 'secrects' dictionary defined in job
# definition file, it will be used.
lava_test_dir="$(find /lava-* -maxdepth 0 -type d | grep -E '^/lava-[0-9]+' 2>/dev/null | sort | tail -1)"
if test -f "${lava_test_dir}/secrets" && grep -q "ARTIFACTORIAL_TOKEN" "${lava_test_dir}/secrets"; then
if test -f "${lava_test_dir}/secrets" && grep -q "_TOKEN" "${lava_test_dir}/secrets"; then
# shellcheck disable=SC1090
. "${lava_test_dir}/secrets"
fi

if [ -z "${ARTIFACTORIAL_TOKEN}" ]; then
echo "WARNING: ARTIFACTORIAL_TOKEN is empty! File uploading skipped."
if [ -n "${ARTIFACTORIAL_TOKEN}" ]; then
return=$(curl ${CURL_VERBOSE_FLAG} -F "path=@${ATTACHMENT}" -F "token=${ARTIFACTORIAL_TOKEN}" "${URL}")
elif [ -n "${SQUAD_ARCHIVE_SUBMIT_TOKEN}" ]; then
squad_testrun_id=$(curl ${CURL_VERBOSE_FLAG} --header "Auth-Token: ${SQUAD_ARCHIVE_SUBMIT_TOKEN}" --form "attachment=@${ATTACHMENT}" "${URL}")
# URL will be in the format like this:
# https://qa-reports.linaro.org/api/submit/squad_group/squad_project/squad_build/environment
url_squad=$(echo "${URL}"|sed 's|/api/submit/.*||')
return="${url_squad}/api/testruns/${squad_testrun_id}/attachments/?filename=${attachmentBasename}"
if ! echo "${return}" | grep -E "^[0-9]+$"; then
return="${squad_testrun_id}"
fi
else
echo "WARNING: ARTIFACTORIAL_TOKEN or SQUAD_ARCHIVE_SUBMIT_TOKEN is empty! File uploading skipped."
echo "test-attachment skip"
command -v lava-test-case > /dev/null 2>&1 && lava-test-case "test-attachment" --result "skip"
exit 0
else
return=$(curl ${CURL_VERBOSE_FLAG} -F "path=@${ATTACHMENT}" -F "token=${ARTIFACTORIAL_TOKEN}" "${ARTIFACTORIAL_URL}")
fi

attachmentBasename="$(basename "${ATTACHMENT}")"
Expand All @@ -61,7 +70,7 @@ if command -v lava-test-reference > /dev/null 2>&1; then
else
echo "test-attachment fail"
echo "Expected the basename of the attachment file (\"${attachmentBasename}\") to be part \
of the Artifactorial URL, but curl returned \"${return}\"."
of the ${URL}, but curl returned \"${return}\"."
command -v lava-test-case > /dev/null 2>&1 && lava-test-case "test-attachment" --result "fail"
exit "${FAILURE_RETURN_VALUE}"
fi
Expand Down
74 changes: 0 additions & 74 deletions automated/utils/upload-to-squad.sh

This file was deleted.