Merge ~morphis/snappy-hwe-snaps/+git/wifi-ap:feature/config-disable-by-default into ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master

Proposed by Simon Fels on 2017-02-01
Status: Superseded
Proposed branch: ~morphis/snappy-hwe-snaps/+git/wifi-ap:feature/config-disable-by-default
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master
Diff against target: 177 lines (+98/-18)
6 files modified
hooks/configure (+27/-0)
snapcraft.yaml (+6/-0)
tests/image/create-image.sh (+3/-0)
tests/lib/prepare.sh (+3/-18)
tests/lib/utilities.sh (+21/-0)
tests/main/conf-wizard-disabled-by-default/task.yaml (+38/-0)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration 2017-02-01 Needs Fixing on 2017-02-01
Matteo Croce 2017-02-01 Pending
Review via email: mp+316103@code.launchpad.net

This proposal has been superseded by a proposal from 2017-02-01.

Description of the Change

Add configure option to allow disabling automatic setup from the gadget snap

The test case needs to stay manual until a first version of the snap
with a configure hook is released into edge.

To post a comment you must log in.
review: Needs Fixing (continuous-integration)
Simon Fels (morphis) wrote :

Please hold-off reviewing this as the state of this MP doesn't reflect what is pushed in the git repository. There seems to be a quite huge delay within the launchpad infrastructure today.

Unmerged commits

1dab7f1... by Simon Fels on 2017-01-27

