Merge ~morphis/snappy-hwe-snaps/+git/network-manager:suspend-resume into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master

Proposed by Simon Fels
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 915a8e10a66e9232352b73186650eb88e951dc7b
Merged at revision: 57b73020ce529d4b8f4250bb1487dbc85873aece
Proposed branch: ~morphis/snappy-hwe-snaps/+git/network-manager:suspend-resume
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master
Diff against target: 127 lines (+88/-1)
4 files modified
run-tests.sh (+1/-1)
snapcraft.yaml (+4/-0)
tests/main/suspend-resume/task.yaml (+80/-0)
tests/main/wifi-connect-secured-ap/task.yaml (+3/-0)
Reviewer Review Type Date Requested Status
Alfonso Sanchez-Beato Approve
System Enablement Bot continuous-integration Approve
Konrad Zapałowicz (community) code Approve
Tony Espy Pending
Review via email: mp+313683@code.launchpad.net

Description of the change

Enable suspend/resume tracking via systemd

 * add spread test to test suspend/resume tracking probably
 * disable session tracking explicitly as not support currently
 * always unload the mac80211_hwsim driver when we used it

To post a comment you must log in.
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

Ack

review: Approve (code)
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)
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
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve

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 eaa2fca..0c8a1fc 100755
3--- a/run-tests.sh
4+++ b/run-tests.sh
5@@ -17,7 +17,7 @@
6 set -e
7
8 image_name=ubuntu-core-16.img
9-channel=candidate
10+channel=stable
11 spread_opts=
12 force_new_image=0
13 test_from_channel=0
14diff --git a/snapcraft.yaml b/snapcraft.yaml
15index 56ba3f0..f1c9e00 100644
16--- a/snapcraft.yaml
17+++ b/snapcraft.yaml
18@@ -135,6 +135,10 @@ parts:
19 - --with-dhclient=no
20 - --with-dnsmasq=no
21 - --with-systemd-journal=no
22+ - --with-session-tracking=no
23+ # We only support suspend/resume tracking together with systemd/logind
24+ # at the moment.
25+ - --with-suspend-resume=systemd
26 # Removes dependency on libicudata which weights 25M. Also libsoup
27 # is only used to verify a domain in the DNS resolve process has a
28 # valid format and to check if a valid internet connection is available.
29diff --git a/tests/main/suspend-resume/task.yaml b/tests/main/suspend-resume/task.yaml
30new file mode 100644
31index 0000000..b5df7d1
32--- /dev/null
33+++ b/tests/main/suspend-resume/task.yaml
34@@ -0,0 +1,80 @@
35+summary: Verify suspend/resume tracking works reliable
36+
37+restore: |
38+ rmmod mac80211_hwsim
39+
40+execute: |
41+ # Install necessary test-tools, we need inotify-tools in this case
42+ snap install --edge se-test-tools
43+
44+ # Get two connected wifi network interfaces wlan0 and wlan1
45+ modprobe mac80211_hwsim radios=2
46+
47+ # FIXME: take the one from edge for now as that is the one which
48+ # has automatic setup capabilities
49+ snap install --edge wifi-ap
50+
51+ /snap/bin/network-manager.nmcli d wifi rescan
52+ while ! /snap/bin/network-manager.nmcli d wifi | grep Ubuntu ; do
53+ /snap/bin/network-manager.nmcli d wifi rescan
54+ sleep 1
55+ done
56+
57+ /snap/bin/network-manager.nmcli d wifi connect Ubuntu
58+
59+ # Override the existing systemd-suspend service unit with a customized
60+ # one to prevent the device from entering real suspend. The service unit
61+ # will block as long as no new files gets created inside the specified
62+ # directory inotifywait listens for changes on.
63+ cat <<-EOF > $PROJECT_PATH/systemd-suspend.service
64+ [Unit]
65+ Description=Suspend
66+ Documentation=man:systemd-suspend.service(8)
67+ DefaultDependencies=no
68+ [Service]
69+ Type=oneshot
70+ ExecStart=/bin/sh -c '/snap/bin/se-test-tools.inotifywait -e create /home/network-manager/systemd-suspend'
71+ EOF
72+ mkdir -p /home/network-manager/systemd-suspend
73+ mount -o bind,ro $PROJECT_PATH/systemd-suspend.service /lib/systemd/system/systemd-suspend.service
74+ systemctl daemon-reload
75+
76+ # NetworkManager should have an inhibit lock in place by default
77+ systemd-inhibit --list | grep "NetworkManager needs to turn off networks"
78+
79+ service=snap.network-manager.networkmanager
80+
81+ # Flush the syslog so that we can reliable grep it once we triggered
82+ # the system suspend
83+ journalctl --flush -u $service
84+
85+ # Kick off the actual suspend in background so that we can continue
86+ # verifying the correct state left by the system before it would
87+ # normally enter a sleep state.
88+ systemctl suspend --no-block &
89+
90+ # The easiest way to ensure NetworkManager did the right thing is
91+ # by going through its log output and verifying it prints out
92+ # what we expect.
93+ journalctl --no-pager -u $service | grep 'manager: sleep requested'
94+ journalctl --no-pager -u $service | grep 'manager: sleeping...'
95+ journalctl --no-pager -u $service | grep "device (wlan1): state change: activated -> unmanaged (reason 'sleeping')"
96+ journalctl --no-pager -u $service | grep 'manager: NetworkManager state is now ASLEEP'
97+
98+ # Connection should be reported as disconnected
99+ /snap/bin/network-manager.nmcli d | grep -v 'wlan1.*connected'
100+ # .. and interface should be disabled
101+ ifconfig | grep -v wlan1
102+
103+ # Now we wakeup the system again and verify NetworkManager
104+ # is correctly setting up the ethernet port again.
105+ journalctl --flush -u $service
106+ touch $PROJECT_PATH/systemd-suspend/wakeup
107+
108+ journalctl --no-pager -u $service | grep 'manager: wake requested (sleeping: yes enabled: yes)'
109+ journalctl --no-pager -u $service | grep 'manager: NetworkManager state is now CONNECTED_LOCAL'
110+ journalctl --no-pager -u $service | grep 'manager: NetworkManager state is now CONNECTED_GLOBAL'
111+ journalctl --no-pager -u $service | grep 'device (wlan1): Activation: successful, device activated.'
112+
113+ ifconfig | grep wlan1
114+ /snap/bin/network-manager.nmcli d | grep -v 'wlan1.*connected'
115diff --git a/tests/main/wifi-connect-secured-ap/task.yaml b/tests/main/wifi-connect-secured-ap/task.yaml
116index ed56a9b..2c7ed53 100644
117--- a/tests/main/wifi-connect-secured-ap/task.yaml
118+++ b/tests/main/wifi-connect-secured-ap/task.yaml
119@@ -4,6 +4,9 @@ environment:
120 WIFI_SSID: Ubuntu
121 WIFI_PASSPHRASE: Test1234
122
123+restore: |
124+ rmmod mac80211_hwsim
125+
126 execute: |
127 snap install wifi-ap
128

Subscribers

People subscribed via source and target branches