Merge ~morphis/snappy-hwe-snaps/+git/engineering-tests:upower-tests into ~snappy-hwe-team/snappy-hwe-snaps/+git/engineering-tests:master

Proposed by Simon Fels
Status: Merged
Approved by: Jim Hodapp
Approved revision: e598c7456b2459bc7bf98204f8ee2f92ba722b5b
Merged at revision: 9b34c9d73e4a2f6c4bfb9139b61fda9fbf111923
Proposed branch: ~morphis/snappy-hwe-snaps/+git/engineering-tests:upower-tests
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/engineering-tests:master
Diff against target: 296 lines (+254/-0)
5 files modified
snapcraft.yaml (+6/-0)
upower/manage.py (+10/-0)
upower/units/00_general.pxu (+52/-0)
upower/units/10_battery_powered.pxu (+133/-0)
upower/units/20_ac_powered.pxu (+53/-0)
Reviewer Review Type Date Requested Status
Jim Hodapp (community) Approve
System Enablement Bot continuous-integration Needs Fixing
Konrad Zapałowicz (community) coed Approve
Matteo Croce (community) Approve
Review via email: mp+313379@code.launchpad.net

Description of the change

Add basic tests to cover functionality of the upower snap

Things covered:

 * snap installation from the store
 * battery detection
 * battery discharging and capacity reporting
 * system power off when battery capacity reaches critical threshold

To post a comment you must log in.
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) :
review: Approve
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

LGTM

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

Just a couple of minor comments inline below.

Also, do you think it'd be useful to add a test for a device that doesn't have a battery making sure that upower correctly identifies that situation as well?

review: Needs Fixing (code)
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 :

