Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/modem-manager:test-on-uc20 into ~snappy-hwe-team/snappy-hwe-snaps/+git/modem-manager:snap-20

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 6a1f448ffee9268e75092c7b6718939f6de5314f
Merged at revision: 7e5f1f1a7199f32dc8435e94459a61f31ec94559
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/modem-manager:test-on-uc20
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/modem-manager:snap-20
Diff against target: 352 lines (+85/-110)
8 files modified
run-tests.sh (+50/-32)
spread.yaml (+4/-2)
tests/lib/prepare-all.sh (+3/-41)
tests/lib/prepare.sh (+8/-13)
tests/lib/restore-each.sh (+5/-11)
tests/lib/snap-names.sh (+1/-1)
tests/lib/utilities.sh (+9/-9)
tests/main/network-manager-autoconn/task.yaml (+5/-1)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Review via email: mp+387327@code.launchpad.net

Commit message

tests: adapt to run on UC20

Description of the change

tests: adapt to run on UC20

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6a1f448ffee9268e75092c7b6718939f6de5314f

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/1342/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/run-tests.sh b/run-tests.sh
2index 04c3b9f..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@@ -17,63 +17,81 @@
12 set -e
13
14 TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/stack-snaps-tools"
15-TESTS_EXTRAS_PATH="stack-snaps-tools"
16+TESTS_EXTRAS_PATH="tests-extras"
17
18-# Display help.
19-# This has to be in sync with the tests-extras/test-runner.sh script
20-# functionalities as the parameters to this one are passed directly there
21-# this function will quit the script because of the 'exec' keyword
22 show_help() {
23 exec cat <<'EOF'
24 Usage: run-tests.sh [OPTIONS]
25
26 This is fetch & forget script and what it does is to fetch the
27-tests-extras repository and execute the run-tests.sh script from
28+stack-snaps-tools repository and execute the run-tests.sh script from
29 there passing arguments as-is.
30
31-optional arguments:
32- --help Show this help message and exit
33- --channel Select another channel to build the base image from (default: stable)
34- --snap Extra snap to install
35- --debug Enable verbose debugging output
36- --test-from-channel Pull network-manager snap from the specified channel instead of building it from source
37- --force-new-image Force generating a new image used for testing
38+When you see this message you don't have the tests-extras folder
39+successfully populated in your workspace yet. Please rerun without
40+specifying --help to proceed with the initial clone of the git repository.
41 EOF
42 }
43
44-# Clone the tests-extras repository
45+# Clone the stack-snaps-tools repository
46 clone_tests_extras() {
47- echo "INFO: Fetching tests-extras scripts into $TESTS_EXTRAS_PATH ..."
48- git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1
49- if [ $? -ne 0 ]; then
50- echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."
51- exit 1
52- fi
53+ echo "INFO: Fetching stack-snaps-tools scripts into $TESTS_EXTRAS_PATH ..."
54+ if ! git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1; then
55+ echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."
56+ exit 1
57+ fi
58 }
59
60-# Make sure the already cloned tests-extras repository is in a known and update
61+# Make sure the already cloned stack-snaps-tools repository is in a known and update
62 # state before it is going to be used.
63 restore_and_update_tests_extras() {
64- echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH"
65- cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull
66- cd -
67+ echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH"
68+ cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull
69+ cd -
70 }
71
72 # ==============================================================================
73-# This is fetch & forget script and what it does is to fetch the tests-extras
74+# This is fetch & forget script and what it does is to fetch the stack-snaps-tools
75 # repo and execute the run-tests.sh script from there passing arguments as-is.
76 #
77-# The tests-extras repository ends up checked out in the snap tree but as a
78+# The stack-snaps-tools repository ends up checked out in the snap tree but as a
79 # hidden directory which is re-used since then.
80
81-# Display help w/o fetching anything and exit
82-[ "$1" = "--help" ] && show_help
83+# Find snap to use in the tests
84+snaps=$(find . -maxdepth 1 -type f -name \
85+ "*_*_$(dpkg-architecture -q DEB_HOST_ARCH).snap")
86+while read -r snap_file; do
87+ if [ -n "$snap" ]; then
88+ printf "More than one snap revision in the folder\n"
89+ exit 1
90+ fi
91+ snap=$PWD/${snap_file#*/}
92+done < <(printf "%s\n" "$snaps")
93+
94+[ ! -d "$TESTS_EXTRAS_PATH" ] && [ "$1" = "--help" ] && show_help
95
96 if [ -d "$TESTS_EXTRAS_PATH" ]; then
97- restore_and_update_tests_extras
98+ restore_and_update_tests_extras
99 else
100- clone_tests_extras
101+ clone_tests_extras
102+fi
103+
104+# Any project-specific options for test-runner should be specified in
105+# .tests_config under EXTRA_ARGS
106+if [ -f ".tests_config" ]; then
107+ # shellcheck disable=SC1091
108+ . .tests_config
109 fi
110
111+# Get backends
112+backends="--backends="
113+separator=""
114+while read -r be; do
115+ backends=$backends$separator${be##*.}
116+ separator=,
117+done < <(yq r spread.yaml --printMode p 'backends.qemu.systems[*].*')
118+
119 echo "INFO: Executing tests runner"
120-cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@"
121+# shellcheck disable=SC2086
122+cd $TESTS_EXTRAS_PATH &&
123+ ./tests-runner.sh "$@" --snap="$snap" "$backends" $EXTRA_ARGS
124diff --git a/spread.yaml b/spread.yaml
125index 1368084..9a775ca 100644
126--- a/spread.yaml
127+++ b/spread.yaml
128@@ -28,8 +28,10 @@ environment:
129
130 backends:
131 qemu:
132+ memory: 4G
133 systems:
134- - ubuntu-core-16:
135+ - ubuntu-core-20:
136+ bios: /usr/share/OVMF/OVMF_CODE.fd
137 username: test
138 password: test
139
140@@ -55,7 +57,7 @@ suites:
141 tests/main/:
142 summary: Full-system tests for ModemManager
143 systems:
144- - ubuntu-core-16
145+ - ubuntu-core-20
146 prepare: |
147 . $TESTSLIB/prepare.sh
148 restore-each: |
149diff --git a/tests/lib/prepare-all.sh b/tests/lib/prepare-all.sh
150index 979e57d..08ae20a 100644
151--- a/tests/lib/prepare-all.sh
152+++ b/tests/lib/prepare-all.sh
153@@ -1,42 +1,4 @@
154-#!/bin/sh
155+#!/bin/bash -x
156
157-# We don't have to build a snap when we should use one from a channel
158-if [ -n "$SNAP_CHANNEL" ] ; then
159- exit 0
160-fi
161-
162-# If there is a snap prebuilt for us, lets take that one to speed things up
163-if [ -e $PROJECT_PATH/${SNAP_NAME}_*_${SNAP_ARCH}.snap ] ; then
164- exit 0
165-fi
166-
167-
168-# Setup classic snap and build the snap in there
169-snap install --devmode --beta classic
170-cat <<-EOF > /home/test/build-snap.sh
171-#!/bin/sh
172-set -ex
173-
174-export DEBIAN_FRONTEND=noninteractive
175-
176-# FIXME: Enable propose for now until problems with conflicting systemd
177-# packages between the Ubuntu Core image ppa and the archive are fixed.
178-echo "deb http://archive.ubuntu.com/ubuntu/ xenial-proposed restricted main universe" > /etc/apt/sources.list.d/ubuntu-proposed.list
179-echo "deb http://ppa.launchpad.net/snappy-dev/image/ubuntu xenial main" > /etc/apt/sources.list.d/ubuntu-image-ppa.list
180-
181-# Ensure we have the latest updates installed as the core snap
182-# may be a bit out of date.
183-apt update
184-apt -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade -y --force-yes
185-
186-apt install -y --force-yes snapcraft
187-cd $PROJECT_PATH
188-snapcraft clean
189-snapcraft
190-EOF
191-chmod +x /home/test/build-snap.sh
192-sudo classic /home/test/build-snap.sh
193-snap remove classic
194-
195-# Make sure we have a snap build
196-test -e $PROJECT_PATH/${SNAP_NAME}_*_${SNAP_ARCH}.snap
197+# Nothing to do here for the moment
198+exit 0
199diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
200index 185bacb..cdf9213 100644
201--- a/tests/lib/prepare.sh
202+++ b/tests/lib/prepare.sh
203@@ -1,6 +1,7 @@
204-#!/bin/sh
205+#!/bin/bash -ex
206
207-. $TESTSLIB/utilities.sh
208+# shellcheck source=tests/lib/utilities.sh
209+. "$TESTSLIB"/utilities.sh
210
211 echo "Wait for firstboot change to be ready"
212 while ! snap changes | grep -q "Done"; do
213@@ -10,9 +11,10 @@ while ! snap changes | grep -q "Done"; do
214 done
215
216 echo "Ensure fundamental snaps are still present"
217-. $TESTSLIB/snap-names.sh
218-for name in $gadget_name $kernel_name $core_name; do
219- if ! snap list | grep -q $name ; then
220+# shellcheck source=tests/lib/snap-names.sh
221+. "$TESTSLIB"/snap-names.sh
222+for name in "$gadget_name" "$kernel_name" "$core_name"; do
223+ if ! snap list | grep -q "$name" ; then
224 echo "Not all fundamental snaps are available, all-snap image not valid"
225 echo "Currently installed snaps:"
226 snap list
227@@ -22,13 +24,6 @@ done
228
229 install_snap_under_test
230
231-# Snapshot of the current snapd state for a later restore
232-if [ ! -f $SPREAD_PATH/snapd-state.tar.gz ] ; then
233- systemctl stop snapd.service snapd.socket
234- tar czf $SPREAD_PATH/snapd-state.tar.gz /var/lib/snapd /etc/netplan
235- systemctl start snapd.socket
236-fi
237-
238 # For debugging dump all snaps and connected slots/plugs
239 snap list
240-snap interfaces
241+snap connections --all
242diff --git a/tests/lib/restore-each.sh b/tests/lib/restore-each.sh
243index 5b62c4b..deea076 100644
244--- a/tests/lib/restore-each.sh
245+++ b/tests/lib/restore-each.sh
246@@ -1,12 +1,13 @@
247-#!/bin/sh
248+#!/bin/bash -ex
249
250-. $TESTSLIB/snap-names.sh
251+# shellcheck source=tests/lib/snap-names.sh
252+. "$TESTSLIB"/snap-names.sh
253
254 # Remove all snaps not being the core, gadget, kernel or snap we're testing
255 for snap in /snap/*; do
256 snap="${snap:6}"
257 case "$snap" in
258- "bin" | "$gadget_name" | "$kernel_name" | core* | "$SNAP_NAME" )
259+ README | bin | "$gadget_name" | "$kernel_name" | core* | snapd | "$SNAP_NAME")
260 ;;
261 *)
262 snap remove "$snap"
263@@ -16,16 +17,9 @@ done
264
265 # Cleanup all configuration files from ModemManager so that we have
266 # a fresh start for the next test
267+systemctl stop snap.modem-manager.modemmanager
268 rm -rf /var/snap/modem-manager/common/*
269 rm -rf /var/snap/modem-manager/current/*
270-systemctl stop snap.modem-manager.modemmanager
271-
272-# Ensure we have the same state for snapd as we had before
273-systemctl stop snapd.service snapd.socket
274-rm -rf /var/lib/snapd/*
275-$(cd / && tar xzf $SPREAD_PATH/snapd-state.tar.gz)
276-rm -rf /root/.snap
277-systemctl start snapd.service snapd.socket
278
279 # Bringup ModemManager again now that the system is restored
280 systemctl start snap.modem-manager.modemmanager
281diff --git a/tests/lib/snap-names.sh b/tests/lib/snap-names.sh
282index 71c9628..f15b09a 100644
283--- a/tests/lib/snap-names.sh
284+++ b/tests/lib/snap-names.sh
285@@ -1,4 +1,4 @@
286-#!/bin/sh
287+#!/bin/bash
288 gadget_name=$(snap list | sed -n 's/^\(pc\|pi[23]\|dragonboard\) .*/\1/p')
289 kernel_name=$gadget_name-kernel
290 core_name=$(snap list | awk '/^(ubuntu-)?core / {print $1; exit}')
291diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
292index f756f66..f0aa6d7 100644
293--- a/tests/lib/utilities.sh
294+++ b/tests/lib/utilities.sh
295@@ -8,7 +8,7 @@ wait_for_modem_manager() {
296 }
297
298 stop_after_first_reboot() {
299- if [ $SPREAD_REBOOT -eq 1 ] ; then
300+ if [ "$SPREAD_REBOOT" -eq 1 ] ; then
301 exit 0
302 fi
303 }
304@@ -18,22 +18,22 @@ install_snap_under_test() {
305 # without any network connectivity after reboot.
306 if [ -n "$SNAP_CHANNEL" ] ; then
307 # Don't reinstall if we have it installed already
308- if ! snap list | grep $SNAP_NAME ; then
309- snap install --$SNAP_CHANNEL $SNAP_NAME
310+ if ! snap list | grep "$SNAP_NAME"; then
311+ snap install --"$SNAP_CHANNEL" "$SNAP_NAME"
312 fi
313 else
314 # Install first from store to avoid error when performing the connection
315- snap install $SNAP_NAME
316+ snap install "$SNAP_NAME"
317 # Install prebuilt snap
318- snap install --dangerous ${PROJECT_PATH}/${SNAP_NAME}_*_${SNAP_ARCH}.snap
319+ snap install --dangerous "$PROJECT_PATH"/"$SNAP_NAME"_*_"$SNAP_ARCH".snap
320 if [ -n "$SNAP_AUTO_ALIASES" ]; then
321 snapd_version=$(snap version | awk '/^snapd / {print $2; exit}')
322 for alias in $SNAP_AUTO_ALIASES ; do
323- target=$SNAP_NAME.$alias
324- if dpkg --compare-versions $snapd_version lt 2.25 ; then
325- target=$SNAP_NAME
326+ target="$SNAP_NAME".$alias
327+ if dpkg --compare-versions "$snapd_version" lt 2.25 ; then
328+ target="$SNAP_NAME"
329 fi
330- snap alias $target $alias
331+ snap alias "$target" "$alias"
332 done
333 fi
334 fi
335diff --git a/tests/main/network-manager-autoconn/task.yaml b/tests/main/network-manager-autoconn/task.yaml
336index 7092b7f..23cff72 100644
337--- a/tests/main/network-manager-autoconn/task.yaml
338+++ b/tests/main/network-manager-autoconn/task.yaml
339@@ -6,8 +6,12 @@ execute: |
340 # Service should be up an running
341 wait_for_modem_manager
342
343- snap install network-manager
344+ snap install --channel=20/beta network-manager
345
346 # Ensure all necessary plugs/slots are connected
347 snap interfaces | grep -Ezq "modem-manager:service .*modem-manager:mmcli"
348 snap interfaces | grep -Ezq "modem-manager:service .*network-manager:modem-manager"
349+
350+ # Set renderer back to networkd
351+ snap set network-manager defaultrenderer=false
352+ sleep 2

Subscribers

People subscribed via source and target branches