Merge ~kzapalowicz/snappy-hwe-snaps/+git/tests-extras:feature/add-extras-scripts into ~snappy-hwe-team/snappy-hwe-snaps/+git/tests-extras:master

Proposed by Konrad Zapałowicz
Status: Merged
Approved by: Simon Fels
Approved revision: 5190d0a74772c60e3d0d10702e05a63da6fced9b
Merged at revision: e2dab660e00044471949271c0b496f73b1ce3eb0
Proposed branch: ~kzapalowicz/snappy-hwe-snaps/+git/tests-extras:feature/add-extras-scripts
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/tests-extras:master
Diff against target: 509 lines (+445/-0)
11 files modified
.ci_tests_disabled (+0/-0)
MAINTAINERS (+2/-0)
README.md (+34/-0)
create-image-scripts/README.md (+7/-0)
create-image-scripts/create-image.sh (+157/-0)
create-image-scripts/pc-model.json (+11/-0)
create-image-scripts/pc.model (+21/-0)
create-image-scripts/test-user-assertion.json (+13/-0)
create-image-scripts/test-user.assertion (+25/-0)
templates/run-tests.sh (+79/-0)
tests-runner.sh (+96/-0)
Reviewer Review Type Date Requested Status
Simon Fels Approve
System Enablement Bot continuous-integration Approve
Jim Hodapp (community) Approve
Review via email: mp+315453@code.launchpad.net

Commit message

Add image creating scripts and tests runner.

These are the tests-related bits shared by snaps. The image creating scripts are responsible for creating an Ubuntu Core image for spread-testing. The test runner executes the spread tests and (if needed) uses the mentioned scripts to create image for testing.

Description of the change

Add image creating scripts and tests runner.

These are the tests-related bits shared by snaps. The image creating scripts are responsible for creating an Ubuntu Core image for spread-testing. The test runner executes the spread tests and (if needed) uses the mentioned scripts to create image for testing.

To post a comment you must log in.
Revision history for this message
Simon Fels (morphis) :
review: Needs Fixing
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Matteo Croce (teknoraver) :
Revision history for this message
Jim Hodapp (jhodapp) wrote :

Looks great Konrad, see my comments inline below for several fixes.

review: Needs Fixing
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

Matteo, could you explain two of your comments that I answered. I would love to learn and understand why

Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

Links to Ubuntu Core documentation added to README.md

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Simon Fels (morphis) :
Revision history for this message
Jim Hodapp (jhodapp) :
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jim Hodapp (jhodapp) wrote :

LGTM

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

LGTM

Actually we really need to extend our CI infrastructure to allow static tests or so to be run.

review: Approve
Revision history for this message
Jim Hodapp (jhodapp) wrote :

@Simon: What exactly do you mean by static tests?

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Simon Fels (morphis) wrote :

Disapproving to see how CI behaves with this.

review: Disapprove
Revision history for this message
Simon Fels (morphis) wrote :

Retriggered CI manually.

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

Approving now to let CI merge this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.ci_tests_disabled b/.ci_tests_disabled
2new file mode 100644
3index 0000000..e69de29
4--- /dev/null
5+++ b/.ci_tests_disabled
6diff --git a/MAINTAINERS b/MAINTAINERS
7new file mode 100644
8index 0000000..5ceb271
9--- /dev/null
10+++ b/MAINTAINERS
11@@ -0,0 +1,2 @@
12+Jim Hodapp <jim.hodapp@canonical.com>
13+Konrad Zapałowicz <konrad.zapalowicz@canonical.com>
14diff --git a/README.md b/README.md
15index e69de29..e8acb18 100644
16--- a/README.md
17+++ b/README.md
18@@ -0,0 +1,34 @@
19+# tests-extras
20+
21+This repository contains the common, test related bits shared across
22+snappy-hwe-snaps snaps.
23+
24+## tests-runner.sh
25+
26+The test runner script will create an image via ubuntu-image and make it available
27+to spread by copying it to ~/.spread/qemu or ~/snap/spread/<version>/.spread/qemu
28+depending on if you're using a local spread version or the one from the
29+snap.
30+
31+## create-image-scripts
32+
33+This subdirectory contains the scripts that build the image used by spread as
34+well as required by Ubuntu Core assertions. The system-user assertion creates
35+user with test/test login/password.
36+
37+For the information on how to fill and use the test-user-assertion.json please
38+refer to Ubuntu Core assertions documentation
39+https://docs.ubuntu.com/core/en/reference/assertions
40+
41+Consequently for the information about pc-model.json model assertions please
42+refer to Ubuntu Core image building documentation
43+https://docs.ubuntu.com/core/en/guides/build-device/image-building
44+
45+## templates
46+
47+Contains the script templates that aid in snap development.
48+
49+### run-tests.sh
50+
51+This is the recommended tests running script that uses the image creation
52+scripts from the tests-extras repository.
53diff --git a/create-image-scripts/README.md b/create-image-scripts/README.md
54new file mode 100644
55index 0000000..b75b66e
56--- /dev/null
57+++ b/create-image-scripts/README.md
58@@ -0,0 +1,7 @@
59+# Generate user password
60+
61+You can generate the password for the system user assertion via
62+
63+```
64+ $ python3 -c 'import crypt; print(crypt.crypt("test", crypt.mksalt(crypt.METHOD_SHA512)))'
65+```
66diff --git a/create-image-scripts/create-image.sh b/create-image-scripts/create-image.sh
67new file mode 100755
68index 0000000..6f70e2a
69--- /dev/null
70+++ b/create-image-scripts/create-image.sh
71@@ -0,0 +1,157 @@
72+#!/bin/sh
73+#
74+# Copyright (C) 2016 Canonical Ltd
75+#
76+# This program is free software: you can redistribute it and/or modify
77+# it under the terms of the GNU General Public License version 3 as
78+# published by the Free Software Foundation.
79+#
80+# This program is distributed in the hope that it will be useful,
81+# but WITHOUT ANY WARRANTY; without even the implied warranty of
82+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83+# GNU General Public License for more details.
84+#
85+# You should have received a copy of the GNU General Public License
86+# along with this program. If not, see <http://www.gnu.org/licenses/>.
87+
88+set -e
89+
90+if [ $(id -u) -ne 0 ] ; then
91+ echo "ERROR: needs to be executed as root"
92+ exit 1
93+fi
94+
95+channel=candidate
96+if [ -n "$1" ] ; then
97+ channel=$1
98+fi
99+
100+snap=
101+if [ -n "$2" ] ; then
102+ snap=$2
103+fi
104+
105+model=pc
106+arch=amd64
107+image_name=ubuntu-core-16.img
108+ubuntu_image_extra_args=
109+
110+if [ -n "$snap" ] ; then
111+ ubuntu_image_extra_args="--extra-snaps $snap"
112+fi
113+
114+ubuntu-image \
115+ --channel $channel \
116+ -o $image_name \
117+ --image-size 4G \
118+ $ubuntu_image_extra_args \
119+ $model.model
120+
121+kpartx -a $image_name
122+sleep 0.5
123+
124+loop_path=$(findfs LABEL=writable)
125+tmp_mount=$(mktemp -d)
126+
127+mount $loop_path $tmp_mount
128+
129+# Migrate all systemd units from core snap into the writable area. This
130+# would be normally done on firstboot by the initramfs but we can't rely
131+# on that because we are adding another file in there and that will
132+# prevent the initramfs from transitioning any files.
133+core_snap=$(find $tmp_mount/system-data/var/lib/snapd/snaps -name "core_*.snap")
134+tmp_core=$(mktemp -d)
135+mount $core_snap $tmp_core
136+mkdir -p $tmp_mount/system-data/etc/systemd
137+cp -rav $tmp_core/etc/systemd/* \
138+ $tmp_mount/system-data/etc/systemd/
139+umount $tmp_core
140+rm -rf $tmp_core
141+
142+# system-user assertion which gives us our test:test user we use to
143+# log into the system
144+mkdir -p $tmp_mount/system-data/var/lib/snapd/seed/assertions
145+cp test-user.assertion $tmp_mount/system-data/var/lib/snapd/seed/assertions
146+
147+# Disable console-conf for the first boot
148+mkdir -p $tmp_mount/system-data/var/lib/console-conf/
149+touch $tmp_mount/system-data/var/lib/console-conf/complete
150+
151+# Create systemd service which is running on firstboot and sets up
152+# various things for us.
153+mkdir -p $tmp_mount/system-data/etc/systemd/system
154+cat << 'EOF' > $tmp_mount/system-data/etc/systemd/system/devmode-firstboot.service
155+[Unit]
156+Description=Run devmode firstboot setup
157+After=snapd.service snapd.socket
158+
159+[Service]
160+Type=oneshot
161+ExecStart=/writable/system-data/var/lib/devmode-firstboot/run.sh
162+RemainAfterExit=yes
163+TimeoutSec=3min
164+EOF
165+
166+mkdir -p $tmp_mount/system-data/etc/systemd/system/multi-user.target.wants
167+ln -sf /etc/systemd/system/devmode-firstboot.service \
168+ $tmp_mount/system-data/etc/systemd/system/multi-user.target.wants/devmode-firstboot.service
169+
170+mkdir $tmp_mount/system-data/var/lib/devmode-firstboot
171+cat << EOF > $tmp_mount/system-data/var/lib/devmode-firstboot/00-snapd-config.yaml
172+network:
173+ version: 2
174+ ethernets:
175+ eth0:
176+ dhcp4: true
177+EOF
178+
179+cat << 'EOF' > $tmp_mount/system-data/var/lib/devmode-firstboot/run.sh
180+#!/bin/sh
181+
182+set -e
183+
184+# Don't start again if we're already done
185+if [ -e /writable/system-data/var/lib/devmode-firstboot/complete ] ; then
186+ exit 0
187+fi
188+
189+echo "Start devmode-firstboot $(date -Iseconds --utc)"
190+
191+if [ "$(snap managed)" = "true" ]; then
192+ echo "System already managed, exiting"
193+ exit 0
194+fi
195+
196+# no changes at all
197+until snap changes ; do
198+ echo "No changes yet, waiting"
199+ sleep 1
200+done
201+
202+while snap changes | grep -qE 'Do(|ing)' .*Initialize system state' ; do
203+ echo "Initialize system state is in progress, waiting"
204+ sleep 1
205+done
206+
207+if [ -n "$(snap known system-user)" ]; then
208+ echo "Trying to create known user"
209+ snap create-user --known --sudoer
210+fi
211+
212+cp /writable/system-data/var/lib/devmode-firstboot/00-snapd-config.yaml /writable/system-data/etc/netplan
213+
214+# Enable console-conf again
215+rm /writable/system-data/var/lib/console-conf/complete
216+
217+# Mark us done
218+touch /writable/system-data/var/lib/devmode-firstboot/complete
219+
220+# Reboot the system as it's now prepared for the user
221+reboot
222+EOF
223+
224+chmod +x $tmp_mount/system-data/var/lib/devmode-firstboot/run.sh
225+
226+umount $tmp_mount
227+kpartx -d $image_name
228+rm -rf $tmp_mount
229diff --git a/create-image-scripts/pc-model.json b/create-image-scripts/pc-model.json
230new file mode 100644
231index 0000000..2eb1411
232--- /dev/null
233+++ b/create-image-scripts/pc-model.json
234@@ -0,0 +1,11 @@
235+{
236+ "type": "model",
237+ "authority-id": "4BKZlf4WMNBKgQfij0rftmp5BzDdVhlf",
238+ "brand-id": "4BKZlf4WMNBKgQfij0rftmp5BzDdVhlf",
239+ "series": "16",
240+ "model": "pc",
241+ "architecture": "amd64",
242+ "gadget": "pc",
243+ "kernel": "pc-kernel",
244+ "timestamp": "2016-09-09T08:27:36+00:00"
245+}
246diff --git a/create-image-scripts/pc.model b/create-image-scripts/pc.model
247new file mode 100644
248index 0000000..345b7e4
249--- /dev/null
250+++ b/create-image-scripts/pc.model
251@@ -0,0 +1,21 @@
252+type: model
253+authority-id: 4BKZlf4WMNBKgQfij0rftmp5BzDdVhlf
254+series: 16
255+brand-id: 4BKZlf4WMNBKgQfij0rftmp5BzDdVhlf
256+model: pc
257+architecture: amd64
258+gadget: pc
259+kernel: pc-kernel
260+timestamp: 2016-09-09T08:27:36+00:00
261+sign-key-sha3-384: a4qX7md6GQGNcZc_cmWPBStTq4RNCnGTzF-4usF5wFylQ-xZQej-SD6prx8Yl89O
262+
263+AcLBXAQAAQoABgUCWBBNTwAKCRAVoE002xqmOPH/EACWLf1UeZgICjNbzLI5bO/84LExS8iUjarG
264+S7DRn8Ln5zu44pxz7UXJNjULgnU8yuKVPVWg0ij7DRvaj8tGxOMMAls1fjSRtEYR8oJFsI3jXDGw
265+cLjvJG/crUxV8DgdZFlF02Kb5VtmNDXs1OE3zpPeniG19JYHaf2hDz4SRmWZe4c2MFrAt2UwI/VC
266+o/209Fl3qA8p8x5EYOBycgHooHm3924NTF9mXbKSfLRgGS7YzmN4FXFyiGOTY6CRsp37XnkxGcA1
267++lyZz1X97qT/fOGVUFqHDqUZmuCs5sC3+DNonytTgKt5+7S+V+Ai45HEayD5f4gS9uscnTMTwEEJ
268+VgSZRU0My+iJwFlXHaGWQe9eC37YCZ3ahBxc2SpkFffXjYhEMtTtr1vDIYCAhbc2k8aa3hPE2GUg
269+3pv8zs1AuZzSVX+Rp4ysMBqU23UUVP6Bmvr7ZD3E8aEUxE6O/BEA10Km5oZPqpmBfcEVO8a0yZjn
270+YQxn4XzY1Nwq1d0sJIV7FEDsq9dXH9QCa4qsCH3KG3jHv32GapvLf8mpr6HSH+JmPM5kNeVugLVy
271+/RUAFNu+Y4hqhpRNC8fc+UDkVBXsLDqHb5gfXnhbFIH8LvpVFR20SSkg9/Km5xC+7wcey0h8SD6/
272+Eh70OPLxDkzitEn/1L/0V987dlJnhS4WpqrYfbHYwQ==
273diff --git a/create-image-scripts/test-user-assertion.json b/create-image-scripts/test-user-assertion.json
274new file mode 100644
275index 0000000..81f6beb
276--- /dev/null
277+++ b/create-image-scripts/test-user-assertion.json
278@@ -0,0 +1,13 @@
279+{
280+ "type": "system-user",
281+ "authority-id": "4BKZlf4WMNBKgQfij0rftmp5BzDdVhlf",
282+ "brand-id": "4BKZlf4WMNBKgQfij0rftmp5BzDdVhlf",
283+ "series": ["16"],
284+ "models": ["pc"],
285+ "name": "Default Test User",
286+ "username": "test",
287+ "email": "test@localhost",
288+ "password": "$6$OCvKy4w/Ppxp7IvC$WPzWiIW.4y18h9htjbOuxLZ.sjQ5M2hoSiEu3FpMU0PMdHQuQdBOqvk8p6DMdS/R/nU/rXidClD23CbSkSgp30",
289+ "since": "2016-10-24T07:12:10+00:00",
290+ "until": "2017-10-24T07:12:10+00:00"
291+}
292diff --git a/create-image-scripts/test-user.assertion b/create-image-scripts/test-user.assertion
293new file mode 100644
294index 0000000..7ebb667
295--- /dev/null
296+++ b/create-image-scripts/test-user.assertion
297@@ -0,0 +1,25 @@
298+type: system-user
299+authority-id: 4BKZlf4WMNBKgQfij0rftmp5BzDdVhlf
300+brand-id: 4BKZlf4WMNBKgQfij0rftmp5BzDdVhlf
301+email: test@localhost
302+models:
303+ - pc
304+name: Default Test User
305+password: $6$OCvKy4w/Ppxp7IvC$WPzWiIW.4y18h9htjbOuxLZ.sjQ5M2hoSiEu3FpMU0PMdHQuQdBOqvk8p6DMdS/R/nU/rXidClD23CbSkSgp30
306+series:
307+ - 16
308+since: 2016-10-24T07:12:10+00:00
309+until: 2017-10-24T07:12:10+00:00
310+username: test
311+sign-key-sha3-384: a4qX7md6GQGNcZc_cmWPBStTq4RNCnGTzF-4usF5wFylQ-xZQej-SD6prx8Yl89O
312+
313+AcLBXAQAAQoABgUCWBBOJAAKCRAVoE002xqmOKaRD/0cEKWb2nbwhk+BTgOrYZHrwzjbIWTZznDh
314+xCD6JWF/yr9br1vEmRz2zCNPPWZgFH9HaJ+mT/lktWIs7VVMIdwMDWYOR8P9rdWM/Jx6iyB3z0OI
315+YO31zaU4XLyolv/YSj/nFXMMD+jIeE4l8j4AtCSJwd7ZS9Jz8F/RfrD8EpG0JU1F55lq8MC0mjZ4
316+ul5ws8k9UiP8nA5IAG30NvvReiUGYqtdkO43eQmy88WABL95MbFsbfEk4/VduG0Gt3y/T8vDDcF6
317+NJEm8L+O9IXnPBAje0Ve0NX3YtOE3CDTkYRKR7xFFJq2cJVCSvf9CsorREg4KyfagIdMKDSa5Tiq
318+FzoAJTfI0ltq5cAnLImtxFKulJ+AnGUNMLrKFr1H0FGtqTZBfs/PcIxy0qY0YDXSF4/9F2PUBdQS
319+tSmN6pT9t1FCGy2Rf5n3QV4e0R2JzS6Kx+vdbPMYqhssQosLU5GwlWj8UbevtphAGf8u8nLBDYWs
320+MNIPi0IrPmzIewZBD05A6a8T+oHZ9dIg5SAnJ4gmz0sCzNDKarvYqLpcU1rZzu78/UypbHXDvBAt
321+gnxYpD6WHR2aHSeyx3WvOp130jFco2/55M0RTEm50isO1uv2DqTn9ULkBdCrG/zOqEmZgY18ds3P
322+yTaAbaIAqUe7scpAHY0a31tfnXq8cRyEX03e9g2Mrg==
323diff --git a/templates/run-tests.sh b/templates/run-tests.sh
324new file mode 100755
325index 0000000..fdba1d8
326--- /dev/null
327+++ b/templates/run-tests.sh
328@@ -0,0 +1,79 @@
329+#!/bin/bash
330+#
331+# Copyright (C) 2016 Canonical Ltd
332+#
333+# This program is free software: you can redistribute it and/or modify
334+# it under the terms of the GNU General Public License version 3 as
335+# published by the Free Software Foundation.
336+#
337+# This program is distributed in the hope that it will be useful,
338+# but WITHOUT ANY WARRANTY; without even the implied warranty of
339+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
340+# GNU General Public License for more details.
341+#
342+# You should have received a copy of the GNU General Public License
343+# along with this program. If not, see <http://www.gnu.org/licenses/>.
344+
345+set -e
346+
347+TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/tests-extras"
348+TESTS_EXTRAS_PATH=".tests-extras"
349+
350+# Display help.
351+# This has to be in sync with the tests-extras/test-runner.sh script
352+# functionalities as the parameters to this one are passed directly there
353+show_help() {
354+ echo "Usage: run-tests.sh [OPTIONS]"
355+ echo
356+ echo "This is fetch & forget script and what it does is to fetch the"
357+ echo "tests-extras repository and execute the run-tests.sh script from"
358+ echo "there passing arguments as-is."
359+ echo
360+ echo "optional arguments:"
361+ echo " --help Show this help message and exit"
362+ echo " --channel Select another channel to build the base image from (default: stable)"
363+ echo " --snap Extra snap to install"
364+ echo " --debug Enable verbose debugging output"
365+ echo " --test-from-channel Pull network-manager snap from the specified channel instead of building it from source"
366+ echo " --force-new-image Force generating a new image used for testing"
367+}
368+
369+# Clone the tests-extras repository
370+clone_tests_extras() {
371+ echo "INFO: Fetching tests-extras scripts into $TESTS_EXTRAS_PATH ..."
372+ (git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1)
373+ if [ $? -ne 0 ]; then
374+ echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."
375+ exit 1
376+ fi
377+}
378+
379+# Make sure the already cloned tests-extras repository is in a known and update
380+# state before it is going to be used.
381+restore_and_update_tests_extras() {
382+ echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH"
383+ (cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull)
384+ (cd ..)
385+}
386+
387+# ==============================================================================
388+# This is fetch & forget script and what it does is to fetch the tests-extras
389+# repo and execute the run-tests.sh script from there passing arguments as-is.
390+#
391+# The tests-extras repository ends up checked out in the snap tree but as a
392+# hidden directory which is re-used since then.
393+
394+# Display help w/o fetching anything
395+if [ "$1" == "--help" ]; then
396+ show_help
397+ exit 0
398+fi
399+
400+if [ -d "$TESTS_EXTRAS_PATH" ]; then
401+ restore_and_update_tests_extras
402+else
403+ clone_tests_extras
404+fi
405+
406+echo "INFO: Executing tests runner"
407+cd $TESTS_EXTRAS_PATH && ./tests-runner.sh $@
408diff --git a/tests-runner.sh b/tests-runner.sh
409new file mode 100755
410index 0000000..20c6c76
411--- /dev/null
412+++ b/tests-runner.sh
413@@ -0,0 +1,96 @@
414+#!/bin/sh
415+#
416+# Copyright (C) 2016 Canonical Ltd
417+#
418+# This program is free software: you can redistribute it and/or modify
419+# it under the terms of the GNU General Public License version 3 as
420+# published by the Free Software Foundation.
421+#
422+# This program is distributed in the hope that it will be useful,
423+# but WITHOUT ANY WARRANTY; without even the implied warranty of
424+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
425+# GNU General Public License for more details.
426+#
427+# You should have received a copy of the GNU General Public License
428+# along with this program. If not, see <http://www.gnu.org/licenses/>.
429+
430+set -e
431+
432+image_name=ubuntu-core-16.img
433+channel=stable
434+snap=
435+spread_opts=
436+force_new_image=0
437+test_from_channel=0
438+
439+show_help() {
440+ echo "Usage: run-tests.sh [OPTIONS]"
441+ echo
442+ echo "Uses spread to execute tests. If required or prompted can generate"
443+ echo "Ubuntu Core image for testing."
444+ echo
445+ echo "optional arguments:"
446+ echo " --help Show this help message and exit"
447+ echo " --channel Select another channel to build the base image from (default: $channel)"
448+ echo " --snap Extra snap to install"
449+ echo " --debug Enable verbose debugging output"
450+ echo " --test-from-channel Pull network-manager snap from the specified channel instead of building it from source"
451+ echo " --force-new-image Force generating a new image used for testing"
452+}
453+
454+while [ -n "$1" ]; do
455+ case "$1" in
456+ --help)
457+ show_help
458+ exit
459+ ;;
460+ --channel=*)
461+ channel=${1#*=}
462+ shift
463+ ;;
464+ --snap=*)
465+ snap=${1#*=}
466+ shift
467+ ;;
468+ --test-from-channel)
469+ test_from_channel=1
470+ shift
471+ ;;
472+ --debug)
473+ spread_opts="$spread_opts -vv -debug"
474+ shift
475+ ;;
476+ --force-new-image)
477+ force_new_image=1
478+ shift
479+ ;;
480+ *)
481+ echo "Unknown command: $1"
482+ exit 1
483+ ;;
484+ esac
485+done
486+
487+SPREAD_QEMU_PATH="$HOME/.spread/qemu"
488+if [ $(which spread) = /snap/bin/spread ] ; then
489+ current_version=`readlink /snap/spread/current`
490+ SPREAD_QEMU_PATH="$HOME/snap/spread/$current_version/.spread/qemu/"
491+fi
492+
493+# Make sure we have a base image we use for testing
494+if [ ! -e $SPREAD_QEMU_PATH/$image_name ] || [ $force_new_image -eq 1 ] ; then
495+
496+ CREATE_IMAGE_PATH="./create-image-scripts"
497+
498+ echo "INFO: Creating new qemu test image ..."
499+ (cd $CREATE_IMAGE_PATH; sudo ./create-image.sh $channel $snap)
500+ mkdir -p $SPREAD_QEMU_PATH
501+ mv $CREATE_IMAGE_PATH/ubuntu-core-16.img $SPREAD_QEMU_PATH/$image_name
502+fi
503+
504+# We currently only run spread tests but we could do other things
505+# here as well like running our snap-lintian tool etc.
506+if [ $test_from_channel -eq 1 ] ; then
507+ export SNAP_CHANNEL=$channel
508+fi
509+spread $spread_opts

Subscribers

People subscribed via source and target branches