A few more required fixes 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
Jim Hodapp (jhodapp) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/snapcraft.yaml b/snapcraft.yaml
2index 8fe3a69..d26c459 100644
3--- a/snapcraft.yaml
4+++ b/snapcraft.yaml
5@@ -29,6 +29,8 @@ apps:
6 command: bin/run-wireless-tools-tests
7 pulseaudio:
8 command: bin/run-pulseaudio-tests
9+ upower:
10+ command: bin/plainbox-wrapper run -i '2016.com.canonical.upower::upower.*'
11
12 parts:
13 common:
14@@ -75,6 +77,10 @@ parts:
15 plugin: plainbox-provider
16 source: ./wireless-tools
17 after: [plainbox-local]
18+ upower:
19+ plugin: plainbox-provider
20+ source: ./upower
21+ after: [plainbox-local]
22 launchers:
23 plugin: dump
24 source: .
25diff --git a/upower/manage.py b/upower/manage.py
26new file mode 100755
27index 0000000..a30933e
28--- /dev/null
29+++ b/upower/manage.py
30@@ -0,0 +1,10 @@
31+#!/usr/bin/env python3
32+from plainbox.provider_manager import setup, N_
33+
34+setup(
35+ name='plainbox-provider-upower',
36+ namespace='2016.com.canonical.upower',
37+ version="1.0",
38+ description=N_("Plainbox provider for the upower snap"),
39+ gettext_domain="2016_com_canonical_upower",
40+)
41diff --git a/upower/units/00_general.pxu b/upower/units/00_general.pxu
42new file mode 100644
43index 0000000..3ab4d2d
44--- /dev/null
45+++ b/upower/units/00_general.pxu
46@@ -0,0 +1,52 @@
47+# Copyright 2016 Canonical Ltd.
48+# All rights reserved.
49+#
50+# Written by:
51+# Simon Fels <simon.fels@canonical.com>
52+
53+unit: category
54+id: upower
55+_name: UPower
56+
57+id: upower/general/can_be_installed
58+category_id: upower
59+_description: Ensure that the upower snap can be installed
60+plugin: manual
61+_steps:
62+ Install upower snap from the appropiate channel via the following command
63+ .
64+ $ snap install --candidate upower
65+ .
66+ NOTE: Depending on which channel you want to test you need to select the
67+ right one. The command above uses the candidate channel as that is the
68+ most used one.
69+_verification:
70+ The installation of the snap should finish with no errors.
71+
72+id: upower/general/service_started
73+category_id: upower
74+_description: Ensure that the upowerd service is up and running
75+plugin: manual
76+_steps:
77+ Check service status with the following command
78+ $ systemctl status snap.upower.service.service
79+_verification:
80+ Output should look like this:
81+ snap.upower.upowerd.service - Service for snap application upower.upowerd
82+ Loaded: loaded (/etc/systemd/system/snap.upower.upowerd.service; enabled; vendor preset: enabled)
83+ Active: active (running) since Thu 2016-12-15 16:13:37 UTC; 54ms ago
84+ Main PID: 4265 (upowerd)
85+ CGroup: /system.slice/snap.upower.upowerd.service
86+ 4265 /snap/upower/x1/usr/libexec/upowerd
87+
88+id: upower/general/client_can_talk_to_service
89+category_id: upower
90+_description: Verify that the upower client can talk to the service
91+plugin: manual
92+_steps:
93+ Enumerate available devices available on the system:
94+ $ upower -e
95+_verification:
96+ Output should look like this and at least one device should be present:
97+ /org/freedesktop/UPower/devices/battery_BAT0
98+ /org/freedesktop/UPower/devices/DisplayDevice
99diff --git a/upower/units/10_battery_powered.pxu b/upower/units/10_battery_powered.pxu
100new file mode 100644
101index 0000000..1977ca7
102--- /dev/null
103+++ b/upower/units/10_battery_powered.pxu
104@@ -0,0 +1,133 @@
105+# Copyright 2016 Canonical Ltd.
106+# All rights reserved.
107+#
108+# Written by:
109+# Simon Fels <simon.fels@canonical.com>
110+
111+unit: category
112+id: upower
113+_name: UPower
114+
115+id: upower/battery_powered/battery_detected
116+category_id: upower
117+_description: Verify upower is able to detect the battery of the system
118+plugin: manual
119+_steps:
120+ Query upowerd for available power devices on the system
121+ $ upower -d
122+_verification:
123+ The output should be similar to the following and should list the
124+ battery of your system:
125+ .
126+ Device: /org/freedesktop/UPower/devices/line_power_AC
127+ native-path: AC
128+ power supply: yes
129+ updated: Do 15 Dez 2016 15:06:55 CET (7163 seconds ago)
130+ has history: no
131+ has statistics: no
132+ line-power
133+ warning-level: none
134+ online: yes
135+ icon-name: 'ac-adapter-symbolic'
136+ .
137+ Device: /org/freedesktop/UPower/devices/battery_BAT0
138+ native-path: BAT0
139+ vendor: SANYO
140+ model: 45N1779
141+ serial: 115
142+ power supply: yes
143+ updated: Do 15 Dez 2016 17:05:18 CET (60 seconds ago)
144+ has history: yes
145+ has statistics: yes
146+ battery
147+ present: yes
148+ rechargeable: yes
149+ state: fully-charged
150+ warning-level: none
151+ energy: 97,05 Wh
152+ energy-empty: 0 Wh
153+ energy-full: 97,13 Wh
154+ energy-full-design: 99,47 Wh
155+ energy-rate: 7,983 W
156+ voltage: 12,374 V
157+ percentage: 99%
158+ capacity: 97,6475%
159+ technology: lithium-ion
160+ icon-name: 'battery-full-charged-symbolic'
161+ .
162+ Device: /org/freedesktop/UPower/devices/DisplayDevice
163+ power supply: yes
164+ updated: Do 15 Dez 2016 16:41:14 CET (1504 seconds ago)
165+ has history: no
166+ has statistics: no
167+ battery
168+ present: yes
169+ state: fully-charged
170+ warning-level: none
171+ energy: 97,05 Wh
172+ energy-full: 97,13 Wh
173+ energy-rate: 7,983 W
174+ percentage: 99%
175+ icon-name: 'battery-full-charged-symbolic'
176+ .
177+ Daemon:
178+ daemon-version: 0.99.4
179+ on-battery: no
180+ lid-is-closed: no
181+ lid-is-present: yes
182+ critical-action: PowerOff
183+
184+id: upower/battery_powered/battery_discharging
185+category_id: upower
186+_description: Verify upower reports discharging battery
187+plugin: manual
188+_steps:
189+ 1. Unplug the power cable from your battery powered device
190+ 2. Listen to reported changes from upower
191+ $ upower -m
192+_verification:
193+ Leave the monitor running for some time. It should report the device changes
194+ for the battery device:
195+ .
196+ [17:22:55.277]device changed: /org/freedesktop/UPowerr/devices/battery_BAT0
197+ [17:22:55.277]device changed: /org/freedesktop/UPower/devices/battery_BAT0
198+ .
199+ Verify with the following command that the actual battery capacity is changing
200+ .
201+ $ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | capacity
202+ capacity: 97,6475%
203+ .
204+ and that the state of the battery device is changed to 'discharging'
205+ .
206+ $ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep state
207+ state: discharging
208+
209+id: upower/battery_powered/low_battery_causes_poweroff
210+category_id: upower
211+_description: Verify upower reports discharging battery
212+plugin: manual
213+_steps:
214+ A battery with a low capacity should cause the device to power off. This
215+ involves as a first step to wait until the battery of the device under test
216+ is close to being empty. The default trigger of the poweroff action is by
217+ default at <= 2%
218+ .
219+ Depending on how full your device battery is you have to wait some time
220+ until it is discharged enough.
221+ .
222+ Watch the system via
223+ .
224+ $ sudo journalctl --no-pager -f
225+_verification:
226+ Once the defined threshold of the battery capacity is reached the system
227+ should power off itself. You can spot this by looking at the output
228+ of the journalctl command which should print something like:
229+ .
230+ Dec 15 16:37:02 localhost.localdomain systemd-logind[1022]: System is powering down
231+ [...]
232+ Dec 15 16:37:02 localhost.localdomain systemd[1]: Starting Power-Off...
233+ Dec 15 16:37:02 localhost.localdomain systemd[1]: Starting Update UTMP about System Runlevel Changes...
234+ Dec 15 16:37:02 localhost.localdomain systemd[1]: Started Power-Off.
235+ Dec 15 16:37:02 localhost.localdomain systemd[1]: Started Update UTMP about System Runlevel Changes.
236+ Dec 15 16:37:02 localhost.localdomain systemd[1]: Reached target Power-Off.
237+ Dec 15 16:37:02 localhost.localdomain systemd-logind[1022]: Operation 'shutdown' finished.
238diff --git a/upower/units/20_ac_powered.pxu b/upower/units/20_ac_powered.pxu
239new file mode 100644
240index 0000000..aac70e4
241--- /dev/null
242+++ b/upower/units/20_ac_powered.pxu
243@@ -0,0 +1,53 @@
244+# Copyright 2016 Canonical Ltd.
245+# All rights reserved.
246+#
247+# Written by:
248+# Simon Fels <simon.fels@canonical.com>
249+
250+unit: category
251+id: upower
252+_name: UPower
253+
254+id: upower/ac_powered/source_detected
255+category_id: upower
256+_description: Verify upower is able to detect the AC power source
257+plugin: manual
258+_steps:
259+ Query upowerd for available power devices on the system
260+ .
261+ $ upower -e
262+_verification:
263+ The AC power source should be listed in the result, e.g.:
264+ .
265+ /org/freedesktop/UPower/devices/line_power_AC
266+
267+id: upower/ac_powered/status_plugged
268+category_id: upower
269+_description: Verify upower report AC source as plugged
270+plugin: manual
271+_steps:
272+ Plug in the AC adapter to your device and query upower with
273+ .
274+ $ upower -i /org/freedesktop/UPower/devices/line_power_AC | grep online
275+ for the online status of the source.
276+_verification:
277+ The output should be
278+ .
279+ online: yes
280+ .
281+ If the source is not plugged upower will report a "no" instead of "yes".
282+
283+id: upower/ac_powered/status_unplugged
284+category_id: upower
285+_description: Verify upower report AC source as unplugged
286+plugin: manual
287+_steps:
288+ Unplug the AC adapter from your device and query upower with
289+ $ upower -i /org/freedesktop/UPower/devices/line_power_AC | grep online
290+ for the online status of the source.
291+_verification:
292+ The output should be
293+ .
294+ online: no
295+ .
296+ If the source is plugged upower will report a "yes" instead of "no".

Subscribers

People subscribed via source and target branches

to all changes: