Merge ~teknoraver/snappy-hwe-snaps/+git/wifi-ap:master into ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master

Proposed by Matteo Croce
Status: Merged
Approved by: Simon Fels
Approved revision: 9653e41ef496b94d6e4683a161b2be29e04fbf74
Merged at revision: 511e88386eb6f69f681b25ec79fb1be209bc6ac0
Proposed branch: ~teknoraver/snappy-hwe-snaps/+git/wifi-ap:master
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master
Prerequisite: ~morphis/snappy-hwe-snaps/+git/wifi-ap:merge-mgmt-and-ap
Diff against target: 428 lines (+111/-70)
18 files modified
bin/ap.sh (+1/-1)
bin/automatic-setup.sh (+25/-0)
bin/helper.sh (+4/-4)
snapcraft.yaml (+6/-0)
tests/lib/prepare-all.sh (+2/-0)
tests/lib/prepare.sh (+2/-2)
tests/lib/restore-each.sh (+11/-0)
tests/lib/utilities.sh (+18/-0)
tests/main/background-process-control/task.yaml (+2/-11)
tests/main/conf-wizard-auto-at-boot/task.yaml (+21/-0)
tests/main/conf-wizard-auto-nodefaultip/task.yaml (+6/-6)
tests/main/conf-wizard-auto-noip/task.yaml (+3/-6)
tests/main/conf-wizard-auto-nowifi/task.yaml (+5/-2)
tests/main/conf-wizard-auto/task.yaml (+1/-9)
tests/main/configuration-changes/task.yaml (+3/-3)
tests/main/default-conf-brings-up-ap/task.yaml (+1/-11)
tests/main/stress-ap-status-control/task.yaml (+0/-6)
tests/main/utf8-ssid/task.yaml (+0/-9)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Jim Hodapp (community) Approve
Simon Fels Approve
Review via email: mp+312068@code.launchpad.net

This proposal supersedes a proposal from 2016-11-29.

Description of the change

Run wizard during first boot.

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
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) :
review: Needs Fixing
Revision history for this message
Matteo Croce (teknoraver) :
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 :

Small change inline below.

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
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (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
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
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: Approve (continuous-integration)
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) :
review: Needs Fixing
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
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 :

Two last comments inline.

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

Lets wait for the CI to give this a last pass and then we can merge.

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 :

Due to hickups in the CI infrastructure the above one is incorrect. The real run is https://jenkins.canonical.com/system-enablement/job/generic-run-snap-spread-tests/190/console

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

