Merge ~pieq/bugit/+git/qabro:1904847-new-sku-and-cid-cli-arguments into bugit:master

Proposed by Pierre Equoy
Status: Merged
Approved by: Pierre Equoy
Approved revision: 18e5655a38c0b7be20a28eb929c212ce57bc13f4
Merged at revision: aa51cca0305ac089a7b4029a6446c055a179da0b
Proposed branch: ~pieq/bugit/+git/qabro:1904847-new-sku-and-cid-cli-arguments
Merge into: bugit:master
Diff against target: 220 lines (+64/-45)
7 files modified
CHANGELOG.md (+11/-1)
patches/sosreport-apt-remove-user-pwd.patch (+1/-1)
qabro/__init__.py (+11/-3)
qabro/bug_assistant.py (+2/-32)
qabro/ui.py (+5/-3)
qabro/utils.py (+31/-2)
snap/snapcraft.yaml (+3/-3)
Reviewer Review Type Date Requested Status
StanleyHuang Approve
Sylvain Pineau (community) Approve
Review via email: mp+402134@code.launchpad.net

Description of the change

Description
===========

Allow QA Engineer to use the `--cid` and `--sku` (or -c and -k, respectively) arguments when invoking qabro to fill the CID and the SKU information.

If a CID is added this way, it is also added as a tag as per cwayne's suggestion [1].

This branch also fixes some stuff needed to be able to build qabro again (sosreport was updated to v4.1 in the repositories, and it broke patches and snapcraft recipe).

How it was tested
=================

Tested as an amd64 snap, running qabro with different arguments:

qabro
-> no CID, no SKU added in the bug description

qabro -c 202012-25387 -k MDN-DVT2-C1 -t "tag1 tag2"
-> CID added in the bug description as well as in the tags list (see below)
-> SKU added in the bug description
-> tags added: tag1, tag2, 202012-25387

[1] https://chat.canonical.com/canonical/pl/ee316bp4p7ndjcjbm6f7byapzc

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

LGTM (good idea to also add them to the bug desc)

