Merge ~pieq/bugit/+git/qabro:fix-1816437-fwts-logs into bugit:master

Proposed by Pierre Equoy
Status: Merged
Approved by: Pierre Equoy
Approved revision: 8d1cb78f71bef16e1510c665fbe5e64e4803fda9
Merged at revision: a913710ecdf5f2fc1a8541ec885c6dcd027625a8
Proposed branch: ~pieq/bugit/+git/qabro:fix-1816437-fwts-logs
Merge into: bugit:master
Diff against target: 158 lines (+46/-60)
2 files modified
qabro/bug_assistant.py (+46/-35)
snap/snapcraft.yaml (+0/-25)
Reviewer Review Type Date Requested Status
Maciej Kisielewski (community) Approve
Pierre Equoy Needs Resubmitting
Review via email: mp+373026@code.launchpad.net

Description of the change

Handles LP issues #1807359 and #1816437. In a nutshell:

- don't run FWTS from qabro anymore
- only rely on FWTS logs generated by Checkbox (from the latest active session)
- remove FWTS binaries from qabro snap

See commit messages for more explanation.

Tested as follow:

0. In a 18.04.3 LXC container, install Checkbox from PPA, as well as checkbox-snappy from Snap store.
1. Build qabro snap from this branch (run `snapcraft` from within the git repo), copy the generated snap to the container and install it:
    (inside container) $ sudo snap install qabro_0.11dev_amd64.snap --devmode
2. Run checkbox-cli (Checkbox from PPA isntall), select 18.04 cert tests, and run tests from the Firmware category. This will create a Checkbox session in ~/.cache/plainbox/sessions/ that contains "fwts*.log" files.
3. Run qabro (while pointing at Staging Launchpad to avoid spamming the real Launchpad):
    $ APPORT_LAUNCHPAD_INSTANCE=staging qabro
4. Enter title, select "qabro" for project, then "Firmware" for category, and press Alt+Enter to submit the bug.
5. Check that qabro output contains the following:
    Uploading attachment fwts_desktop_diagnosis_results.log...
    Uploading attachment fwts_uefirtvariable.log...
6. Check that the generated LP issue contains the two above logs as attachments
7. Repeat steps 2~6 using checkbox-snappy.checkbox-cli instead of checkbox-cli to make sure things work fine with snap-based Checkbox sessions
8. Run checkbox-cli again, but this time only run tests that do not contain FWTS jobs (you can for instance run the 18.04 cert test plan and deselect everything before starting the test).
9. Repeat step 3~4, and check that qabro output contains the following:
    No FWTS logs found in Checkbox session!
This is expected since the last active Checkbox session found has not run FWTS-related jobs.

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Some improvement suggestions below.
Landable as is. +1

review: Approve
Revision history for this message
Pierre Equoy (pieq) wrote :

Thanks for the feedback Maciek!

I'll resubmit this, rebased. I added a few inline answers to your comments.

Revision history for this message
Pierre Equoy (pieq) wrote :

Oops, I realized $HOME and /home/$USER were here for a reason (see comment below).

Revision history for this message
Pierre Equoy (pieq) wrote :

Resubmitted with minor changes (PEP257, ...).

review: Needs Resubmitting
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/qabro/bug_assistant.py b/qabro/bug_assistant.py
2index 12f6df4..d8248d5 100644
3--- a/qabro/bug_assistant.py
4+++ b/qabro/bug_assistant.py
5@@ -1,4 +1,5 @@
6 import getpass
7+from glob import glob
8 import os
9 import re
10 import subprocess
11@@ -263,59 +264,69 @@ class AttachmentAssistant:
12 snap["confinement"]) + "\n"
13 self.attachments["snap_list.log"] = out.encode()
14
15- def attach_last_checkbox_session(self):
16- """Archive the most recent Plainbox session available and add it to
17- the attachments.
18- """
19- session_tgz = os.path.expandvars('$HOME/checkbox-session.tgz')
20- if os.path.exists(session_tgz):
21- os.remove(session_tgz)
22-
23+ def _get_last_checkbox_session_path(self):
24+ """Return path of the most recent Checkbox session directory."""
25+ rootpath = ''
26+ latest_session_dir = ''
27 # Determine if we use a classic install or a snap install
28 classic_path = os.path.expandvars('/home/$USER/.cache/plainbox/sessions')
29- rootpath = ''
30 if os.path.exists(classic_path):
31 rootpath = classic_path
32 else:
33 ss = snapdsocket()
34- snap_list = [e for e in ss.get_snaps() if 'checkbox' in e['name']]
35- if snap_list:
36- snap_name = snap_list[0]["name"]
37- sp = "/home/$USER/snap/{}/current/plainbox/sessions"
38- snap_path = os.path.expandvars(sp.format(snap_name))
39- if os.path.exists(snap_path):
40- rootpath = snap_path
41-
42- # Get the most recent Checkbox session and add it to the attachments
43+ snap_list = [e['title'] for e in ss.get_snaps() if 'checkbox-' in e['name']]
44+ for snap_name in snap_list:
45+ sp = ["/home/$USER/snap/{}/current/.cache/plainbox/sessions",
46+ "/root/snap/{}/current/.cache/plainbox/sessions"]
47+ for p in sp:
48+ snap_path = os.path.expandvars(p.format(snap_name))
49+ if os.path.exists(snap_path):
50+ rootpath = snap_path
51+ # Get path of the most recent Checkbox session
52 if rootpath:
53 sessions_dirs = [os.path.join(rootpath, f) for f in os.listdir(rootpath)
54 if os.path.isdir(os.path.join(rootpath, f))]
55 if sessions_dirs:
56 latest_session_dir = max(sessions_dirs, key=lambda x: os.stat(x).st_mtime)
57- with tarfile.open(session_tgz, 'w:gz') as tar:
58- tar.add(latest_session_dir)
59- with open(session_tgz, 'rb') as f:
60- data = f.read()
61- self.attachments['checkbox-session.tgz'] = data
62 else:
63 print('There does not seem to be any Checkbox session here...')
64+ return latest_session_dir
65+
66+ def attach_last_checkbox_session(self):
67+ """Archive and attach the most recent Checkbox session available."""
68+ latest_session_dir = self._get_last_checkbox_session_path()
69+ if latest_session_dir:
70+ session_tgz = os.path.expandvars('$HOME/checkbox-session.tgz')
71+ if os.path.exists(session_tgz):
72+ os.remove(session_tgz)
73+ with tarfile.open(session_tgz, 'w:gz') as tar:
74+ tar.add(latest_session_dir)
75+ with open(session_tgz, 'rb') as f:
76+ data = f.read()
77+ self.attachments['checkbox-session.tgz'] = data
78
79 def attach_fwts_logs(self):
80+ """Check for FWTS-related log files in the most recent Checkbox session
81+ and attach them.
82+ """
83 p = os.getenv("PATH")
84 lp = os.getenv("LD_LIBRARY_PATH")
85- logfile = os.path.expandvars("$HOME/fwts_results.log")
86+ latest_session_dir = self._get_last_checkbox_session_path()
87 if p and lp:
88- print("Running FWTS...")
89- command = ["sudo", "env", "PATH={}".format(p),
90- "LD_LIBRARY_PATH={}".format(lp), "fwts", "-q", "-r",
91- logfile, "version", "cpufreq", "maxfreq", "msr", "mtrr",
92- "nx", "virt", "aspm", "dmicheck", "apicedge", "klog",
93- "oops", "esrt", "uefibootpath", "uefirtvariable",
94- "uefirttime", "uefirtmisc", "--acpitests", "--log-level=high"]
95- subprocess.call(command)
96- with open(logfile, 'rb') as f:
97- content = f.read()
98- self.attachments['fwts_results.log'] = content
99+ if latest_session_dir:
100+ logpath = os.path.join(latest_session_dir, "CHECKBOX_DATA",
101+ "fwts*.log")
102+ logfiles = glob(logpath)
103+ if logfiles:
104+ for log in logfiles:
105+ with open(log, 'rb') as f:
106+ content = f.read()
107+ self.attachments[os.path.basename(log)] = content
108+ else:
109+ print("No FWTS logs found in Checkbox session!")
110+ else:
111+ print(("Cannot find Checkbox session where FWTS logs could be "
112+ "located!"))
113 else:
114 print("$PATH and/or $LD_LIBRARY_PATH missing. Cannot run FWTS!")
115
116diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
117index 2c9982d..41a00ee 100644
118--- a/snap/snapcraft.yaml
119+++ b/snap/snapcraft.yaml
120@@ -17,9 +17,6 @@ apps:
121 sosreport:
122 command: sosreport --no-report --batch --tmp-dir $SNAP_USER_COMMON -z gzip
123
124- fwts:
125- command: bin/fwts
126-
127 lspci:
128 command: lspci
129
130@@ -57,28 +54,6 @@ parts:
131 # variable used by sosreport to call other commands.
132 patch $SNAPCRAFT_PART_INSTALL/usr/share/sosreport/sos/policies/ubuntu.py $SNAPCRAFT_STAGE/patches/sosreport-env-path-snap.patch
133
134- fwts:
135- plugin: autotools
136- source: git://kernel.ubuntu.com/hwe/fwts
137- source-tag: V19.01.00
138- stage-packages:
139- - libfdt1
140- - libbsd0
141- - libpci3
142- build-packages:
143- - gcc
144- - make
145- - autoconf
146- - automake
147- - libtool
148- - libjson-c-dev
149- - flex
150- - bison
151- - dh-autoreconf
152- - libglib2.0-dev
153- - libfdt-dev
154- - libbsd-dev
155-
156 lspci:
157 plugin: nil
158 stage-packages:

Subscribers

People subscribed via source and target branches

to all changes: