Merge ~kzapalowicz/snappy-hwe-snaps/+git/jenkins-jobs:feature/make-test-snap-in-sync into ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master
- Git
- lp:~kzapalowicz/snappy-hwe-snaps/+git/jenkins-jobs
- feature/make-test-snap-in-sync
- Merge into master
Status: | Merged |
---|---|
Approved by: | Simon Fels |
Approved revision: | a6b1ab3f8a42607a69ac967d32ab9915373e244e |
Merged at revision: | 1037f2f9948cba85d23f323c1f1b1ac65e7617ed |
Proposed branch: | ~kzapalowicz/snappy-hwe-snaps/+git/jenkins-jobs:feature/make-test-snap-in-sync |
Merge into: | ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master |
Diff against target: |
188 lines (+154/-2) 3 files modified
jobs/snap/snap-test-on-hw.sh (+149/-0) jobs/snap/snap-test.sh (+2/-2) jobs/snap/snap-test.yaml (+3/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Simon Fels | Approve | ||
System Enablement Bot | continuous-integration | Approve | |
Alfonso Sanchez-Beato | Approve | ||
Review via email: mp+328352@code.launchpad.net |
Commit message
Description of the change
jobs/snap: add hardware testing to the test job
This is based on
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
I think it would be good to add to the description and the commit message a link to the original sources for snap-test-on-hw.sh
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:5d262b6542b
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Simon Fels (morphis) : | # |
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Please see comments below, especially the one about yaml format.
Also, I do not think this should be a separate job. In build-scripts there was a function, set_test_type(), which checked if there were tests defined for real hardware, and in the test job this was checked and real HW tests where run if appropriate. We should do something similar so this gets run by the snap-test.sh job if appropriate. I would also keep the original structure as a function called run_hardware_
Finally, this should be tested using the alsa-utils snap, preferably before merging if possible (we can merge and check after if there is no easy way).
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:ea3b0280e4c
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:1d0cc2005bb
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:0ab0583a7a6
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Simon Fels (morphis) wrote : | # |
Three comments inline otherwise looks good.
Konrad Zapałowicz (kzapalowicz) wrote : | # |
one answer
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:4d7441e425c
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Thanks for the changes, just one minor request.
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:81fe8eac832
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:66f1e40dcd0
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
I just noticed that this recent commit needs to be ported back to this MP:
Also, should now tools/hardware-
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:e2204d18a73
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Simon Fels (morphis) : | # |
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
LGTM
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:a6b1ab3f8a4
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | diff --git a/jobs/snap/snap-test-on-hw.sh b/jobs/snap/snap-test-on-hw.sh |
2 | new file mode 100644 |
3 | index 0000000..66ce757 |
4 | --- /dev/null |
5 | +++ b/jobs/snap/snap-test-on-hw.sh |
6 | @@ -0,0 +1,149 @@ |
7 | +#!/bin/sh |
8 | +# |
9 | +# Copyright (C) 2017 Canonical Ltd |
10 | +# |
11 | +# This program is free software: you can redistribute it and/or modify |
12 | +# it under the terms of the GNU General Public License version 3 as |
13 | +# published by the Free Software Foundation. |
14 | +# |
15 | +# This program is distributed in the hope that it will be useful, |
16 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | +# GNU General Public License for more details. |
19 | +# |
20 | +# You should have received a copy of the GNU General Public License |
21 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | + |
23 | +set -ex |
24 | + |
25 | +. "$WORKSPACE/.build_env" |
26 | + |
27 | +SSH_PATH="${JENKINS_HOME}/.ssh/" |
28 | +SSH_KEY_PATH="${SSH_PATH}/git.launchpad.net/${BOT_USERNAME}" |
29 | + |
30 | +SSH="ssh -i $SSH_KEY_PATH/id_rsa $REMOTE_USER@$REMOTE_WORKER" |
31 | +SCP="scp -i $SSH_KEY_PATH/id_rsa" |
32 | + |
33 | +REPO=https://git.launchpad.net/~${LAUNCHPAD_TEAM}/${LAUNCHPAD_PROJECT}/+git/$CI_REPO |
34 | +BRANCH=$CI_BRANCH |
35 | + |
36 | +# If no CI repo/branch is set fallback to the source repo/branch set |
37 | +# which will be the case for those repositories which don't contain |
38 | +# a snap. |
39 | +if [ -z "$CI_REPO" ]; then |
40 | + REPO=$SOURCE_GIT_REPO |
41 | + BRANCH=$SOURCE_GIT_REPO_BRANCH |
42 | +fi |
43 | + |
44 | +REMOTE_WORKSPACE=/home/$REMOTE_USER/$BUILD_TAG |
45 | +REMOTE_RESULTS_BASE_DIR=/home/$REMOTE_USER/results |
46 | + |
47 | +tmp_srcdir=$(mktemp -d) |
48 | +git clone --depth 1 -b $SOURCE_GIT_REPO_BRANCH $SOURCE_GIT_REPO $tmp_srcdir/src |
49 | +cd $tmp_srcdir |
50 | + |
51 | +if ! grep -q "type: adhoc" src/spread.yaml; then |
52 | + echo "INFO: testing on hardware is disabled" |
53 | + rm -rf $tmp_srcdir |
54 | + exit 0 |
55 | +fi |
56 | + |
57 | +TEST_TYPE=none |
58 | +if [ -e "src/spread.yaml" ]; then |
59 | + TEST_TYPE=spread |
60 | +fi |
61 | +if [ -e "src/run-tests.sh" ]; then |
62 | + TEST_TYPE=script |
63 | +fi |
64 | + |
65 | +TEST_RESULTS=test_results |
66 | + |
67 | +# Just dragonboard for the moment |
68 | +TEST_SPEC=testflinger-dragonboard.yaml |
69 | + |
70 | +# We use jq to process testflinger output |
71 | +if ! which jq; then |
72 | + sudo apt install --yes jq |
73 | +fi |
74 | + |
75 | +# Initially the device has a password-less ubuntu user. But spread needs a |
76 | +# user with a password, so we use the DEVICE_USER/DEVICE_PASSWORD pair to |
77 | +# create it. Note: {device_ip} gets substituted by testflinger. |
78 | +DEVICE_USER=test |
79 | +DEVICE_PASSWORD=test |
80 | +DEVICE_SSH="ssh -q -o UserKnownHostsFile=/dev/null |
81 | + -o StrictHostKeyChecking=no -p 22 ubuntu@{device_ip}" |
82 | + |
83 | +if [ "$TEST_TYPE" = script ]; then |
84 | +TEST_COMMAND="./run-tests.sh --spread-system=hw-ubuntu-core-16 |
85 | + --external-address={device_ip}:22 --external-user=$DEVICE_USER |
86 | + --external-password=$DEVICE_PASSWORD --debug" |
87 | +else |
88 | +TEST_COMMAND="export SPREAD_EXTERNAL_ADDRESS={device_ip}:22 && |
89 | + export SPREAD_EXTERNAL_USER=$DEVICE_USER && |
90 | + export SPREAD_EXTERNAL_PASSWORD=$DEVICE_PASSWORD && |
91 | + ./spread -vv external:hw-ubuntu-core-16" |
92 | +fi |
93 | + |
94 | +# Run testflinger from our bare metal server so we can install it |
95 | + |
96 | +$SSH mkdir -p "$REMOTE_WORKSPACE" |
97 | + |
98 | +# If the snap has been built, copy over |
99 | +if [ -n "$RESULTS_ID" ]; then |
100 | + set +x |
101 | + # We need to flatten the key here to avoid issues with yaml parsing |
102 | + SSH_KEY_DATA=$(tr '\n:' '?!' < "$SSH_KEY_PATH"/id_rsa) |
103 | + set -x |
104 | +fi |
105 | + |
106 | +cat << EOF > "$WORKSPACE"/"$TEST_SPEC" |
107 | +job_queue: dragonboard |
108 | +provision_data: |
109 | + channel: stable |
110 | +test_data: |
111 | + test_cmds: |
112 | + - sudo apt update |
113 | + - sudo apt install --yes git curl |
114 | + - git clone --depth 1 -b $BRANCH $REPO src |
115 | + - cd src && curl -s -O https://niemeyer.s3.amazonaws.com/spread-amd64.tar.gz && tar xzvf spread-amd64.tar.gz |
116 | + - $DEVICE_SSH "sudo adduser --extrausers --quiet --disabled-password --gecos '' $DEVICE_USER" |
117 | + - $DEVICE_SSH "echo $DEVICE_USER:$DEVICE_PASSWORD | sudo chpasswd" |
118 | + - $DEVICE_SSH "echo '$DEVICE_USER ALL=(ALL) NOPASSWD:ALL' | sudo tee /etc/sudoers.d/create-user-test" |
119 | + - if [ -n $RESULTS_ID ]; then set +x; echo "$SSH_KEY_DATA" | tr '?!' '\n:' > ssh_key; set -x; chmod 600 ssh_key; scp -i ssh_key $REMOTE_USER@$REMOTE_WORKER:$REMOTE_RESULTS_BASE_DIR/$RESULTS_ID/*.snap src/; fi |
120 | + - cd src && export PATH=$PATH:\$(pwd) && $TEST_COMMAND |
121 | +EOF |
122 | + |
123 | +$SCP "$WORKSPACE"/"$TEST_SPEC" "$REMOTE_USER"@"$REMOTE_WORKER":"$REMOTE_WORKSPACE"/ |
124 | + |
125 | +$SSH << EOF |
126 | +#!/bin/sh |
127 | +set -ex |
128 | + |
129 | +cd $REMOTE_WORKSPACE |
130 | +if ! which virtualenv; then |
131 | + sudo apt install --yes virtualenv |
132 | +fi |
133 | + |
134 | +git clone -b master https://git.launchpad.net/testflinger-cli |
135 | +cd testflinger-cli |
136 | +virtualenv -p python3 env |
137 | +. env/bin/activate |
138 | +./setup.py install |
139 | + |
140 | +JOB_ID=\$(testflinger-cli submit -q $REMOTE_WORKSPACE/$TEST_SPEC) |
141 | +echo "JOB_ID: \${JOB_ID}" |
142 | + |
143 | +testflinger-cli poll \${JOB_ID} |
144 | +testflinger-cli results \${JOB_ID} > $REMOTE_WORKSPACE/$TEST_RESULTS |
145 | +EOF |
146 | + |
147 | +$SCP "$REMOTE_USER"@"$REMOTE_WORKER":"$REMOTE_WORKSPACE"/"$TEST_RESULTS" "$WORKSPACE"/ |
148 | + |
149 | +$SSH sudo rm -rf "$REMOTE_WORKSPACE" |
150 | + |
151 | +TEST_STATUS=$(jq -r .test_status "$WORKSPACE"/"$TEST_RESULTS") |
152 | +echo "Test exit status: $TEST_STATUS" |
153 | + |
154 | +rm -rf $tmp_srcdir |
155 | +exit "$TEST_STATUS" |
156 | diff --git a/jobs/snap/snap-test.sh b/jobs/snap/snap-test.sh |
157 | index bea5e3a..d673610 100644 |
158 | --- a/jobs/snap/snap-test.sh |
159 | +++ b/jobs/snap/snap-test.sh |
160 | @@ -32,7 +32,7 @@ SCP="scp -i $SSH_KEY_PATH/id_rsa" |
161 | REMOTE_WORKSPACE=/home/$REMOTE_USER/$BUILD_TAG |
162 | REMOTE_RESULTS_BASE_DIR=/home/$REMOTE_USER/results |
163 | |
164 | -tmp_srcdir=`mktemp -d` |
165 | +tmp_srcdir=$(mktemp -d) |
166 | git clone --depth 1 -b $SOURCE_GIT_REPO_BRANCH $SOURCE_GIT_REPO $tmp_srcdir/src |
167 | cd $tmp_srcdir/src |
168 | # This will fail as we have set set -e above when the revision isn't part of |
169 | @@ -75,7 +75,7 @@ export PATH=/build/bin:$PATH |
170 | # Once the snapped version includes this backend, then we can |
171 | # change the manual building of spread with making sure the snap |
172 | # package is installed. |
173 | -export GOPATH=`mktemp -d` |
174 | +export GOPATH=$(mktemp -d) |
175 | go get -d -v github.com/snapcore/spread/... |
176 | go build github.com/snapcore/spread/cmd/spread |
177 | mkdir /build/bin |
178 | diff --git a/jobs/snap/snap-test.yaml b/jobs/snap/snap-test.yaml |
179 | index 9c15699..a361bbd 100644 |
180 | --- a/jobs/snap/snap-test.yaml |
181 | +++ b/jobs/snap/snap-test.yaml |
182 | @@ -62,3 +62,6 @@ |
183 | - shell: |
184 | !include-raw-escape: |
185 | - snap-test.sh |
186 | + - shell: |
187 | + !include-raw-escape: |
188 | + - snap-test-on-hw.sh |
PASSED: Continuous integration, rev:924df366edc ce6b15a0305ac18 26c82ac7d63897 /jenkins. canonical. com/system- enablement/ job/generic- build-snap/ 1843/ /jenkins. canonical. com/system- enablement/ job/generic- build-snap- worker/ 2845 /jenkins. canonical. com/system- enablement/ job/generic- update- snap-mp/ 1751/console /jenkins. canonical. com/system- enablement/ job/generic- test-snap/ 3131
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/system- enablement/ job/generic- build-snap/ 1843/rebuild
https:/