review: Approve
Revision history for this message
StanleyHuang (stanley31) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/CHANGELOG.md b/CHANGELOG.md
2index 8ad30f7..c6d804b 100644
3--- a/CHANGELOG.md
4+++ b/CHANGELOG.md
5@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
6 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
7
8 ## [Unreleased]
9+### Added
10+- Provide argument to add SKU and CID from command line using `--sku` and `--cid`, respectively. If a CID is provided, it is also added as a tag ([LP #1904847](https://bugs.launchpad.net/qabro/+bug/1904847))
11+
12+### Changed
13+- Get buildstamp (image information) from different locations to match IoT and PC projects for both Ubuntu classic and core
14+- Updated snap recipe and patches to work with new version of sosreport (v4.1)
15+
16+### Fixed
17+- Attach acpidump output only if process call OK (to avoid problem on ARM devices with no ACPI tables) ([LP #1903229](https://bugs.launchpad.net/qabro/+bug/1903229))
18+- Ignore lspci-related errors when getting standard info ([LP #1910193](https://bugs.launchpad.net/qabro/+bug/1910193))
19
20 ## [0.14] - 2020-09-28
21 ### Added
22@@ -118,4 +128,4 @@ Initial version.
23 [0.4]: https://git.launchpad.net/qabro/log/?qt=range&q=v0.3...v0.4
24 [0.3]: https://git.launchpad.net/qabro/log/?qt=range&q=v0.2...v0.3
25 [0.2]: https://git.launchpad.net/qabro/log/?qt=range&q=v0.1...v0.2
26-[0.1]: https://git.launchpad.net/qabro/tag/?h=v0.1
27\ No newline at end of file
28+[0.1]: https://git.launchpad.net/qabro/tag/?h=v0.1
29diff --git a/patches/sosreport-apt-remove-user-pwd.patch b/patches/sosreport-apt-remove-user-pwd.patch
30index b8fddec..524e4cb 100644
31--- a/patches/sosreport-apt-remove-user-pwd.patch
32+++ b/patches/sosreport-apt-remove-user-pwd.patch
33@@ -3,7 +3,7 @@
34 @@ -9,6 +9,7 @@
35 # See the LICENSE file in the source distribution for further information.
36
37- from sos.plugins import Plugin, UbuntuPlugin, DebianPlugin
38+ from sos.report.plugins import Plugin, UbuntuPlugin, DebianPlugin
39 +from glob import glob
40
41
42diff --git a/qabro/__init__.py b/qabro/__init__.py
43index 5604dcb..7169068 100644
44--- a/qabro/__init__.py
45+++ b/qabro/__init__.py
46@@ -51,6 +51,8 @@ def main():
47 parser.add_argument("-s", "--series", help="Series e.g. focal")
48 parser.add_argument("-t", "--tags",
49 help="Tags (such as Platform tag) separated by spaces")
50+ parser.add_argument("-k", "--sku", help="SKU of the device under test")
51+ parser.add_argument("-c", "--cid", help="Canonical ID (CID) of the device under test")
52 args = parser.parse_args()
53 if args.fwts:
54 if not args.project:
55@@ -62,14 +64,20 @@ def main():
56 start_ui(assignee=args.assignee,
57 project=args.project,
58 series=args.series,
59- tags=args.tags)
60+ tags=args.tags,
61+ sku=args.sku,
62+ cid=args.cid)
63
64
65-def start_ui(assignee='', project='', series='', tags=''):
66+def start_ui(assignee='', project='', series='', tags='', sku='', cid=''):
67+ tags += " {}".format(cid)
68+ tags = " ".join(tags.split()) # Remove unwanted spaces
69 ui = ReportScreen(assignee=assignee.lower(),
70 project=project.lower(),
71 series=series.lower(),
72- tags=tags.lower())
73+ tags=tags.lower(),
74+ sku=sku.strip().upper(),
75+ cid=cid)
76 ui.run()
77 ba = BugAssistant(ui.report())
78 while True:
79diff --git a/qabro/bug_assistant.py b/qabro/bug_assistant.py
80index 75ea219..bfa58b1 100644
81--- a/qabro/bug_assistant.py
82+++ b/qabro/bug_assistant.py
83@@ -266,39 +266,9 @@ class AttachmentAssistant:
84 snap.props.confinement.value_nick)
85 self.attachments["snap_list.log"] = out.encode()
86
87- def _get_last_checkbox_session_path(self, usr_home="/home/$USER", root_home="/root", root_dir="/"):
88- """Return path of the most recent Checkbox session directory."""
89- rootpath = ''
90- latest_session_dir = ''
91- generic_path = os.path.join(root_dir, "var/tmp/checkbox-ng/sessions")
92- classic_path = os.path.expandvars(os.path.join(usr_home, ".cache/plainbox/sessions"))
93- if os.path.exists(generic_path): # for any checkbox installs based on checkbox-ng >= 1.10
94- rootpath = generic_path
95- elif os.path.exists(classic_path): # for classic checkbox installs based on checkbox-ng <= 1.9
96- rootpath = classic_path
97- else: # for snap checkbox installs based on checkbox-ng <= 1.9
98- snaps = qabro.utils.get_snaps()
99- snap_list = [e.props.name for e in snaps if 'checkbox-' in e.props.name]
100- for snap_name in snap_list:
101- sp = [os.path.join(usr_home, "snap/{}/current/.cache/plainbox/sessions"),
102- os.path.join(root_home, "snap/{}/current/.cache/plainbox/sessions")]
103- for p in sp:
104- snap_path = os.path.expandvars(p.format(snap_name))
105- if os.path.exists(snap_path):
106- rootpath = snap_path
107- # Get path of the most recent Checkbox session
108- if rootpath:
109- sessions_dirs = [os.path.join(rootpath, f) for f in os.listdir(rootpath)
110- if os.path.isdir(os.path.join(rootpath, f))]
111- if sessions_dirs:
112- latest_session_dir = max(sessions_dirs, key=lambda x: os.stat(x).st_mtime)
113- else:
114- print('There does not seem to be any Checkbox session here...')
115- return latest_session_dir
116-
117 def attach_last_checkbox_session(self):
118 """Archive and attach the most recent Checkbox session available."""
119- latest_session_dir = self._get_last_checkbox_session_path()
120+ latest_session_dir = qabro.utils.get_last_checkbox_session_path()
121 if latest_session_dir:
122 session_tgz = os.path.expandvars('$HOME/checkbox-session.tgz')
123 if os.path.exists(session_tgz):
124@@ -315,7 +285,7 @@ class AttachmentAssistant:
125 """
126 p = os.getenv("PATH")
127 lp = os.getenv("LD_LIBRARY_PATH")
128- latest_session_dir = self._get_last_checkbox_session_path()
129+ latest_session_dir = qabro.utils.get_last_checkbox_session_path()
130 if p and lp:
131 if latest_session_dir:
132 logpath = os.path.join(latest_session_dir, "CHECKBOX_DATA",
133diff --git a/qabro/ui.py b/qabro/ui.py
134index f83c516..436eb68 100644
135--- a/qabro/ui.py
136+++ b/qabro/ui.py
137@@ -44,11 +44,13 @@ class ReportScreen:
138 elif d["category"] == "vendors":
139 tags["vendors"] = d["tags"]
140
141- def __init__(self, assignee='', project='', series='', tags=''):
142+ def __init__(self, assignee='', project='', series='', tags='', sku='', cid=''):
143 # Adding standard info (CPU, BIOS, GPU, etc.) to the description
144 std_info = AttachmentAssistant.get_standard_info()
145- std_info_str = '\n'.join(['{}: {}'.format(elt, std_info[elt]) for elt in std_info])
146- self.default_description += "[Additional information]\nSKU: \n" + std_info_str
147+ std_info_str = "\n".join(["{}: {}".format(elt, std_info[elt]) for elt in std_info])
148+ cid_str = "\nCID: {}".format(cid)
149+ sku_str = "\nSKU: {}".format(sku)
150+ self.default_description += "[Additional information]" + cid_str + sku_str + "\n" + std_info_str
151
152 self._title = urwid.LineBox(urwid.Edit(), 'Bug Title')
153 self._description = urwid.LineBox(urwid.Edit(edit_text=self.default_description,
154diff --git a/qabro/utils.py b/qabro/utils.py
155index 8c3e4e8..a89ed24 100644
156--- a/qabro/utils.py
157+++ b/qabro/utils.py
158@@ -1,12 +1,41 @@
159 #!/usr/bin/env python3
160 import gi
161+import gzip
162 import json
163-import pprint
164-import socket
165+import os
166
167 gi.require_version('Snapd', '1')
168 from gi.repository import Snapd
169
170+def get_last_checkbox_session_path(usr_home="/home/$USER", root_home="/root", root_dir="/"):
171+ """Return path of the most recent Checkbox session directory."""
172+ rootpath = ''
173+ latest_session_dir = ''
174+ generic_path = os.path.join(root_dir, "var/tmp/checkbox-ng/sessions")
175+ classic_path = os.path.expandvars(os.path.join(usr_home, ".cache/plainbox/sessions"))
176+ if os.path.exists(generic_path): # for any checkbox installs based on checkbox-ng >= 1.10
177+ rootpath = generic_path
178+ elif os.path.exists(classic_path): # for classic checkbox installs based on checkbox-ng <= 1.9
179+ rootpath = classic_path
180+ else: # for snap checkbox installs based on checkbox-ng <= 1.9
181+ snaps = get_snaps()
182+ snap_list = [e.props.name for e in snaps if 'checkbox-' in e.props.name]
183+ for snap_name in snap_list:
184+ sp = [os.path.join(usr_home, "snap/{}/current/.cache/plainbox/sessions"),
185+ os.path.join(root_home, "snap/{}/current/.cache/plainbox/sessions")]
186+ for p in sp:
187+ snap_path = os.path.expandvars(p.format(snap_name))
188+ if os.path.exists(snap_path):
189+ rootpath = snap_path
190+ # Get path of the most recent Checkbox session
191+ if rootpath:
192+ sessions_dirs = [os.path.join(rootpath, f) for f in os.listdir(rootpath)
193+ if os.path.isdir(os.path.join(rootpath, f))]
194+ if sessions_dirs:
195+ latest_session_dir = max(sessions_dirs, key=lambda x: os.stat(x).st_mtime)
196+ else:
197+ print('There does not seem to be any Checkbox session here...')
198+ return latest_session_dir
199
200 def get_snaps():
201 client = Snapd.Client()
202diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
203index 346125e..a7608a5 100644
204--- a/snap/snapcraft.yaml
205+++ b/snap/snapcraft.yaml
206@@ -62,11 +62,11 @@ parts:
207 snapcraftctl build
208 # Patch to add a bunch of $SNAP-related paths in the $PATH environment
209 # variable used by sosreport to call other commands.
210- patch $SNAPCRAFT_PART_INSTALL/usr/share/sosreport/sos/policies/ubuntu.py $SNAPCRAFT_STAGE/patches/sosreport-env-path-snap.patch
211+ patch $SNAPCRAFT_PART_INSTALL/usr/lib/python3/dist-packages/sos/policies/distros/ubuntu.py $SNAPCRAFT_STAGE/patches/sosreport-env-path-snap.patch
212 # patches from YC Chen
213- patch $SNAPCRAFT_PART_INSTALL/usr/share/sosreport/sos/plugins/apt.py $SNAPCRAFT_STAGE/patches/sosreport-apt-remove-user-pwd.patch
214+ patch $SNAPCRAFT_PART_INSTALL/usr/lib/python3/dist-packages/sos/report/plugins/apt.py $SNAPCRAFT_STAGE/patches/sosreport-apt-remove-user-pwd.patch
215 # patch to be able to have data from `dpkg -l` command
216- patch $SNAPCRAFT_PART_INSTALL/usr/share/sosreport/sos/plugins/dpkg.py $SNAPCRAFT_STAGE/patches/sosreport-dpkg-l.patch
217+ patch $SNAPCRAFT_PART_INSTALL/usr/lib/python3/dist-packages/sos/report/plugins/dpkg.py $SNAPCRAFT_STAGE/patches/sosreport-dpkg-l.patch
218
219 sosreport-plugins:
220 after: [sosreport]

Subscribers

People subscribed via source and target branches

to all changes: