canonical-hw-cert team mailing list archive
-
canonical-hw-cert team
-
Mailing list archive
-
Message #25642
Re: [Merge] ~pgentili/hwcert-jenkins-jobs:zapper-jenkins into hwcert-jenkins-jobs:master
Review: Needs Fixing
I think the changes mentioned below should get this into a state where it can work. Let's start with that and then improve it from there if needed.
Diff comments:
> diff --git a/jobs/zapper/run-zapper.sh b/jobs/zapper/run-zapper.sh
> new file mode 100644
> index 0000000..dc77605
> --- /dev/null
> +++ b/jobs/zapper/run-zapper.sh
> @@ -0,0 +1,104 @@
> +#!/bin/bash
> +set +e
> +set -x
> +
> +[ "{no_run}" = "True" ] && exit
> +
> +cat > job.yaml <<EOF
> + job_queue: {queue}
> + global_timeout: 18000
> + output_timeout: 1200
> + test_data:
> + {test_data}
> + test_cmds: |
> + set -x
> +
> + #!/bin/bash
> + SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
> + _put() {{{{
> + scp \$SSH_OPTS \$1 {user}@\$DEVICE_IP:\$2
> + }}}}
> + _get() {{{{
> + scp \$SSH_OPTS {user}@\$DEVICE_IP:\$1 \$2
> + }}}}
> + _run() {{{{
> + ssh -t \$SSH_OPTS {user}@\$DEVICE_IP "\$@"
> + }}}}
> +
> + ## Launcher file
> + cat <<EOF > launcher
> + #!/usr/bin/env checkbox-cli
> + {checkbox_conf}
> + [environment]
> + ZAPPER_HOST = {zapper_ip}
For systems connected to a zapper, this should be part of the device config. Similar to how we do the control_host for sdwire/muxpi. If it's something that needs to be used during the tests (not just by the device agent) then it should be exposed in the environment settings of the device config.
If we try to do it in the templates, then this will get unmanageable once we have >1 device with a zapper connected to it.
> + EOF
> +
> + # Merge the launcher we downloaded with checkbox.conf
> + python3 -c "import configparser;c=configparser.ConfigParser(delimiters=('=',));c.optionxform=str;c.read('launcher');c.write(open('checkbox-launcher','wt'))"
> +
> + mkdir -p artifacts
> + cp checkbox-launcher artifacts
> +
> + #ensure that there's RPyC 5.x installed, so Zapper Proxy can use it
> + echo "preparing the system..."
> + _run sudo apt-get -qq update
> + _run sudo apt-get -qq install -y python3-pip
> + _run sudo pip3 install rpyc==5.0.0
> +
> + echo Starting
> + # DISPLAY=:0 to make sure graphic test jobs were tested expectedly (not necessary in remote)
> + PYTHONUNBUFFERED=1 checkbox-cli remote \$DEVICE_IP checkbox-launcher
> + EXITCODE=\$?
> +
> + # will be downloaded over testflinger-cli artifacts later
> + mkdir -p artifacts
> +
> + find /home/ubuntu/ -name 'submission_*.junit.xml' -exec mv {} artifacts/junit.xml \;
> + find /home/ubuntu/ -name 'submission_*.html' -exec mv {} artifacts/submission.html \;
> + find /home/ubuntu/ -name 'submission_*.tar.xz' -exec mv {} artifacts/submission.tar.xz \;
I know this seems weird, but there are several things along the path that try to apply python string.format(). So the {} here will have to be {{{{}}}} to work properly, or else it won't even process this in jjb
> + tar -xf artifacts/submission.tar.xz submission.json
> + mv submission.json artifacts
> + echo "Files in artifacts:"
> + ls artifacts
> +EOF
> +
> +#Remove previous venv
> +rm -rf env
> +cat <<EOF >build-env.sh
> +{build_env}
> +EOF
> +. build-env.sh
> +
> +git -C hwcert-jenkins-tools pull -q || (rm -rf hwcert-jenkins-tools && git clone -q https://git.launchpad.net/hwcert-jenkins-tools)
> +git -C hwcert-data pull -q || git clone -q git+ssh://ce-certification-qa@xxxxxxxxxxxxxxxxx/~canonical-hw-cert/hwcert-jenkins-jobs/+git/hwcert-data
> +
> +JOB_ID=$(testflinger submit -q job.yaml)
> +echo "JOB_ID: ${{JOB_ID}}"
> +echo "${{JOB_ID}}" > JOB_ID
> +testflinger poll ${{JOB_ID}}
> +
> +TEST_STATUS=$(testflinger results ${{JOB_ID}} |jq -r .test_status)
> +
> +rm -rf artifacts*
> +#retry getting the artifacts after a delay if it fails
> +testflinger artifacts ${{JOB_ID}} || (sleep 30 && testflinger artifacts ${{JOB_ID}})
> +tar -xzf artifacts.tgz
> +
> +set +x
> +if C3LINK=$(testflinger results ${{JOB_ID}} |jq -r .test_output|grep -a certification.canonical.com/submissions/status); then
> + echo "Found successful C3 submission link"
> +else
> + C3LINK="Failed to find C3 submission link"
> +fi
> +export C3LINK
> +echo $C3LINK > c3link
> +set -x
> +
> +mkdir -p artifacts
> +echo Jenkins build details: ${{BUILD_URL}} > artifacts/summary
> +hwcert-jenkins-tools/revcache-job-summary -f hwcert-data/known-test-fails.yaml artifacts/submission.json $JOB_NAME > artifacts/raw_summary
> +cat artifacts/raw_summary >> artifacts/summary
> +echo >> artifacts/summary
> +
> +echo "Test exit status: ${{TEST_STATUS}}"
> +exit $TEST_STATUS
--
https://code.launchpad.net/~pgentili/hwcert-jenkins-jobs/+git/hwcert-jenkins-jobs/+merge/430767
Your team hwcert-jenkins is subscribed to branch hwcert-jenkins-jobs:master.
References