My requested change looks good although there are 4 spread tests currently failing.

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
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
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
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/bin/ap.sh b/bin/ap.sh
2index b98cfe0..4fd35e8 100755
3--- a/bin/ap.sh
4+++ b/bin/ap.sh
5@@ -87,7 +87,7 @@ if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then
6 # Make sure if the real wifi interface is connected we use
7 # the same channel for our AP as otherwise the created AP
8 # will not work.
9- channel_in_use=$(iw dev $WIFI_INTERFACE info |awk '/channel/{print$2}')
10+ channel_in_use=$($SNAP/bin/iw dev $WIFI_INTERFACE info |awk '/channel/{print$2}')
11 if [ "$channel_in_use" != "$WIFI_CHANNEL" ] ; then
12 echo "ERROR: You configured a different channel than the WiFi device"
13 echo " is currently using. This will not work as most devices"
14diff --git a/bin/automatic-setup.sh b/bin/automatic-setup.sh
15new file mode 100755
16index 0000000..9a93954
17--- /dev/null
18+++ b/bin/automatic-setup.sh
19@@ -0,0 +1,25 @@
20+#!/bin/sh
21+#
22+# Copyright (C) 2016 Canonical Ltd
23+#
24+# This program is free software: you can redistribute it and/or modify
25+# it under the terms of the GNU General Public License version 3 as
26+# published by the Free Software Foundation.
27+#
28+# This program is distributed in the hope that it will be useful,
29+# but WITHOUT ANY WARRANTY; without even the implied warranty of
30+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+# GNU General Public License for more details.
32+#
33+# You should have received a copy of the GNU General Public License
34+# along with this program. If not, see <http://www.gnu.org/licenses/>.
35+
36+set -x
37+
38+[ -f "$SNAP_DATA/config" ] && exit 0
39+
40+while ! $SNAP/bin/client status; do
41+ sleep .5
42+done
43+
44+exec $SNAP/bin/client wizard --auto
45diff --git a/bin/helper.sh b/bin/helper.sh
46index 4a557d6..f535325 100644
47--- a/bin/helper.sh
48+++ b/bin/helper.sh
49@@ -17,13 +17,13 @@
50 set -x
51
52 does_interface_exist() {
53- grep -q $1 /proc/net/dev
54+ [ -d /sys/class/net/$1 ]
55 }
56
57 wait_until_interface_is_available() {
58- while ! does_interface_exist $iface; do
59- # Wait for 10ms
60- sleep 0.01
61+ while ! does_interface_exist $1; do
62+ # Wait for 200ms
63+ sleep 0.2
64 done
65 }
66
67diff --git a/snapcraft.yaml b/snapcraft.yaml
68index d4d41d5..3168ff0 100644
69--- a/snapcraft.yaml
70+++ b/snapcraft.yaml
71@@ -31,6 +31,11 @@ apps:
72 - network-control
73 - firewall-control
74 - network-manager
75+ automatic-setup:
76+ command: bin/automatic-setup.sh
77+ daemon: simple
78+ plugs:
79+ - network
80
81 parts:
82 common:
83@@ -41,6 +46,7 @@ parts:
84 - bin/config-internal.sh
85 - bin/ap.sh
86 - bin/helper.sh
87+ - bin/automatic-setup.sh
88 - conf/default-config
89
90 network-utils:
91diff --git a/tests/lib/prepare-all.sh b/tests/lib/prepare-all.sh
92index 59e1349..52d622a 100644
93--- a/tests/lib/prepare-all.sh
94+++ b/tests/lib/prepare-all.sh
95@@ -12,6 +12,8 @@ if [ -e /home/wifi-ap/wifi-ap_*_amd64.snap ] ; then
96 exit 0
97 fi
98
99+# Simulate two WiFi radio network interfaces
100+modprobe mac80211_hwsim radios=2
101
102 # Setup classic snap and build the wifi-ap snap in there
103 snap install --devmode --beta classic
104diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
105index 55129b3..b95e884 100644
106--- a/tests/lib/prepare.sh
107+++ b/tests/lib/prepare.sh
108@@ -31,7 +31,7 @@ if [ -n "$SNAP_CHANNEL" ] ; then
109 else
110 # Install prebuilt wifi-ap snap
111 snap install --dangerous /home/wifi-ap/wifi-ap_*_amd64.snap
112- # As we have a snap which we build locally its unasserted and therefor
113+ # As we have a snap which we build locally it's unasserted and therefore
114 # we don't have any snap-declarations in place and need to manually
115 # connect all plugs.
116 snap connect wifi-ap:network-control core
117@@ -49,4 +49,4 @@ fi
118
119 # For debugging dump all snaps and connected slots/plugs
120 snap list
121-snap interfaces
122\ No newline at end of file
123+snap interfaces
124diff --git a/tests/lib/restore-each.sh b/tests/lib/restore-each.sh
125index 1193b58..fa474b4 100644
126--- a/tests/lib/restore-each.sh
127+++ b/tests/lib/restore-each.sh
128@@ -22,6 +22,7 @@ rm -rf /var/snap/$SNAP_NAME/current/*
129 # Depending on what the test did both services are not meant to be
130 # running here.
131 systemctl stop snap.wifi-ap.management-service || true
132+wait_for_systemd_service_exit snap.wifi-ap.management-service
133
134 # Drop any generated or modified netplan configuration files. The original
135 # ones will be restored below.
136@@ -41,3 +42,13 @@ netplan apply
137 # Start services again now that the system is restored
138 systemctl start snap.wifi-ap.management-service
139 wait_for_systemd_service snap.wifi-ap.management-service
140+
141+# remove and reinsert the module to refresh all the wifi network settings
142+rmmod mac80211_hwsim || true
143+modprobe mac80211_hwsim radios=2
144+wait_until_interface_is_available wlan0
145+wait_until_interface_is_available wlan1
146+
147+# Wizard should run after snap install
148+systemctl restart snap.wifi-ap.automatic-setup
149+wait_for_systemd_service_exit snap.wifi-ap.automatic-setup
150diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
151index 0e4c455..9e2513e 100644
152--- a/tests/lib/utilities.sh
153+++ b/tests/lib/utilities.sh
154@@ -6,3 +6,21 @@ wait_for_systemd_service() {
155 done
156 sleep 1
157 }
158+
159+wait_for_systemd_service_exit() {
160+ while systemctl status $1 ; do
161+ sleep 1
162+ done
163+ sleep 1
164+}
165+
166+does_interface_exist() {
167+ [ -d /sys/class/net/$1 ]
168+}
169+
170+wait_until_interface_is_available() {
171+ while ! does_interface_exist $1; do
172+ # Wait for 200ms
173+ sleep 0.2
174+ done
175+}
176diff --git a/tests/main/background-process-control/task.yaml b/tests/main/background-process-control/task.yaml
177index a1b62fa..58dd047 100644
178--- a/tests/main/background-process-control/task.yaml
179+++ b/tests/main/background-process-control/task.yaml
180@@ -1,27 +1,18 @@
181 summary: Test correct service behavior to ensure the background AP process is running
182
183 prepare: |
184- # Simulate two WiFi radio network interfaces
185- modprobe mac80211_hwsim radios=2
186-
187 # We need some tools for scanning etc.
188 snap install wireless-tools
189 snap connect wireless-tools:network-control core
190
191-restore: |
192- rmmod mac80211_hwsim
193-
194 execute: |
195 # Verify first the management service is up and running
196 /snap/bin/wifi-ap.config get
197- test "`/snap/bin/wifi-ap.config get disabled`" = true
198+ test "`/snap/bin/wifi-ap.config get disabled`" = false
199
200 # AP should be not active at this time as still disabled
201- /snap/bin/wifi-ap.status | grep "ap.active: false"
202-
203- # Now start the AP and ensure its reported as active
204- /snap/bin/wifi-ap.config set disabled false
205 /snap/bin/wifi-ap.status | grep "ap.active: true"
206+
207 # And if we wait a bit more it should be still active
208 sleep 5
209 /snap/bin/wifi-ap.status | grep "ap.active: true"
210diff --git a/tests/main/conf-wizard-auto-at-boot/task.yaml b/tests/main/conf-wizard-auto-at-boot/task.yaml
211new file mode 100644
212index 0000000..b042097
213--- /dev/null
214+++ b/tests/main/conf-wizard-auto-at-boot/task.yaml
215@@ -0,0 +1,21 @@
216+summary: Verify that the automatic wizard works
217+
218+execute: |
219+ # Check that we get good default values
220+ test "$(/snap/bin/wifi-ap.config get disabled)" = false
221+
222+ test "$(/snap/bin/wifi-ap.config get wifi.interface)" = wlan0
223+ test "$(/snap/bin/wifi-ap.config get wifi.security)" = open
224+ test "$(/snap/bin/wifi-ap.config get wifi.ssid)" = Ubuntu
225+ test "$(/snap/bin/wifi-ap.config get wifi.address)" = 10.0.60.1
226+
227+ test "$(/snap/bin/wifi-ap.config get dhcp.range-start)" = 10.0.60.2
228+ test "$(/snap/bin/wifi-ap.config get dhcp.range-stop)" = 10.0.60.199
229+
230+ default_route=$(ip route |awk '/default/{print$5}')
231+ if [ -n "$default_route" ]; then
232+ test "$(/snap/bin/wifi-ap.config get share.disabled)" = false
233+ test "$(/snap/bin/wifi-ap.config get share.network-interface)" = "$default_route"
234+ else
235+ test "$(/snap/bin/wifi-ap.config get share.disabled)" = true
236+ fi
237diff --git a/tests/main/conf-wizard-auto-nodefaultip/task.yaml b/tests/main/conf-wizard-auto-nodefaultip/task.yaml
238index e6d6e06..8be2f75 100644
239--- a/tests/main/conf-wizard-auto-nodefaultip/task.yaml
240+++ b/tests/main/conf-wizard-auto-nodefaultip/task.yaml
241@@ -1,9 +1,6 @@
242 summary: Verify that the wizard is able to find an unused IP
243
244 prepare: |
245- # Simulate a radio network interfaces
246- modprobe mac80211_hwsim radios=1
247-
248 # Dummy interface to assign an IP to
249 modprobe dummy
250
251@@ -12,11 +9,14 @@ prepare: |
252 ifconfig dummy0 10.0.48.2/20
253
254 restore: |
255- rmmod mac80211_hwsim dummy
256+ rmmod dummy
257
258 execute: |
259- # Start the automatic wizard, it must fail
260- /snap/bin/wifi-ap.setup-wizard wizard --auto
261+ # Free the actual IP
262+ ifconfig wlan0 0.0.0.0
263+
264+ # Start the automatic wizard
265+ /snap/bin/wifi-ap.setup-wizard --auto
266
267 # Check for assigned IP on subnet 10.0.64.0/24
268 test "$(/snap/bin/wifi-ap.config get wifi.address)" = 10.0.64.1
269diff --git a/tests/main/conf-wizard-auto-noip/task.yaml b/tests/main/conf-wizard-auto-noip/task.yaml
270index 5a0885c..10822e1 100644
271--- a/tests/main/conf-wizard-auto-noip/task.yaml
272+++ b/tests/main/conf-wizard-auto-noip/task.yaml
273@@ -1,9 +1,6 @@
274 summary: Verify that wizard fails when all private subnets are busy
275
276 prepare: |
277- # Simulate a radio network interfaces
278- modprobe mac80211_hwsim radios=1
279-
280 # Dummy interface to assign an IP to
281 modprobe dummy
282
283@@ -11,11 +8,11 @@ prepare: |
284 ifconfig dummy0 10.0.0.2/8
285
286 restore: |
287- rmmod mac80211_hwsim dummy
288+ rmmod dummy
289
290 execute: |
291 # Start the automatic wizard, it must fail
292- ! /snap/bin/wifi-ap.setup-wizard wizard --auto
293+ ! /snap/bin/wifi-ap.setup-wizard --auto
294
295 # Check for a descriptive error message
296- /snap/bin/wifi-ap.setup-wizard wizard --auto 2>&1 |grep 'No free netmask found'
297+ /snap/bin/wifi-ap.setup-wizard --auto 2>&1 |grep 'No free netmask found'
298diff --git a/tests/main/conf-wizard-auto-nowifi/task.yaml b/tests/main/conf-wizard-auto-nowifi/task.yaml
299index 18301f1..ce89798 100644
300--- a/tests/main/conf-wizard-auto-nowifi/task.yaml
301+++ b/tests/main/conf-wizard-auto-nowifi/task.yaml
302@@ -1,8 +1,11 @@
303 summary: Verify that wizard fails when there are no WiFi devices
304
305+prepare: |
306+ rmmod mac80211_hwsim
307+
308 execute: |
309 # Start the automatic wizard, it must fail
310- ! /snap/bin/wifi-ap.setup-wizard wizard --auto
311+ ! /snap/bin/wifi-ap.setup-wizard --auto
312
313 # Check for a descriptive error message
314- /snap/bin/wifi-ap.setup-wizard wizard --auto 2>&1 |grep 'There are no valid wireless network interfaces available'
315+ /snap/bin/wifi-ap.setup-wizard --auto 2>&1 |grep 'There are no valid wireless network interfaces available'
316diff --git a/tests/main/conf-wizard-auto/task.yaml b/tests/main/conf-wizard-auto/task.yaml
317index bdda246..ae6219c 100644
318--- a/tests/main/conf-wizard-auto/task.yaml
319+++ b/tests/main/conf-wizard-auto/task.yaml
320@@ -1,15 +1,7 @@
321 summary: Verify that the automatic wizard works
322
323-prepare: |
324- # Simulate two WiFi radio network interfaces
325- modprobe mac80211_hwsim radios=2
326-
327-restore: |
328- rmmod mac80211_hwsim
329-
330 execute: |
331- # Start the automatic wizard
332- /snap/bin/wifi-ap.setup-wizard wizard --auto
333+ # The automatic wizard was already started
334
335 # Check that we get good default values
336 test "$(/snap/bin/wifi-ap.config get disabled)" = false
337diff --git a/tests/main/configuration-changes/task.yaml b/tests/main/configuration-changes/task.yaml
338index 07c2e09..61f55a0 100644
339--- a/tests/main/configuration-changes/task.yaml
340+++ b/tests/main/configuration-changes/task.yaml
341@@ -5,10 +5,10 @@ execute: |
342 /snap/bin/wifi-ap.config set wifi.interface wlan1
343 test "`/snap/bin/wifi-ap.config get wifi.interface`" = "wlan1"
344
345- test `/snap/bin/wifi-ap.config get disabled` = true
346- /snap/bin/wifi-ap.config set disabled false
347- # Verify 'disabled' was safed and change to 'wifi.interface' is still there
348 test `/snap/bin/wifi-ap.config get disabled` = false
349+ /snap/bin/wifi-ap.config set disabled true
350+ # Verify 'disabled' was saved and change to 'wifi.interface' is still there
351+ test `/snap/bin/wifi-ap.config get disabled` = true
352 test "`/snap/bin/wifi-ap.config get wifi.interface`" = "wlan1"
353
354 ! /snap/bin/wifi-ap.config set
355diff --git a/tests/main/default-conf-brings-up-ap/task.yaml b/tests/main/default-conf-brings-up-ap/task.yaml
356index ed9fcf3..820a695 100644
357--- a/tests/main/default-conf-brings-up-ap/task.yaml
358+++ b/tests/main/default-conf-brings-up-ap/task.yaml
359@@ -1,18 +1,8 @@
360 summary: Verify that the default configuration is able to spawn up an AP
361
362-prepare: |
363- # Simulate two WiFi radio network interfaces
364- modprobe mac80211_hwsim radios=2
365-
366-restore: |
367- rmmod mac80211_hwsim
368-
369 execute: |
370 . $TESTSLIB/utilities.sh
371
372- # Default configuration will use wlan0 which we just created
373- /snap/bin/wifi-ap.config set disabled false
374-
375 snap install wireless-tools
376 snap connect wireless-tools:network-control core
377
378@@ -35,6 +25,6 @@ execute: |
379 # And we should get an IP address assigned over DHCP
380 dhclient wlan1
381 # IP Address and routing needs to be correct
382- ifconfig wlan1 | fgrep 'inet addr:10.0.60.1'
383+ ifconfig wlan1 | fgrep 'inet addr:10.0.60'
384 ip route | fgrep '10.0.60.0/24 dev wlan1'
385 ip route | fgrep 'default via 10.0.60.1 dev wlan1'
386diff --git a/tests/main/stress-ap-status-control/task.yaml b/tests/main/stress-ap-status-control/task.yaml
387index 38fe709..83876ff 100644
388--- a/tests/main/stress-ap-status-control/task.yaml
389+++ b/tests/main/stress-ap-status-control/task.yaml
390@@ -5,16 +5,10 @@ environment:
391 SCAN_ITERATIONS: 10
392
393 prepare: |
394- # Simulate two WiFi radio network interfaces
395- modprobe mac80211_hwsim radios=2
396-
397 # We need some tools for scanning etc.
398 snap install wireless-tools
399 snap connect wireless-tools:network-control core
400
401-restore: |
402- rmmod mac80211_hwsim
403-
404 execute: |
405 # Bring up the access point first
406 /snap/bin/wifi-ap.config set disabled false
407diff --git a/tests/main/utf8-ssid/task.yaml b/tests/main/utf8-ssid/task.yaml
408index 6d190c6..a9714c3 100644
409--- a/tests/main/utf8-ssid/task.yaml
410+++ b/tests/main/utf8-ssid/task.yaml
411@@ -1,17 +1,8 @@
412 summary: Verify that the AP can accept an UTF8 SSID
413
414-prepare: |
415- # Simulate two WiFi radio network interfaces
416- modprobe mac80211_hwsim radios=2
417-
418-restore: |
419- rmmod mac80211_hwsim
420-
421 execute: |
422 . $TESTSLIB/utilities.sh
423
424- wait_for_systemd_service snap.wifi-ap.management-service
425-
426 # Default configuration will use wlan0 which we just created
427 /snap/bin/wifi-ap.config set wifi.ssid 'Ubuntu👍'
428 /snap/bin/wifi-ap.config set disabled false

Subscribers

People subscribed via source and target branches

to all changes: