canonical-hw-cert team mailing list archive
-
canonical-hw-cert team
-
Mailing list archive
-
Message #85914
[Merge] hwcert-jenkins-jobs:riverside into hwcert-jenkins-jobs:master
Rémy MARTIN has proposed merging hwcert-jenkins-jobs:riverside into hwcert-jenkins-jobs:master.
Commit message:
First version of Riverside checkbox automation running in the cert lab (edited)
Requested reviews:
hwcert-jenkins (hwcert-jenkins)
For more details, see:
https://code.launchpad.net/~hwcert-jenkins/hwcert-jenkins-jobs/+git/hwcert-jenkins-jobs/+merge/439306
Adapted from Kivu job, tested partially locally. There are still a few things that needs to be fine tuned, like a way to run sudo commands on the target. Currently I am visudoing a /etc/sudoers.d/checkbox file with "ubuntu ALL=(ALL:ALL) NOPASSWD: ALL", but it's not very elegant.
--
Your team hwcert-jenkins is requested to review the proposed merge of hwcert-jenkins-jobs:riverside into hwcert-jenkins-jobs:master.
diff --git a/jobs/riverside/checkbox.conf b/jobs/riverside/checkbox.conf
new file mode 100644
index 0000000..c0dd444
--- /dev/null
+++ b/jobs/riverside/checkbox.conf
@@ -0,0 +1,22 @@
+# Please keep the indents below, for yaml formatting/templating
+ [launcher]
+ launcher_version = 1
+ app_id = com.canonical.certification:riverside-test
+ stock_reports = text, submission_files, certification
+
+ [test plan]
+ unit = com.canonical.qa.riverside::riverside-classic-automated
+ forced = yes
+
+ [test selection]
+ forced = yes
+
+ [ui]
+ type = silent
+
+ [transport:c3]
+ secure_id = \$HEXR_DEVICE_SECURE_ID
+
+ [manifest]
+ com.canonical.certification::has_hardware_watchdog = true
+ com.canonical.certification::has_ethernet_adapter = true
diff --git a/jobs/riverside/projects/jetson-agx-orin.yaml b/jobs/riverside/projects/jetson-agx-orin.yaml
new file mode 100644
index 0000000..8119946
--- /dev/null
+++ b/jobs/riverside/projects/jetson-agx-orin.yaml
@@ -0,0 +1,5 @@
+- project:
+ name: jetson-agx-orin
+ queue: 202211-30841
+ jobs:
+ - '{prefix}-riverside-{name}':
diff --git a/jobs/riverside/riverside-template.yaml b/jobs/riverside/riverside-template.yaml
new file mode 100644
index 0000000..bc0dce0
--- /dev/null
+++ b/jobs/riverside/riverside-template.yaml
@@ -0,0 +1,33 @@
+- job-template:
+ name: '{prefix}-riverside-{name}'
+ email: 'remy.martin@xxxxxxxxxxxxx'
+ project-type: freestyle
+ description: |
+ Run Riverside tests
+ triggers:
+ - timed: # Every Monday, Wednesday, Friday
+ 'H H * * 1,3,5'
+ 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-riverside.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
diff --git a/jobs/riverside/run-riverside.sh b/jobs/riverside/run-riverside.sh
new file mode 100755
index 0000000..fb7ba50
--- /dev/null
+++ b/jobs/riverside/run-riverside.sh
@@ -0,0 +1,106 @@
+#!/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_username: ubuntu
+ test_password: ubuntu
+ test_cmds: |
+ set -x
+
+ #!/bin/bash
+ SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
+ _put() {{
+ scp \$SSH_OPTS \$1 ubuntu@\$DEVICE_IP:\$2
+ }}
+ _get() {{
+ scp \$SSH_OPTS ubuntu@\$DEVICE_IP:\$1 \$2
+ }}
+ _run() {{
+ ssh -t \$SSH_OPTS ubuntu@\$DEVICE_IP "\$@"
+ }}
+
+ ## Launcher file
+ cat <<EOF > launcher
+ #!/usr/bin/env checkbox-cli
+ {checkbox_conf}
+ 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'))"
+ export DESCRIPTION="Riverside tests\nJenkins URL: $BUILD_URL"
+ # Add the description to the launcher
+ python3 -c "import configparser;c=configparser.ConfigParser(delimiters=('=',));c.optionxform=str;c.read('checkbox-launcher');c['launcher']['session_desc']='\$DESCRIPTION';c.write(open('checkbox-launcher','wt'))"
+
+ mkdir -p artifacts
+ cp checkbox-launcher artifacts
+
+ echo "preparing the system..."
+ _run sudo snap install checkbox20
+ _run sudo snap install --channel latest/edge checkbox-riverside-classic --classic
+
+ 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
+
+ # cleanup (do not remove everything because some package can be already here ..)
+ _run sudo snap remove checkbox-riverside-classic
+ _run sudo snap remove checkbox20
+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)
+
+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
+cat artifacts/raw_summary >> artifacts/summary
+echo >> artifacts/summary
+
+echo "Test exit status: $TEST_STATUS"
+exit $TEST_STATUS
Follow ups