Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/pulseaudio:fix-tests into ~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio:master
- Git
- lp:~alfonsosanchezbeato/snappy-hwe-snaps/+git/pulseaudio
- fix-tests
- Merge into master
Status: | Merged |
---|---|
Approved by: | Alfonso Sanchez-Beato |
Approved revision: | c6c785b2fc77ca90f2ea59fc9307c907b425cbc9 |
Merged at revision: | cc080fd62696da35441f72194d97e84575888e19 |
Proposed branch: | ~alfonsosanchezbeato/snappy-hwe-snaps/+git/pulseaudio:fix-tests |
Merge into: | ~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio:master |
Diff against target: |
325 lines (+87/-111) 8 files modified
dev/null (+0/-8) run-tests.sh (+51/-33) snapcraft.yaml (+1/-0) tests/lib/prepare-all.sh (+3/-42) tests/lib/prepare.sh (+8/-9) tests/lib/restore-each.sh (+4/-3) tests/lib/utilities.sh (+17/-14) tests/main/pactl-connects-to-server/task.yaml (+3/-2) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
System Enablement Bot | continuous-integration | Approve | |
Review via email: mp+387378@code.launchpad.net |
Commit message
tests: fix ancillary scripts
run-tests.sh: update to latest template
Description of the change
tests: fix ancillary scripts
run-tests.sh: update to latest template
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:78254fff87a
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Successfully build documentation, rev: 91f5885f1e9b428
Generated documentation is available at https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:91f5885f1e9
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Successfully build documentation, rev: c6c785b2fc77ca9
Generated documentation is available at https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:c6c785b2fc7
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | diff --git a/run-tests.sh b/run-tests.sh |
2 | index 0b0679d..7f827b6 100755 |
3 | --- a/run-tests.sh |
4 | +++ b/run-tests.sh |
5 | @@ -1,4 +1,4 @@ |
6 | -#!/bin/sh |
7 | +#!/bin/bash |
8 | # |
9 | # Copyright (C) 2016 Canonical Ltd |
10 | # |
11 | @@ -16,64 +16,82 @@ |
12 | |
13 | set -e |
14 | |
15 | -TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/tests-extras" |
16 | -TESTS_EXTRAS_PATH=".tests-extras" |
17 | +TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/stack-snaps-tools" |
18 | +TESTS_EXTRAS_PATH="tests-extras" |
19 | |
20 | -# Display help. |
21 | -# This has to be in sync with the tests-extras/test-runner.sh script |
22 | -# functionalities as the parameters to this one are passed directly there |
23 | -# this function will quit the script because of the 'exec' keyword |
24 | show_help() { |
25 | exec cat <<'EOF' |
26 | Usage: run-tests.sh [OPTIONS] |
27 | |
28 | This is fetch & forget script and what it does is to fetch the |
29 | -tests-extras repository and execute the run-tests.sh script from |
30 | +stack-snaps-tools repository and execute the run-tests.sh script from |
31 | there passing arguments as-is. |
32 | |
33 | -optional arguments: |
34 | - --help Show this help message and exit |
35 | - --channel Select another channel to build the base image from (default: stable) |
36 | - --snap Extra snap to install |
37 | - --debug Enable verbose debugging output |
38 | - --test-from-channel Pull network-manager snap from the specified channel instead of building it from source |
39 | - --force-new-image Force generating a new image used for testing |
40 | +When you see this message you don't have the tests-extras folder |
41 | +successfully populated in your workspace yet. Please rerun without |
42 | +specifying --help to proceed with the initial clone of the git repository. |
43 | EOF |
44 | } |
45 | |
46 | -# Clone the tests-extras repository |
47 | +# Clone the stack-snaps-tools repository |
48 | clone_tests_extras() { |
49 | - echo "INFO: Fetching tests-extras scripts into $TESTS_EXTRAS_PATH ..." |
50 | - git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1 |
51 | - if [ $? -ne 0 ]; then |
52 | - echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.." |
53 | - exit 1 |
54 | - fi |
55 | + echo "INFO: Fetching stack-snaps-tools scripts into $TESTS_EXTRAS_PATH ..." |
56 | + if ! git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1; then |
57 | + echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.." |
58 | + exit 1 |
59 | + fi |
60 | } |
61 | |
62 | -# Make sure the already cloned tests-extras repository is in a known and update |
63 | +# Make sure the already cloned stack-snaps-tools repository is in a known and update |
64 | # state before it is going to be used. |
65 | restore_and_update_tests_extras() { |
66 | - echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH" |
67 | - cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull |
68 | - cd - |
69 | + echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH" |
70 | + cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull |
71 | + cd - |
72 | } |
73 | |
74 | # ============================================================================== |
75 | -# This is fetch & forget script and what it does is to fetch the tests-extras |
76 | +# This is fetch & forget script and what it does is to fetch the stack-snaps-tools |
77 | # repo and execute the run-tests.sh script from there passing arguments as-is. |
78 | # |
79 | -# The tests-extras repository ends up checked out in the snap tree but as a |
80 | +# The stack-snaps-tools repository ends up checked out in the snap tree but as a |
81 | # hidden directory which is re-used since then. |
82 | |
83 | -# Display help w/o fetching anything and exit |
84 | -[ "$1" = "--help" ] && show_help |
85 | +# Find snap to use in the tests |
86 | +snaps=$(find . -maxdepth 1 -type f -name \ |
87 | + "*_*_$(dpkg-architecture -q DEB_HOST_ARCH).snap") |
88 | +while read -r snap_file; do |
89 | + if [ -n "$snap" ]; then |
90 | + printf "More than one snap revision in the folder\n" |
91 | + exit 1 |
92 | + fi |
93 | + snap=$PWD/${snap_file#*/} |
94 | +done < <(printf "%s\n" "$snaps") |
95 | + |
96 | +[ ! -d "$TESTS_EXTRAS_PATH" ] && [ "$1" = "--help" ] && show_help |
97 | |
98 | if [ -d "$TESTS_EXTRAS_PATH" ]; then |
99 | - restore_and_update_tests_extras |
100 | + restore_and_update_tests_extras |
101 | else |
102 | - clone_tests_extras |
103 | + clone_tests_extras |
104 | +fi |
105 | + |
106 | +# Any project-specific options for test-runner should be specified in |
107 | +# .tests_config under EXTRA_ARGS |
108 | +if [ -f ".tests_config" ]; then |
109 | + # shellcheck disable=SC1091 |
110 | + . .tests_config |
111 | fi |
112 | |
113 | +# Get backends |
114 | +backends="--backends=" |
115 | +separator="" |
116 | +while read -r be; do |
117 | + backends=$backends$separator${be##*.} |
118 | + separator=, |
119 | +done < <(yq r spread.yaml --printMode p 'backends.qemu.systems[*].*') |
120 | + |
121 | echo "INFO: Executing tests runner" |
122 | -cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@" |
123 | +# shellcheck disable=SC2086 |
124 | +cd $TESTS_EXTRAS_PATH && |
125 | + ./tests-runner.sh "$@" --snap="$snap" "$backends" $EXTRA_ARGS |
126 | diff --git a/snapcraft.yaml b/snapcraft.yaml |
127 | index b4bf686..5015ebb 100644 |
128 | --- a/snapcraft.yaml |
129 | +++ b/snapcraft.yaml |
130 | @@ -129,6 +129,7 @@ parts: |
131 | - --disable-systemd-login |
132 | - --without-caps |
133 | - --disable-webrtc-aec |
134 | + - --disable-dbus |
135 | - --disable-oss-output |
136 | - --disable-oss-wrapper |
137 | - --disable-jack |
138 | diff --git a/tests/lib/prepare-all.sh b/tests/lib/prepare-all.sh |
139 | index 00819cf..08ae20a 100644 |
140 | --- a/tests/lib/prepare-all.sh |
141 | +++ b/tests/lib/prepare-all.sh |
142 | @@ -1,43 +1,4 @@ |
143 | -#!/bin/bash |
144 | +#!/bin/bash -x |
145 | |
146 | -# We don't have to build a snap when we should use one from a |
147 | -# channel |
148 | -if [ -n "$SNAP_CHANNEL" ] ; then |
149 | - exit 0 |
150 | -fi |
151 | - |
152 | -# Setup classic snap and build the pulseaudio snap in there |
153 | -snap install --devmode --beta classic |
154 | -cat <<-EOF > /home/test/build-snap.sh |
155 | -#!/bin/sh |
156 | -set -ex |
157 | - |
158 | -export DEBIAN_FRONTEND=noninteractive |
159 | - |
160 | -# If there is a snap prebuilt for us, lets take that one to speed things up. |
161 | -if [ -e $PROJECT_PATH/${SNAP_NAME}_*_${SNAP_ARCH}.snap ] ; then |
162 | - exit 0 |
163 | -fi |
164 | - |
165 | -# FIXME: Enable propose for now until problems with conflicting systemd |
166 | -# packages between the Ubuntu Core image ppa and the archive are fixed. |
167 | -echo "deb http://archive.ubuntu.com/ubuntu/ xenial-proposed restricted main universe" > /etc/apt/sources.list.d/ubuntu-proposed.list |
168 | -echo "deb http://ppa.launchpad.net/snappy-dev/image/ubuntu xenial main" > /etc/apt/sources.list.d/ubuntu-image-ppa.list |
169 | - |
170 | -# Ensure we have the latest updates installed as the core snap |
171 | -# may be a bit out of date. |
172 | -apt update |
173 | -apt -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade -y --force-yes |
174 | - |
175 | -apt install -y --force-yes snapcraft |
176 | -cd /home/pulseaudio |
177 | -snapcraft clean |
178 | -snapcraft |
179 | -EOF |
180 | - |
181 | -chmod +x /home/test/build-snap.sh |
182 | -sudo classic /home/test/build-snap.sh |
183 | -snap remove classic |
184 | - |
185 | -# Make sure we have a snap build |
186 | -test -e /home/pulseaudio/${SNAP_NAME}*_${SNAP_ARCH}.snap |
187 | +# Nothing to do here for the moment |
188 | +exit 0 |
189 | diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh |
190 | index e14a9b2..fc90454 100644 |
191 | --- a/tests/lib/prepare.sh |
192 | +++ b/tests/lib/prepare.sh |
193 | @@ -1,6 +1,7 @@ |
194 | -#!/bin/bash |
195 | +#!/bin/bash -ex |
196 | |
197 | -. $TESTSLIB/utilities.sh |
198 | +# shellcheck source=tests/lib/utilities.sh |
199 | +. "$TESTSLIB"/utilities.sh |
200 | |
201 | echo "Wait for firstboot change to be ready" |
202 | while ! snap changes | grep -q "Done"; do |
203 | @@ -10,9 +11,10 @@ while ! snap changes | grep -q "Done"; do |
204 | done |
205 | |
206 | echo "Ensure fundamental snaps are still present" |
207 | -. $TESTSLIB/snap-names.sh |
208 | -for name in $gadget_name $kernel_name $core_name; do |
209 | - if ! snap list | grep -q $name ; then |
210 | +# shellcheck source=tests/lib/snap-names.sh |
211 | +. "$TESTSLIB"/snap-names.sh |
212 | +for name in "$gadget_name" "$kernel_name" "$core_name"; do |
213 | + if ! snap list | grep -q "$name" ; then |
214 | echo "Not all fundamental snaps are available, all-snap image not valid" |
215 | echo "Currently installed snaps:" |
216 | snap list |
217 | @@ -20,9 +22,6 @@ for name in $gadget_name $kernel_name $core_name; do |
218 | fi |
219 | done |
220 | |
221 | -echo "Kernel has a store revision" |
222 | -snap list | grep ^${kernel_name} | grep -E " [0-9]+\s+canonical" |
223 | - |
224 | install_snap_under_test |
225 | |
226 | # Snapshot of the current snapd state for a later restore |
227 | @@ -34,4 +33,4 @@ fi |
228 | |
229 | # For debugging dump all snaps and connected slots/plugs |
230 | snap list |
231 | -snap interfaces |
232 | +snap connections --all |
233 | diff --git a/tests/lib/restore-each.sh b/tests/lib/restore-each.sh |
234 | index 541ba8c..9427aa8 100644 |
235 | --- a/tests/lib/restore-each.sh |
236 | +++ b/tests/lib/restore-each.sh |
237 | @@ -1,12 +1,13 @@ |
238 | -#!/bin/bash |
239 | +#!/bin/bash -ex |
240 | |
241 | -. $TESTSLIB/snap-names.sh |
242 | +# shellcheck source=tests/lib/snap-names.sh |
243 | +. "$TESTSLIB"/snap-names.sh |
244 | |
245 | # Remove all snaps not being the core, gadget, kernel or snap we're testing |
246 | for snap in /snap/*; do |
247 | snap="${snap:6}" |
248 | case "$snap" in |
249 | - "bin" | "$gadget_name" | "$kernel_name" | "$core_name" | "$SNAP_NAME") |
250 | + README | bin | "$gadget_name" | "$kernel_name" | core* | snapd | "$SNAP_NAME") |
251 | ;; |
252 | *) |
253 | snap remove "$snap" |
254 | diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh |
255 | index 08c0b8c..afc319d 100644 |
256 | --- a/tests/lib/utilities.sh |
257 | +++ b/tests/lib/utilities.sh |
258 | @@ -12,23 +12,26 @@ install_snap_under_test() { |
259 | # without any network connectivity after reboot. |
260 | if [ -n "$SNAP_CHANNEL" ] ; then |
261 | # Don't reinstall if we have it installed already |
262 | - if ! snap list | grep $SNAP_NAME ; then |
263 | - snap install --$SNAP_CHANNEL $SNAP_NAME |
264 | + if ! snap list | grep "$SNAP_NAME"; then |
265 | + snap install --"$SNAP_CHANNEL" "$SNAP_NAME" |
266 | fi |
267 | else |
268 | # Install first from store to avoid error when performing the connection |
269 | - snap install $SNAP_NAME |
270 | + sleep 3 |
271 | + snap install "$SNAP_NAME" |
272 | + sleep 3 |
273 | # Install prebuilt snap |
274 | - snap install --dangerous ${PROJECT_PATH}/${SNAP_NAME}_*_${SNAP_ARCH}.snap |
275 | - fi |
276 | - if [ -n "$SNAP_AUTO_ALIASES" ]; then |
277 | - snapd_version=$(snap version | awk '/^snapd / {print $2; exit}') |
278 | - for alias in $SNAP_AUTO_ALIASES ; do |
279 | - target=$SNAP_NAME.$alias |
280 | - if dpkg --compare-versions $snapd_version lt 2.25 ; then |
281 | - target=$SNAP_NAME |
282 | - fi |
283 | - snap alias $target $alias |
284 | - done |
285 | + snap install --dangerous "$PROJECT_PATH"/"$SNAP_NAME"_*_"$SNAP_ARCH".snap |
286 | + sleep 3 |
287 | + if [ -n "$SNAP_AUTO_ALIASES" ]; then |
288 | + snapd_version=$(snap version | awk '/^snapd / {print $2; exit}') |
289 | + for alias in $SNAP_AUTO_ALIASES ; do |
290 | + target="$SNAP_NAME".$alias |
291 | + if dpkg --compare-versions "$snapd_version" lt 2.25 ; then |
292 | + target="$SNAP_NAME" |
293 | + fi |
294 | + snap alias "$target" "$alias" |
295 | + done |
296 | + fi |
297 | fi |
298 | } |
299 | diff --git a/tests/main/module-loading-disabled/task.yaml b/tests/main/module-loading-disabled/task.yaml |
300 | deleted file mode 100644 |
301 | index 5ee9b43..0000000 |
302 | --- a/tests/main/module-loading-disabled/task.yaml |
303 | +++ /dev/null |
304 | @@ -1,8 +0,0 @@ |
305 | -summary: Verify module loading is disabled |
306 | - |
307 | -description: | |
308 | - As we're running pulseaudio in system mode (see https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/) |
309 | - for more details we have module loading disabled to prevent any client from loading malicious code into the daemon. |
310 | - |
311 | -execute: | |
312 | - ! /snap/bin/pactl load-module module-null-sink |
313 | diff --git a/tests/main/pactl-connects-to-server/task.yaml b/tests/main/pactl-connects-to-server/task.yaml |
314 | index 41dee48..f547f73 100644 |
315 | --- a/tests/main/pactl-connects-to-server/task.yaml |
316 | +++ b/tests/main/pactl-connects-to-server/task.yaml |
317 | @@ -1,5 +1,6 @@ |
318 | summary: Test pactl is working |
319 | |
320 | execute: | |
321 | - # Does it even work? |
322 | - /snap/bin/pactl info | grep -Pzq 'Server Name: pulseaudio' |
323 | + sleep 3 |
324 | + # Does it even work? |
325 | + /snap/bin/pactl info | grep -Pzq 'Server Name: pulseaudio' |
PASSED: Successfully build documentation, rev: 78254fff87a3aff 9aff0efe5817b78 b082bc73cf
Generated documentation is available at https:/ /jenkins. canonical. com/system- enablement/ job/snappy- hwe-snaps- snap-docs/ 1344/