Add configure option to allow disabling automatic setup from the gadget snap

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/configure b/hooks/configure
2new file mode 100755
3index 0000000..138635d
4--- /dev/null
5+++ b/hooks/configure
6@@ -0,0 +1,27 @@
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 -x
24+
25+# The 'automatic-setup.disabled' option is only meant to be used from
26+# a gadget snap to prevent the wizard on running when the snap is
27+# being installed. As the configure hook will be called before the
28+# services are being started we can easily create a empty
29+# configuration to fallback to the default one for everything.
30+value=`snapctl get automatic-setup.disable`
31+if [ -n "$value" ]; then
32+ echo "# Empty default config" > $SNAP_DATA/.config
33+fi
34diff --git a/snapcraft.yaml b/snapcraft.yaml
35index 6123d4b..a3e20db 100644
36--- a/snapcraft.yaml
37+++ b/snapcraft.yaml
38@@ -45,6 +45,12 @@ apps:
39 - network
40
41 parts:
42+ hooks:
43+ plugin: dump
44+ source: hooks
45+ organize:
46+ configure: meta/hooks/configure
47+
48 common:
49 plugin: dump
50 source: .
51diff --git a/tests/image/create-image.sh b/tests/image/create-image.sh
52index 33c1a37..5e68bc7 100755
53--- a/tests/image/create-image.sh
54+++ b/tests/image/create-image.sh
55@@ -40,8 +40,11 @@ if [ ! -z "$snap" ] ; then
56 ubuntu_image_extra_args="--extra-snaps $snap"
57 fi
58
59+snap download --stable pc
60+
61 ubuntu-image \
62 --channel $channel \
63+ --extra-snaps pc_*.snap \
64 -o $image_name \
65 --image-size 4G \
66 $ubuntu_image_extra_args \
67diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
68index b95e884..d4b7020 100644
69--- a/tests/lib/prepare.sh
70+++ b/tests/lib/prepare.sh
71@@ -1,5 +1,7 @@
72 #!/bin/bash
73
74+. $TESTSLIB/utilities.sh
75+
76 echo "Wait for firstboot change to be ready"
77 while ! snap changes | grep -q "Done"; do
78 snap changes || true
79@@ -21,24 +23,7 @@ done
80 echo "Kernel has a store revision"
81 snap list | grep ^${kernel_name} | grep -E " [0-9]+\s+canonical"
82
83-# If we don't install wifi-ap here we get a system
84-# without any network connectivity after reboot.
85-if [ -n "$SNAP_CHANNEL" ] ; then
86- # Don't reinstall if we have it installed already
87- if ! snap list | grep wifi-ap ; then
88- snap install --$SNAP_CHANNEL wifi-ap
89- fi
90-else
91- # Install prebuilt wifi-ap snap
92- snap install --dangerous /home/wifi-ap/wifi-ap_*_amd64.snap
93- # As we have a snap which we build locally it's unasserted and therefore
94- # we don't have any snap-declarations in place and need to manually
95- # connect all plugs.
96- snap connect wifi-ap:network-control core
97- snap connect wifi-ap:network-bind core
98- snap connect wifi-ap:network core
99- snap connect wifi-ap:firewall-control core
100-fi
101+install_snap_under_test
102
103 # Snapshot of the current snapd state for a later restore
104 if [ ! -f $SPREAD_PATH/snapd-state.tar.gz ] ; then
105diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
106index 9e2513e..83f2e9e 100644
107--- a/tests/lib/utilities.sh
108+++ b/tests/lib/utilities.sh
109@@ -24,3 +24,24 @@ wait_until_interface_is_available() {
110 sleep 0.2
111 done
112 }
113+
114+install_snap_under_test() {
115+ # If we don't install wifi-ap here we get a system
116+ # without any network connectivity after reboot.
117+ if [ -n "$SNAP_CHANNEL" ] ; then
118+ # Don't reinstall if we have it installed already
119+ if ! snap list | grep wifi-ap ; then
120+ snap install --$SNAP_CHANNEL wifi-ap
121+ fi
122+ else
123+ # Install prebuilt wifi-ap snap
124+ snap install --dangerous /home/wifi-ap/wifi-ap_*_amd64.snap
125+ # As we have a snap which we build locally it's unasserted and therefore
126+ # we don't have any snap-declarations in place and need to manually
127+ # connect all plugs.
128+ snap connect wifi-ap:network-control core
129+ snap connect wifi-ap:network-bind core
130+ snap connect wifi-ap:network core
131+ snap connect wifi-ap:firewall-control core
132+ fi
133+}
134diff --git a/tests/main/conf-wizard-disabled-by-default/task.yaml b/tests/main/conf-wizard-disabled-by-default/task.yaml
135new file mode 100644
136index 0000000..3c066ac
137--- /dev/null
138+++ b/tests/main/conf-wizard-disabled-by-default/task.yaml
139@@ -0,0 +1,38 @@
140+summary: Verify the wizard can be disabled by default from a gadget snap
141+
142+prepare: |
143+ . $TESTSLIB/snap-names.sh
144+ snap list | grep $gadget_name | awk '{print $2}' > /tmp/gadget_version
145+
146+restore: |
147+ . $TESTSLIB/snap-names.sh
148+ # Restore the original gadget snap so that any following tests don't suffer
149+ # from our modified gadget.
150+ original_revision=`cat /tmp/gadget_version`
151+ current_revision=`snap list | grep $gadget_name | awk '{print $2}'`
152+ if [ $current_revision -ne $original_revision ]; then
153+ snap revert --revision=$original_revision $gadget_name
154+ fi
155+
156+execute: |
157+ . $TESTSLIB/snap-names.sh
158+ . $TESTSLIB/utilities.sh
159+
160+ snap remove wifi-ap
161+ snap install --edge --devmode se-test-tools
162+
163+ # We need a custom gadget snap for this so lets fetch one from the store
164+ # and modify it.
165+ snap download --stable $gadget_name
166+ /snap/bin/se-test-tools.unsquashfs -d gadget ${gadget_name}_*.snap
167+ cat << EOF >> gadget/meta/snap.yaml
168+ defaults:
169+ wifi-ap:
170+ automatic-setup.disable: true
171+ EOF
172+ /snap/bin/se-test-tools.mksquashfs gadget $gadget_name.snap -comp xz -no-xattrs
173+ snap install --dangerous $gadget_name.snap
174+
175+ install_snap_under_test
176+
177+ test "$(snap get wifi-ap automatic-setup.disable)" = "true"

Subscribers

People subscribed via source and target branches

to all changes: