Merge lp:~sylvain-pineau/checkbox/device_check into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Jeff Lane 
Approved revision: 4325
Merged at revision: 4331
Proposed branch: lp:~sylvain-pineau/checkbox/device_check
Merge into: lp:checkbox
Diff against target: 104 lines (+57/-4)
2 files modified
providers/plainbox-provider-checkbox/jobs/miscellanea.txt.in (+14/-0)
providers/plainbox-provider-resource-generic/bin/udev_resource (+43/-4)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/device_check
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Sylvain Pineau Needs Resubmitting
Review via email: mp+293523@code.launchpad.net

Description of the change

This is a result of the QA roundtable we had last week in Taipei.

Context:

When a device is not detected on a system, all tests that should have been generated are simply not here and could lead to a valid certificate. It's very hard to review a submission and look for missing tests. But it's far easier to review a submission including failed tests.

This MR proposes a new test using the udev parser but in a new way. With the new --list option it enumerates devices per categories (e.g VIDEO, WIRELESS). The tester can then compare this list with the official manifest of the machine and then can fail the test and help the certificate reviewer.

So far only VIDEO, NETWORK, WIRELESS and DISK categories are considered but it's not limited and could be extended to all categories known to the udev parser.

I'll later propose to add this test to all certification test plans as a mandatory job. It will work on both client and server since the tee commands also redirect to stdout (zenity will only be run on desktop).

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Sample output from my own system:

===========================[ Running Selected Jobs ]============================
--------------[ Running job 1 / 1. Estimated time left: 0:00:05 ]---------------
--------------------------------[ Device Check ]--------------------------------
ID: 2013.com.canonical.certification::miscellanea/device_check
Category: 2013.com.canonical.plainbox::miscellanea
Purpose:

Device check

Steps:

1. Commence the test
2. Check the system manifest and review the devices known to udev

Pick an action
    => press ENTER to continue
  c => add a comment
  s => skip this job
  q => save the session and quit
[csq]:
... 8< -------------------------------------------------------------------------
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
VIDEO (1):
 - Intel Corporation 3rd Gen Core processor Graphics Controller

NETWORK (2):
 - Ericsson Business Mobile Networks BV H5321 gw
 - Intel Corporation 82579LM Gigabit Network Connection

WIRELESS (1):
 - Intel Corporation Centrino Ultimate-N 6300 (3x3 AGN)

DISK (1):
 - None HGST HTS725050A7E630

------------------------------------------------------------------------- >8 ---
Verification:

Are all devices well reported by udev?

Please decide what to do next:
  outcome: job needs verification
  comments:
Pick an action
  c => add a comment
  p => set outcome to pass
  f => set outcome to fail
  s => set outcome to skip
  r => re-run this job
    => set suggested outcome [job passed]
[cpfsr]: p
Outcome: job passed
==================================[ Results ]===================================
 ☑ : Device Check

Revision history for this message
Jeff Lane  (bladernr) wrote :

Just so I understand this, all you're basically doing is dumping UDEV by category, and then manually comparing that to a piece of paper that lists what should be on the SUT?

I'm curious because this KINDA answers something I've been trying to think of a solution for in Server as well. I just want to make sure I understand your description of how this works.

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Yes this is exactly that. Sorry if my wording what not clear enough. As said, some jobs are not even created if a device is not reported by udev (to be clear again they are not skipped or failed just not created at all).

What the test is adding is a manual check, a job meant to be run before anything else to leave an evidence and ease the review.

Revision history for this message
Jeff Lane  (bladernr) wrote :

Thanks! Actually, your wording was fine, I just saw this first thing this morning before coffee and wanted to be sure, because as I said, it's an idea that ties in with something I've wanted to solve myself with server as well... so I'll have to look at co-opting this later on :)

review: Needs Fixing
4323. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

4324. By Sylvain Pineau

providers:resource:udev: Add the --list option to enumerate device per category

4325. By Sylvain Pineau

providers:checkbox: New job meant to check devices reported by udev

This new job relies on the udev_resource command to list devices by categories.
It will help the tester to review the SUT manifest and fail/comment on the test
if devices are missing.

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

I've added a choice list - hardcoded though - which should cover more than we need since we're using a very limited set of devices in template jobs.

review: Needs Resubmitting
Revision history for this message
Jeff Lane  (bladernr) wrote :

