canonical-hw-cert team mailing list archive
-
canonical-hw-cert team
-
Mailing list archive
-
Message #25418
[Merge] ~pgentili/hwcert-jenkins-jobs:zapper-jenkins into hwcert-jenkins-jobs:master
Paolo Gentili has proposed merging ~pgentili/hwcert-jenkins-jobs:zapper-jenkins into hwcert-jenkins-jobs:master.
Commit message:
Add: template and first project running zapper-enabled tests
Requested reviews:
Paul Larson (pwlars)
For more details, see:
https://code.launchpad.net/~pgentili/hwcert-jenkins-jobs/+git/hwcert-jenkins-jobs/+merge/430767
https://warthogs.atlassian.net/browse/ZAP-211
Added a job for testing devices using Zapper in companion mode.
--
Your team hwcert-jenkins is subscribed to branch hwcert-jenkins-jobs:master.
diff --git a/jobs/zapper/checkbox.conf b/jobs/zapper/checkbox.conf
new file mode 100644
index 0000000..a25d7e4
--- /dev/null
+++ b/jobs/zapper/checkbox.conf
@@ -0,0 +1,18 @@
+# Please keep the indents below, for yaml formatting/templating
+ [launcher]
+ launcher_version = 1
+ app_id = com.canonical.certification:zapper-test
+ stock_reports = text, submission_files
+
+ [test plan]
+ unit = com.canonical.certification::zapper-enabled-full
+ forced = yes
+
+ [test selection]
+ forced = yes
+
+ [ui]
+ type = silent
+
+ [transport:c3]
+ secure_id = \$HEXR_DEVICE_SECURE_ID
diff --git a/jobs/zapper/projects/zapper-202203-30003.yaml b/jobs/zapper/projects/zapper-202203-30003.yaml
new file mode 100644
index 0000000..4cf2493
--- /dev/null
+++ b/jobs/zapper/projects/zapper-202203-30003.yaml
@@ -0,0 +1,6 @@
+- project:
+ name: hp-probook-440-g9
+ queue: 202203-30003
+ zapper_ip: 10.102.156.230
+ jobs:
+ - '{prefix}-zapper-{name}':
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}
+ 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 \;
+ 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
diff --git a/jobs/zapper/zapper-template.yaml b/jobs/zapper/zapper-template.yaml
new file mode 100644
index 0000000..0c64503
--- /dev/null
+++ b/jobs/zapper/zapper-template.yaml
@@ -0,0 +1,32 @@
+- job-template:
+ name: '{prefix}-zapper-{name}'
+ email: 'paolo.gentili@xxxxxxxxxxxxx'
+ project-type: freestyle
+ description: |
+ Run Zapper-enabled tests
+ triggers:
+ - timed: '@daily'
+ wrappers:
+ - timeout:
+ timeout: 400
+ fail: true
+ - ssh-agent-credentials:
+ users:
+ - 'ssh-ce-certification-qa'
+ checkbox_conf:
+ !include-raw-escape: checkbox.conf
+ builders:
+ - shell:
+ !include-raw: run-zapper.sh
+ publishers:
+ - post-tasks:
+ - matches:
+ - log-text: "Build timed out"
+ operator: OR
+ - log-text: "Build was aborted"
+ operator: OR
+ script: |
+ testflinger cancel $(cat JOB_ID)
+ - archive:
+ artifacts: 'artifacts/*'
+ allow-empty: true
Follow ups