Merge ~morphis/snappy-hwe-snaps/+git/network-manager:powersave-configuration into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master
- Git
- lp:~morphis/snappy-hwe-snaps/+git/network-manager
- powersave-configuration
- Merge into master
Status: | Merged |
---|---|
Approved by: | Simon Fels |
Approved revision: | 639d7ce78b40bea7ac3db467a76fb95578346b6e |
Merged at revision: | 0be7e8ba7b2d2243c45c3fe119ad3f7e18419685 |
Proposed branch: | ~morphis/snappy-hwe-snaps/+git/network-manager:powersave-configuration |
Merge into: | ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master |
Diff against target: |
277 lines (+124/-37) 9 files modified
README.md (+15/-0) hooks/configure (+33/-0) spread.yaml (+0/-7) tests/full/wol-enabled-by-default/task.yaml (+1/-1) tests/lib/prepare-all.sh (+6/-0) tests/lib/prepare.sh (+18/-19) tests/lib/restore-each.sh (+7/-10) tests/lib/utilities.sh (+16/-0) tests/main/wifi-powersave-config-option/task.yaml (+28/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
System Enablement Bot | continuous-integration | Approve | |
Jim Hodapp (community) | Approve | ||
Alfonso Sanchez-Beato | Approve | ||
Tony Espy | Pending | ||
Review via email: mp+312898@code.launchpad.net |
Commit message
Description of the change
Implement configure hook to accept wifi.powersave option.
This will default to "disable" to keep powersave mode off.
The hook itself isn't enabled in the default snap build yet because snapcraft doesn't support hooks yet. In the spread test we're copying the hook manually in place to be able to test it properly.
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:23eb8bed670
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:23eb8bed670
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1a18e306888
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1a18e306888
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:ae76ecdf3be
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:ae76ecdf3be
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
LGTM
Jim Hodapp (jhodapp) wrote : | # |
One minor typo to fix, see inline below.
Simon Fels (morphis) wrote : | # |
@Jim: Fixed.
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:0546274e511
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:0546274e511
https:/
Executed test runs:
ABORTED: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:0546274e511
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:b51386d3848
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:b51386d3848
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:639d7ce78b4
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:639d7ce78b4
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | diff --git a/README.md b/README.md | |||
2 | index a8fec2f..8b92863 100644 | |||
3 | --- a/README.md | |||
4 | +++ b/README.md | |||
5 | @@ -2,6 +2,21 @@ | |||
6 | 2 | 2 | ||
7 | 3 | This is the snap to package the NetworkManager management service. | 3 | This is the snap to package the NetworkManager management service. |
8 | 4 | 4 | ||
9 | 5 | ## Hook support | ||
10 | 6 | |||
11 | 7 | All implemented hooks are stored inside the hooks directory. | ||
12 | 8 | |||
13 | 9 | As snapcraft has no support as of today (09/12/2016) to include | ||
14 | 10 | hooks in a snap this always needs to be done manually. For this | ||
15 | 11 | |||
16 | 12 | $ snapcraft | ||
17 | 13 | $ cp -r hooks prime/meta/ | ||
18 | 14 | $ snapcraft snap prime | ||
19 | 15 | |||
20 | 16 | does the job. Please note that none of the snaps available from the | ||
21 | 17 | store will have these hooks included until snapcraft receives | ||
22 | 18 | support for hooks. | ||
23 | 19 | |||
24 | 5 | ## Running tests | 20 | ## Running tests |
25 | 6 | 21 | ||
26 | 7 | We have a set of spread (https://github.com/snapcore/spread) tests which | 22 | We have a set of spread (https://github.com/snapcore/spread) tests which |
27 | diff --git a/hooks/configure b/hooks/configure | |||
28 | 8 | new file mode 100755 | 23 | new file mode 100755 |
29 | index 0000000..1d3399e | |||
30 | --- /dev/null | |||
31 | +++ b/hooks/configure | |||
32 | @@ -0,0 +1,33 @@ | |||
33 | 1 | #!/bin/bash | ||
34 | 2 | wifi_powersave_default="disable" | ||
35 | 3 | wifi_powersave_conf_path=$SNAP_DATA/conf.d/wifi-powersave.conf | ||
36 | 4 | |||
37 | 5 | switch_wifi_powersave() { | ||
38 | 6 | # See https://developer.gnome.org/libnm/stable/NMSettingWireless.html#NMSettingWirelessPowersave | ||
39 | 7 | # for the meaning of the different values for the wifi.powersave option. | ||
40 | 8 | case $1 in | ||
41 | 9 | enable) | ||
42 | 10 | cat << EOF > $wifi_powersave_conf_path | ||
43 | 11 | [connection] | ||
44 | 12 | wifi.powersave = 3 | ||
45 | 13 | EOF | ||
46 | 14 | ;; | ||
47 | 15 | disable) | ||
48 | 16 | cat << EOF > $wifi_powersave_conf_path | ||
49 | 17 | [connection] | ||
50 | 18 | wifi.powersave = 2 | ||
51 | 19 | EOF | ||
52 | 20 | ;; | ||
53 | 21 | *) | ||
54 | 22 | echo "WARNING: invalid value '$1' supplied for wifi.powersave configuration option" | ||
55 | 23 | ;; | ||
56 | 24 | esac | ||
57 | 25 | } | ||
58 | 26 | |||
59 | 27 | wifi_powersave="`snapctl get wifi.powersave`" | ||
60 | 28 | if [ -n "$wifi_powersave" ]; then | ||
61 | 29 | switch_wifi_powersave $wifi_powersave | ||
62 | 30 | else | ||
63 | 31 | snapctl set wifi.powersave=$wifi_powersave_default | ||
64 | 32 | switch_wifi_powersave $wifi_powersave_default | ||
65 | 33 | fi | ||
66 | diff --git a/spread.yaml b/spread.yaml | |||
67 | index d718813..0ae35a2 100644 | |||
68 | --- a/spread.yaml | |||
69 | +++ b/spread.yaml | |||
70 | @@ -55,9 +55,6 @@ suites: | |||
71 | 55 | prepare: | | 55 | prepare: | |
72 | 56 | . $TESTSLIB/utilities.sh | 56 | . $TESTSLIB/utilities.sh |
73 | 57 | stop_after_first_reboot | 57 | stop_after_first_reboot |
74 | 58 | # Force snapd state to be regenerated so that it also preserves | ||
75 | 59 | # the netplan renderer switch configuration file. | ||
76 | 60 | rm -f /home/network-manager/snapd-state.tar.gz | ||
77 | 61 | switch_netplan_to_network_manager | 58 | switch_netplan_to_network_manager |
78 | 62 | . $TESTSLIB/prepare.sh | 59 | . $TESTSLIB/prepare.sh |
79 | 63 | REBOOT | 60 | REBOOT |
80 | @@ -67,8 +64,4 @@ suites: | |||
81 | 67 | . $TESTSLIB/utilities.sh | 64 | . $TESTSLIB/utilities.sh |
82 | 68 | stop_after_first_reboot | 65 | stop_after_first_reboot |
83 | 69 | switch_netplan_to_networkd | 66 | switch_netplan_to_networkd |
84 | 70 | # Need to drop the state here as it includes the netplan config | ||
85 | 71 | # which configures us to use NetworkManager as renderer. The | ||
86 | 72 | # prepare script run for the next suite will regenerate it. | ||
87 | 73 | rm -f /home/network-manager/snapd-state.tar.gz | ||
88 | 74 | REBOOT | 67 | REBOOT |
89 | diff --git a/tests/full/wol-enabled-by-default/task.yaml b/tests/full/wol-enabled-by-default/task.yaml | |||
90 | index 434ef01..4e1989d 100644 | |||
91 | --- a/tests/full/wol-enabled-by-default/task.yaml | |||
92 | +++ b/tests/full/wol-enabled-by-default/task.yaml | |||
93 | @@ -44,7 +44,7 @@ execute: | | |||
94 | 44 | # We can sadly only verify that the value was correctly applied when | 44 | # We can sadly only verify that the value was correctly applied when |
95 | 45 | # we're running the tests on a real device. QEMU doesn't support setting | 45 | # we're running the tests on a real device. QEMU doesn't support setting |
96 | 46 | # the WoL value of the ethernet network device. | 46 | # the WoL value of the ethernet network device. |
98 | 47 | if [ ! cat /proc/cpuinfo | grep QEMU ] ; then | 47 | if [ -z "`cat /proc/cpuinfo | grep QEMU`" ] ; then |
99 | 48 | # Get the tools snap to have the ethtool tool available | 48 | # Get the tools snap to have the ethtool tool available |
100 | 49 | snap install --devmode --edge se-test-tools | 49 | snap install --devmode --edge se-test-tools |
101 | 50 | snap connect se-test-tools:network core | 50 | snap connect se-test-tools:network core |
102 | diff --git a/tests/lib/prepare-all.sh b/tests/lib/prepare-all.sh | |||
103 | index 6632406..f8b2eb2 100644 | |||
104 | --- a/tests/lib/prepare-all.sh | |||
105 | +++ b/tests/lib/prepare-all.sh | |||
106 | @@ -22,6 +22,12 @@ apt install -y --force-yes snapcraft | |||
107 | 22 | cd /home/network-manager | 22 | cd /home/network-manager |
108 | 23 | snapcraft clean | 23 | snapcraft clean |
109 | 24 | snapcraft | 24 | snapcraft |
110 | 25 | # If we have any hooks we need to copy them in place as long as | ||
111 | 26 | # snapcraft does not support them | ||
112 | 27 | if [ -d hooks ]; then | ||
113 | 28 | cp -r hooks prime/meta | ||
114 | 29 | snapcraft snap prime | ||
115 | 30 | fi | ||
116 | 25 | EOF | 31 | EOF |
117 | 26 | chmod +x /home/test/build-snap.sh | 32 | chmod +x /home/test/build-snap.sh |
118 | 27 | sudo classic /home/test/build-snap.sh | 33 | sudo classic /home/test/build-snap.sh |
119 | diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh | |||
120 | index d290bbc..57d24b5 100644 | |||
121 | --- a/tests/lib/prepare.sh | |||
122 | +++ b/tests/lib/prepare.sh | |||
123 | @@ -1,4 +1,5 @@ | |||
124 | 1 | #!/bin/bash | 1 | #!/bin/bash |
125 | 2 | . $TESTSLIB/utilities.sh | ||
126 | 2 | 3 | ||
127 | 3 | echo "Wait for firstboot change to be ready" | 4 | echo "Wait for firstboot change to be ready" |
128 | 4 | while ! snap changes | grep -q "Done"; do | 5 | while ! snap changes | grep -q "Done"; do |
129 | @@ -21,27 +22,25 @@ done | |||
130 | 21 | echo "Kernel has a store revision" | 22 | echo "Kernel has a store revision" |
131 | 22 | snap list | grep ^${kernel_name} | grep -E " [0-9]+\s+canonical" | 23 | snap list | grep ^${kernel_name} | grep -E " [0-9]+\s+canonical" |
132 | 23 | 24 | ||
147 | 24 | # If we don't install network-manager here we get a system | 25 | # Remove any existing state archive from other test suites |
148 | 25 | # without any network connectivity after reboot. | 26 | rm -f /home/network-manager/snapd-state.tar.gz |
149 | 26 | if [ -n "$SNAP_CHANNEL" ] ; then | 27 | rm -f /home/network-manager/nm-state.tar.gz |
150 | 27 | # Don't reinstall if we have it installed already | 28 | |
151 | 28 | if ! snap list | grep network-manager ; then | 29 | snap_install network-manager |
138 | 29 | snap install --$SNAP_CHANNEL network-manager | ||
139 | 30 | fi | ||
140 | 31 | else | ||
141 | 32 | # Need first install from store to get all necessary assertions into | ||
142 | 33 | # place. Second local install will then bring in our locally built | ||
143 | 34 | # snap. | ||
144 | 35 | snap install network-manager | ||
145 | 36 | snap install --dangerous /home/network-manager/network-manager_*_amd64.snap | ||
146 | 37 | fi | ||
152 | 38 | 30 | ||
153 | 39 | # Snapshot of the current snapd state for a later restore | 31 | # Snapshot of the current snapd state for a later restore |
159 | 40 | if [ ! -f $SPREAD_PATH/snapd-state.tar.gz ] ; then | 32 | systemctl stop snapd.service snapd.socket |
160 | 41 | systemctl stop snapd.service snapd.socket | 33 | tar czf $SPREAD_PATH/snapd-state.tar.gz /var/lib/snapd /etc/netplan |
161 | 42 | tar czf $SPREAD_PATH/snapd-state.tar.gz /var/lib/snapd /etc/netplan | 34 | systemctl start snapd.socket |
162 | 43 | systemctl start snapd.socket | 35 | |
163 | 44 | fi | 36 | # And also snapshot NetworkManager's state |
164 | 37 | systemctl stop snap.network-manager.networkmanager | ||
165 | 38 | tar czf $SPREAD_PATH/nm-state.tar.gz /var/snap/network-manager | ||
166 | 39 | systemctl start snap.network-manager.networkmanager | ||
167 | 40 | |||
168 | 41 | # Make sure the original netplan configuration is applied and active | ||
169 | 42 | netplan generate | ||
170 | 43 | netplan apply | ||
171 | 45 | 44 | ||
172 | 46 | # For debugging dump all snaps and connected slots/plugs | 45 | # For debugging dump all snaps and connected slots/plugs |
173 | 47 | snap list | 46 | snap list |
174 | diff --git a/tests/lib/restore-each.sh b/tests/lib/restore-each.sh | |||
175 | index bd397e1..87ae5cb 100644 | |||
176 | --- a/tests/lib/restore-each.sh | |||
177 | +++ b/tests/lib/restore-each.sh | |||
178 | @@ -1,6 +1,7 @@ | |||
179 | 1 | #!/bin/bash | 1 | #!/bin/bash |
180 | 2 | 2 | ||
181 | 3 | . $TESTSLIB/snap-names.sh | 3 | . $TESTSLIB/snap-names.sh |
182 | 4 | . $TESTSLIB/utilities.sh | ||
183 | 4 | 5 | ||
184 | 5 | # Remove all snaps not being the core, gadget, kernel or snap we're testing | 6 | # Remove all snaps not being the core, gadget, kernel or snap we're testing |
185 | 6 | for snap in /snap/*; do | 7 | for snap in /snap/*; do |
186 | @@ -14,12 +15,6 @@ for snap in /snap/*; do | |||
187 | 14 | esac | 15 | esac |
188 | 15 | done | 16 | done |
189 | 16 | 17 | ||
190 | 17 | # Cleanup all configuration files from NetworkManager so that we have | ||
191 | 18 | # a fresh start for the next test | ||
192 | 19 | rm -rf /var/snap/network-manager/common/* | ||
193 | 20 | rm -rf /var/snap/network-manager/current/* | ||
194 | 21 | systemctl stop snap.network-manager.networkmanager | ||
195 | 22 | |||
196 | 23 | # Drop any generated or modified netplan configuration files. The original | 18 | # Drop any generated or modified netplan configuration files. The original |
197 | 24 | # ones will be restored below. | 19 | # ones will be restored below. |
198 | 25 | rm -f /etc/netplan/* | 20 | rm -f /etc/netplan/* |
199 | @@ -27,13 +22,15 @@ rm -f /etc/netplan/* | |||
200 | 27 | # Ensure we have the same state for snapd as we had before | 22 | # Ensure we have the same state for snapd as we had before |
201 | 28 | systemctl stop snapd.service snapd.socket | 23 | systemctl stop snapd.service snapd.socket |
202 | 29 | rm -rf /var/lib/snapd/* | 24 | rm -rf /var/lib/snapd/* |
204 | 30 | $(cd / && tar xzf $SPREAD_PATH/snapd-state.tar.gz) | 25 | tar xzf $SPREAD_PATH/snapd-state.tar.gz -C / |
205 | 31 | rm -rf /root/.snap | 26 | rm -rf /root/.snap |
206 | 32 | systemctl start snapd.service snapd.socket | 27 | systemctl start snapd.service snapd.socket |
207 | 33 | 28 | ||
208 | 29 | systemctl stop snap.network-manager.networkmanager | ||
209 | 30 | rm -rf /var/snap/network-manager/* | ||
210 | 31 | tar xzf $SPREAD_PATH/nm-state.tar.gz -C / | ||
211 | 32 | systemctl start snap.network-manager.networkmanager | ||
212 | 33 | |||
213 | 34 | # Make sure the original netplan configuration is applied and active | 34 | # Make sure the original netplan configuration is applied and active |
214 | 35 | netplan generate | 35 | netplan generate |
215 | 36 | netplan apply | 36 | netplan apply |
216 | 37 | |||
217 | 38 | # Bringup NetworkManager again now that the system is restored | ||
218 | 39 | systemctl start snap.network-manager.networkmanager | ||
219 | diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh | |||
220 | index 000ef74..8ca1418 100644 | |||
221 | --- a/tests/lib/utilities.sh | |||
222 | +++ b/tests/lib/utilities.sh | |||
223 | @@ -1,4 +1,20 @@ | |||
224 | 1 | #!/bin/sh | 1 | #!/bin/sh |
225 | 2 | snap_install() { | ||
226 | 3 | name=$1 | ||
227 | 4 | if [ -n "$SNAP_CHANNEL" ] ; then | ||
228 | 5 | # Don't reinstall if we have it installed already | ||
229 | 6 | if ! snap list | grep $name ; then | ||
230 | 7 | snap install --$SNAP_CHANNEL $name | ||
231 | 8 | fi | ||
232 | 9 | else | ||
233 | 10 | # Need first install from store to get all necessary assertions into | ||
234 | 11 | # place. Second local install will then bring in our locally built | ||
235 | 12 | # snap. | ||
236 | 13 | snap install $name | ||
237 | 14 | snap install --dangerous $PROJECT_PATH/$name*_amd64.snap | ||
238 | 15 | fi | ||
239 | 16 | } | ||
240 | 17 | |||
241 | 2 | switch_netplan_to_network_manager() { | 18 | switch_netplan_to_network_manager() { |
242 | 3 | if [ -e /etc/netplan/00-default-nm-renderer.yaml ] ; then | 19 | if [ -e /etc/netplan/00-default-nm-renderer.yaml ] ; then |
243 | 4 | return 0 | 20 | return 0 |
244 | diff --git a/tests/main/wifi-powersave-config-option/task.yaml b/tests/main/wifi-powersave-config-option/task.yaml | |||
245 | 5 | new file mode 100644 | 21 | new file mode 100644 |
246 | index 0000000..4711069 | |||
247 | --- /dev/null | |||
248 | +++ b/tests/main/wifi-powersave-config-option/task.yaml | |||
249 | @@ -0,0 +1,28 @@ | |||
250 | 1 | summary: Verify WiFi powersave can be enabled via a snap config option | ||
251 | 2 | |||
252 | 3 | environment: | ||
253 | 4 | WIFI_POWERSAVE_CONF_PATH: /var/snap/network-manager/current/conf.d/wifi-powersave.conf | ||
254 | 5 | |||
255 | 6 | execute: | | ||
256 | 7 | . $TESTSLIB/utilities.sh | ||
257 | 8 | |||
258 | 9 | # The mac80211_hwsim driver does not support the powersave mode | ||
259 | 10 | # so we can't check this reliable. | ||
260 | 11 | |||
261 | 12 | test "`snap get network-manager wifi.powersave`" = "disable" | ||
262 | 13 | grep "wifi.powersave = 2" $WIFI_POWERSAVE_CONF_PATH | ||
263 | 14 | |||
264 | 15 | # Try to enable and disable again | ||
265 | 16 | snap set network-manager wifi.powersave=enable | ||
266 | 17 | test "`snap get network-manager wifi.powersave`" = "enable" | ||
267 | 18 | grep "wifi.powersave = 3" $WIFI_POWERSAVE_CONF_PATH | ||
268 | 19 | |||
269 | 20 | snap set network-manager wifi.powersave=disable | ||
270 | 21 | test "`snap get network-manager wifi.powersave`" = "disable" | ||
271 | 22 | grep "wifi.powersave = 2" $WIFI_POWERSAVE_CONF_PATH | ||
272 | 23 | |||
273 | 24 | # Specifying no value means the snap should use the default | ||
274 | 25 | # which is 'disable' | ||
275 | 26 | snap set network-manager wifi.powersave= | ||
276 | 27 | test "`snap get network-manager wifi.powersave`" = "disable" | ||
277 | 28 | grep "wifi.powersave = 2" $WIFI_POWERSAVE_CONF_PATH |
Some comments below. Two additional points:
1. Please rebase and force-push to reduce the number of commits so history is cleaner.
2. As hooks are not currently supported by snapcraft, there are additional steps for building the snap. Please comment on how to do this in README.md, or better, provide a script/makefile that makes the build.