Great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'providers/plainbox-provider-checkbox/jobs/miscellanea.txt.in'
2--- providers/plainbox-provider-checkbox/jobs/miscellanea.txt.in 2016-04-20 22:12:24 +0000
3+++ providers/plainbox-provider-checkbox/jobs/miscellanea.txt.in 2016-05-02 19:03:03 +0000
4@@ -286,3 +286,17 @@
5 command: get_make_and_model
6 _description: Retrieve the computer's make and model for easier access than digging through the dmidecode output.
7 _summary: Gather info on the SUT's make and model
8+
9+plugin: user-interact-verify
10+category_id: 2013.com.canonical.plainbox::miscellanea
11+estimated_duration: 5.0
12+id: miscellanea/device_check
13+command: udev_resource -l VIDEO NETWORK WIRELESS DISK | tee >([[ $DISPLAY ]] && zenity --text-info --title="Device report")
14+_summary: Device Check
15+_purpose:
16+ Device check
17+_steps:
18+ 1. Commence the test
19+ 2. Compare items on System Manifest to the devices known to udev
20+_verification:
21+ Do the devices reported by udev match the devices on the Manifest?
22
23=== modified file 'providers/plainbox-provider-resource-generic/bin/udev_resource'
24--- providers/plainbox-provider-resource-generic/bin/udev_resource 2016-02-02 12:54:35 +0000
25+++ providers/plainbox-provider-resource-generic/bin/udev_resource 2016-05-02 19:03:03 +0000
26@@ -20,12 +20,17 @@
27 import argparse
28 import shlex
29
30+from collections import OrderedDict
31 from subprocess import check_output, CalledProcessError
32
33 from checkbox_support.parsers.udevadm import UdevadmParser
34
35-
36-class UdevResult:
37+categories = ("ACCELEROMETER", "AUDIO", "BLUETOOTH", "CAPTURE", "CARDREADER",
38+ "DISK", "KEYBOARD", "MOUSE", "NETWORK", "OTHER", "TOUCHPAD",
39+ "TOUCHSCREEN", "USB", "VIDEO", "WIRELESS")
40+
41+
42+class UdevResultDump:
43
44 attributes = ("path", "name", "bus", "category", "driver", "product_id",
45 "vendor_id", "subproduct_id", "subvendor_id", "product",
46@@ -40,6 +45,29 @@
47 print()
48
49
50+class UdevResultLister:
51+
52+ def __init__(self, categories):
53+ self.categories = categories
54+ self._data = OrderedDict()
55+ for c in categories:
56+ self._data[c] = []
57+
58+ def display(self):
59+ for c, devices in self._data.items():
60+ print("{} ({}):".format(c, len(devices)))
61+ for d in devices:
62+ print(" - {}".format(d))
63+ print()
64+
65+ def addDevice(self, device):
66+ c = getattr(device, "category", None)
67+ if c in self.categories:
68+ p = getattr(device, "product", "Unknow product")
69+ v = getattr(device, "vendor", "Unknow vendor")
70+ self._data[c].append("{} {}".format(v, p))
71+
72+
73 def main():
74 parser = argparse.ArgumentParser()
75 parser.add_argument("-c", "--command", action='store', type=str,
76@@ -50,6 +78,12 @@
77 default="lsblk -i -n -P -o KNAME,TYPE,MOUNTPOINT",
78 help="""Command to execute to get lsblk information.
79 Only change it if you know what you're doing.""")
80+ parser.add_argument('-l','--list', nargs='+', choices=categories,
81+ metavar=("CATEGORY"),
82+ help="""List devices found under the requested
83+ categories.
84+ Acceptable categories to list are:
85+ {}""".format(', '.join(categories)))
86 args = parser.parse_args()
87 try:
88 output = check_output(shlex.split(args.command))
89@@ -61,8 +95,13 @@
90 output = output.decode("UTF-8", errors='ignore')
91 lsblk = lsblk.decode("UTF-8", errors='ignore')
92 udev = UdevadmParser(output, lsblk=lsblk)
93- result = UdevResult()
94- udev.run(result)
95+ if args.list:
96+ result = UdevResultLister(args.list)
97+ udev.run(result)
98+ result.display()
99+ else:
100+ result = UdevResultDump()
101+ udev.run(result)
102
103
104 if __name__ == "__main__":

Subscribers

People subscribed via source and target branches