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

Add support to upload artifacts to SQUAD server #497

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

liuyq
Copy link
Collaborator

@liuyq liuyq commented Feb 26, 2024

With the automated/utils/upload-to-squad.sh added and the change on the noninteractive-tradefe test as an example in this pull request. there are other tests need to be update as well after pull request.

The SQUAD url should be defined in the format like described here:
https://squad.readthedocs.io/en/latest/intro.html#submitting-results

And the job definition, SQUAD_ARCHIVE_SUBMIT_TOKEN should be defined under the secrets section.

secrets:
  SQUAD_ARCHIVE_SUBMIT_TOKEN: SQUAD_ARCHIVE_SUBMIT_TOKEN 

And SQUAD_UPLOAD_URL should be defined as one parameter like:

- test:
    ...
    definitions:
    - repository: https://github.com/Linaro/test-definitions.git
      from: git
      path: automated/android/noninteractive-tradefed/tradefed.yaml
      params:
        ...
        SQUAD_UPLOAD_URL: https://qa-reports.linaro.org/api/submit/squad_group/squad_project/squad_build/environment 
      name: cts-lkft

@bhcopeland
Copy link
Member

bhcopeland commented Feb 26, 2024

LGTM

}

while getopts ":a:u:t:vr" opt; do
case "${opt}" in
Copy link
Contributor

Choose a reason for hiding this comment

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

"t" is missing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for pointing out! will drop the "t" option here.

FAILURE_RETURN_VALUE=0

usage() {
echo "Usage: $0 [-a <attachment>] [-u <artifactorial_url>] [-t <artifactorial_token>] [-v] [-r]" 1>&2
Copy link
Contributor

Choose a reason for hiding this comment

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

"t" option is missing from the help text.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for pointing out it! will drop the "t" description from here.
The idea here is to not support passing the token to avoid the possibility of leak.

fi

if command -v lava-test-reference > /dev/null 2>&1; then
# The 'ARTIFACTORIAL_TOKEN' needs to be defined in 'secrects' dictionary in job
Copy link
Contributor

Choose a reason for hiding this comment

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

this part contradicts usage description.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will update

exit 0
else
# return is the squad testrun id
return=$(curl ${CURL_VERBOSE_FLAG} --header "Auth-Token: ${SQUAD_ARCHIVE_SUBMIT_TOKEN}" --form "attachment=@${ATTACHMENT}" "${ARTIFACTORIAL_URL}")
Copy link
Contributor

Choose a reason for hiding this comment

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

is SQUAD_ARHIVE_SUBMIT_TOKEN the same thing as ARTIFACTORIAL_TOKEN?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From function level, they could be seen as the same. but they are used for different cases, and will be in different value, so need to be defined as two variables I think.


attachmentBasename="$(basename "${ATTACHMENT}")"
if echo "${return}" | grep -E "^[0-9]+$"; then
url_uploaded="https://qa-reports.linaro.org/api/testruns/${return}/attachments/?filename=${attachmentBasename}"
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't ARTIFACTORIAL_URL be used instead of hardcoded qa-reports.linaro.org?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for the suggestion, will update to use ARTIFACTORIAL_URL to get the new url.

@liuyq
Copy link
Collaborator Author

liuyq commented Feb 26, 2024

@mwasilew just updated according to your comments/suggestions, please help check it again

Copy link
Contributor

@mwasilew mwasilew left a comment

Choose a reason for hiding this comment

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

LGTM with one minor comment. Thanks for fixing it!

if command -v lava-test-reference > /dev/null 2>&1; then
# The 'SQUAD_ARCHIVE_SUBMIT_TOKEN' needs to be defined in 'secrects' dictionary in job
# definition file, or defined in the environment, it will be used.
lava_test_dir="$(find /lava-* -maxdepth 0 -type d | grep -E '^/lava-[0-9]+' 2>/dev/null | sort | tail -1)"
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bit problematic. If there is lava_test_results_dir set in the job context, "/lava-*" might not be correct. However I've no idea how to make it work for all cases. I would suggest adding a comment to address this problem for future maintainers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the comment,

to replace the uploading to archive.vlo

Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
via specifying the SQUAD_UPLOAD_URL variables.

To be noted, to avoid leak of tokens, the SQUAD_ARCHIVE_SUBMIT_TOKEN
used to upload is not supported to be defined in the job definition
in the plain text format, it's must be defined as one profile managed
token by the submitter

Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
# 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/"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think URL can go away now that archive.vlo is dead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in case archive.vlo is recovered some time later, the current jobs would still be able to run.
leave it here for compatibility for now.

And I also have a plan to remove this URL and the following TOKEN, and the upload-to-artifactorial.sh script in a separate PR, just one concern is that not sure if there is anyone else uses this test as well, their archive server may still work.

@liuyq
Copy link
Collaborator Author

liuyq commented Feb 26, 2024

Hi, @bhcopeland @roxell @sumitsemwal
could we go ahead to have this one and the #498 one merged first now?

@bhcopeland bhcopeland merged commit 178f445 into Linaro:master Feb 26, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants