Merge lp:~bladernr/checkbox/story759-checkbox-add-suspend-log-check into lp:checkbox

Proposed by Jeff Lane 
Status: Merged
Merged at revision: 2080
Proposed branch: lp:~bladernr/checkbox/story759-checkbox-add-suspend-log-check
Merge into: lp:checkbox
Diff against target: 285 lines (+137/-29)
7 files modified
data/whitelists/sru.whitelist (+1/-0)
debian/changelog (+8/-0)
jobs/hibernate.txt.in (+8/-2)
jobs/stress.txt.in (+14/-2)
jobs/suspend.txt.in (+8/-2)
scripts/fwts_test (+26/-23)
scripts/sleep_test_log_check (+72/-0)
To merge this branch: bzr merge lp:~bladernr/checkbox/story759-checkbox-add-suspend-log-check
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+160665@code.launchpad.net

Description of the change

Wrote the parser script to look at the FWTS log and give us the error count and/or report of errors encountered in testing
modified fwts_test to include a new fail level "none" to tell fwts_test to NOT fail on any error.
modified sleep test jobs in hibernate.txt.in, suspend.txt.in and stress.txt.in to use the new fail level.
Also added log check jobs to each of those files to use the new parser script.
Also modified SRU whitelist to make sure that the log check runs after suspend as well.

To post a comment you must log in.
Revision history for this message
Jeff Lane  (bladernr) wrote :
Revision history for this message
Daniel Manrique (roadmr) wrote :

Looks good and I even tested the script locally.

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/whitelists/sru.whitelist'
2--- data/whitelists/sru.whitelist 2013-04-22 23:48:18 +0000
3+++ data/whitelists/sru.whitelist 2013-04-24 14:32:29 +0000
4@@ -95,6 +95,7 @@
5 suspend/network_before_suspend
6 suspend/memory_before_suspend
7 suspend/suspend_advanced_auto
8+suspend/suspend-single-log-check
9 suspend/audio_after_suspend_auto
10 suspend/network_resume_time
11 suspend/wifi_resume_time
12
13=== modified file 'debian/changelog'
14--- debian/changelog 2013-04-24 13:33:15 +0000
15+++ debian/changelog 2013-04-24 14:32:29 +0000
16@@ -18,6 +18,14 @@
17 plugins/persist_prompt.py: promoted save to run before lock release.
18 checkbox/lib/fifo.py: trap OSError exception at close when the input/output
19 fifo fds disappear before fifo.close() can get to them. (LP: #115561)
20+ * scripts/sleep_test_log_check: added new script to parse fwts logs for
21+ errors
22+ jobs/hibernate.txt.in, jobs/stress.txt.in, jobs/suspend.txt.in: added jobs
23+ to use the sleep_test_log_check script after s3/s4 tests. Modified current
24+ s3/s4 tests to use the new None fail level for fwts_test
25+ scripts/fwts_test: no longer fails on fwts errors if "-f none" is chosen.
26+ Now it should only fail by manual indication if the actual sleep action
27+ fails. (LP: #1169922)
28
29 [ Brendan Donegan ]
30 * scripts/sources_test - modified script so that it takes sources list
31
32=== modified file 'jobs/hibernate.txt.in'
33--- jobs/hibernate.txt.in 2013-01-03 14:58:32 +0000
34+++ jobs/hibernate.txt.in 2013-04-24 14:32:29 +0000
35@@ -6,7 +6,7 @@
36 command:
37 if type -P fwts >/dev/null; then
38 echo "Calling fwts"
39- fwts_test -l $CHECKBOX_DATA/hibernate-single -s s4 --s4-device-check --s4-device-check-delay=45 --s4-sleep-delay=120
40+ fwts_test -l $CHECKBOX_DATA/hibernate-single -f none -s s4 --s4-device-check --s4-device-check-delay=45 --s4-sleep-delay=120
41 else
42 echo "Calling sleep_test"
43 sleep_test -s disk -w 120
44@@ -22,7 +22,13 @@
45 VERIFICATION:
46 Did the system successfully hibernate and did it work properly after waking up?
47
48+plugin: shell
49+name: power-management/hibernate-single-log-check
50+command: [ -e $CHECKBOX_DATA/hibernate-single.log ] && sleep_test_log_check -v s4 $CHECKBOX_DATA/hibernate-single.log
51+_description:
52+ Automated check of the hibernate log for errors discovered by fwts
53+
54 plugin: attachment
55 name: power-management/hibernate-single-log-attach
56-command: [ -e $CHECKBOX_DATA/hibernate-single.log ] && cat $CHECBOX_DATA/hibernate-single.log
57+command: [ -e $CHECKBOX_DATA/hibernate-single.log ] && cat $CHECKBOX_DATA/hibernate-single.log
58 description: attaches log from single hibernate/resume test to results
59
60=== modified file 'jobs/stress.txt.in'
61--- jobs/stress.txt.in 2013-04-04 16:06:42 +0000
62+++ jobs/stress.txt.in 2013-04-24 14:32:29 +0000
63@@ -16,7 +16,7 @@
64 command:
65 if type -P fwts >/dev/null; then
66 echo "Calling fwts"
67- fwts_test -l $CHECKBOX_DATA/hibernate_30_cycles -s s4 --s4-device-check --s4-device-check-delay=45 --s4-sleep-delay=120 --s4-multiple=30
68+ fwts_test -l $CHECKBOX_DATA/hibernate_30_cycles -f none -s s4 --s4-device-check --s4-device-check-delay=45 --s4-sleep-delay=120 --s4-multiple=30
69 else
70 echo "Calling sleep_test"
71 sleep_test -s disk -i 30 -w 120
72@@ -25,6 +25,12 @@
73 PURPOSE:
74 This is an automated stress test that will force the system to hibernate/resume for 30 cycles
75
76+plugin: shell
77+name: power-management/hibernate-30-cycles-log-check
78+command: [ -e $CHECKBOX_DATA/hibernate_30_cycles.log ] && sleep_test_log_check -v s4 $CHECKBOX_DATA/hibernate_30_cycles.log
79+_description:
80+ Automated check of the 30 cycle hibernate log for errors detected by fwts.
81+
82 plugin: attachment
83 name: power-management/hibernate-30-cycle-log-attach
84 command: [ -e $CHECKBOX_DATA/hibernate_30_cycles.log ] && cat $CHECKBOX_DATA/hibernate_30_cycles.log
85@@ -39,7 +45,7 @@
86 command:
87 if type -P fwts >/dev/null; then
88 echo "Calling fwts"
89- set -o pipefail; fwts_test -l $CHECKBOX_DATA/suspend_30_cycles -s s3 --s3-device-check --s3-device-check-delay=45 --s3-sleep-delay=30 --s3-multiple=30 | tee $CHECKBOX_DATA/suspend_30_cycles_times.log
90+ set -o pipefail; fwts_test -l $CHECKBOX_DATA/suspend_30_cycles -f none -s s3 --s3-device-check --s3-device-check-delay=45 --s3-sleep-delay=30 --s3-multiple=30 | tee $CHECKBOX_DATA/suspend_30_cycles_times.log
91 else
92 echo "Calling sleep_test"
93 set -o pipefail; sleep_test -p s mem -i 30 | tee $CHECKBOX_DATA/suspend_30_cycles_times.log
94@@ -48,6 +54,12 @@
95 PURPOSE:
96 This is an automated stress test that will force the system to suspend/resume for 30 cycles.
97
98+plugin: shell
99+name: power-management/suspend-30-cycles-log-check
100+command: [ -e $CHECKBOX_DATA/suspend_30_cycles.log ] && sleep_test_log_check -v s3 $CHECKBOX_DATA/suspend_30_cycles.log
101+_description:
102+ Automated check of the 30 cycle hibernate log for errors detected by fwts.
103+
104 plugin: attachment
105 name: power-management/suspend-30-cycle-log-attach
106 command: [ -e $CHECKBOX_DATA/suspend_30_cycles.log ] && cat $CHECKBOX_DATA/suspend_30_cycles.log
107
108=== modified file 'jobs/suspend.txt.in'
109--- jobs/suspend.txt.in 2013-04-24 03:40:17 +0000
110+++ jobs/suspend.txt.in 2013-04-24 14:32:29 +0000
111@@ -168,7 +168,7 @@
112 command:
113 if type -P fwts >/dev/null; then
114 echo "Calling fwts"
115- set -o pipefail; fwts_test -f critical -l $CHECKBOX_DATA/suspend_single -s s3 --s3-sleep-delay=30 --s3-device-check --s3-device-check-delay=45 | tee $CHECKBOX_DATA/suspend_single_times.log
116+ set -o pipefail; fwts_test -f none -l $CHECKBOX_DATA/suspend_single -s s3 --s3-sleep-delay=30 --s3-device-check --s3-device-check-delay=45 | tee $CHECKBOX_DATA/suspend_single_times.log
117 else
118 echo "Calling sleep_test"
119 set -o pipefail; sleep_test -p | tee $CHECKBOX_DATA/suspend_single_times.log
120@@ -194,7 +194,13 @@
121 This is the automated version of suspend/suspend_advanced.
122 user: root
123 environ: CHECKBOX_DATA
124-command: set -o pipefail; fwts_test -f critical -l $CHECKBOX_DATA/suspend_single -s s3 --s3-sleep-delay=30 --s3-device-check --s3-device-check-delay=45 | tee $CHECKBOX_DATA/suspend_single_times.log
125+command: set -o pipefail; fwts_test -f none -l $CHECKBOX_DATA/suspend_single -s s3 --s3-sleep-delay=30 --s3-device-check --s3-device-check-delay=45 | tee $CHECKBOX_DATA/suspend_single_times.log
126+
127+plugin: shell
128+name: suspend/suspend-single-log-check
129+command: [ -e $CHECKBOX_DATA/suspend_single.log ] && sleep_test_log_check -v s3 $CHECKBOX_DATA/suspend_single.log
130+_description:
131+ Automated check of the suspend log to look for errors reported by fwts
132
133 plugin: attachment
134 name: suspend/suspend-single-log-attach
135
136=== modified file 'scripts/fwts_test'
137--- scripts/fwts_test 2013-01-15 23:03:42 +0000
138+++ scripts/fwts_test 2013-04-24 14:32:29 +0000
139@@ -125,7 +125,7 @@
140 '[Default: %(default)s]'))
141 parser.add_argument('-f', '--fail-level',
142 default='high',
143- choices=['critical', 'high', 'medium', 'low'],
144+ choices=['critical', 'high', 'medium', 'low', 'none'],
145 help=('Specify the FWTS failure level that will trigger '
146 'this script to return a failing exit code. For '
147 'example, if you chose "critical" as the '
148@@ -188,15 +188,17 @@
149 passed = []
150
151 # Set correct fail level
152- args.fail_level = 'FAILED_%s' % args.fail_level.upper()
153-
154- # Get our failure priority and create the priority values
155- fail_levels = {'FAILED_CRITICAL':4,
156- 'FAILED_HIGH':3,
157- 'FAILED_MEDIUM':2,
158- 'FAILED_LOW':1}
159- fail_priority = fail_levels[args.fail_level]
160-
161+ if args.fail_level is not 'none':
162+ args.fail_level = 'FAILED_%s' % args.fail_level.upper()
163+
164+ # Get our failure priority and create the priority values
165+ fail_levels = {'FAILED_CRITICAL':4,
166+ 'FAILED_HIGH':3,
167+ 'FAILED_MEDIUM':2,
168+ 'FAILED_LOW':1,
169+ 'FAILED_NONE':0}
170+ fail_priority = fail_levels[args.fail_level]
171+
172 # Enforce only using sleep opts with --sleep
173 if args.sleep_time or args.resume_time and not args.sleep:
174 parser.error('--sleep-time and --resume-time only apply to the '
175@@ -327,19 +329,20 @@
176 print("Passed: %d" % len(passed))
177 for test in passed:
178 print(" - " + test)
179-
180- if fail_priority == fail_levels['FAILED_CRITICAL']:
181- if critical_fails:
182- return 1
183- if fail_priority == fail_levels['FAILED_HIGH']:
184- if critical_fails or high_fails:
185- return 1
186- if fail_priority == fail_levels['FAILED_MEDIUM']:
187- if critical_fails or high_fails or medium_fails:
188- return 1
189- if fail_priority == fail_levels['FAILED_LOW']:
190- if critical_fails or high_fails or medium_fails or low_fails:
191- return 1
192+
193+ if args.fail_level is not 'none':
194+ if fail_priority == fail_levels['FAILED_CRITICAL']:
195+ if critical_fails:
196+ return 1
197+ if fail_priority == fail_levels['FAILED_HIGH']:
198+ if critical_fails or high_fails:
199+ return 1
200+ if fail_priority == fail_levels['FAILED_MEDIUM']:
201+ if critical_fails or high_fails or medium_fails:
202+ return 1
203+ if fail_priority == fail_levels['FAILED_LOW']:
204+ if critical_fails or high_fails or medium_fails or low_fails:
205+ return 1
206
207 return 0
208
209
210=== added file 'scripts/sleep_test_log_check'
211--- scripts/sleep_test_log_check 1970-01-01 00:00:00 +0000
212+++ scripts/sleep_test_log_check 2013-04-24 14:32:29 +0000
213@@ -0,0 +1,72 @@
214+#!/usr/bin/env python3
215+'''
216+This script is used to parse the log generated by fwts and check it for certain
217+errors detected during testing. It expects that this is a log file created by
218+fwts at runtime using the -l <log name> option.
219+
220+It's written now specifically for checking ater the fwts s3 and s4 tests but
221+can be adapted to look for other tests, or all tests.
222+'''
223+
224+import sys
225+
226+from argparse import ArgumentParser, RawTextHelpFormatter
227+
228+
229+def main():
230+ parser = ArgumentParser()
231+ parser.add_argument('-v', '--verbose',
232+ action='store_true',
233+ default=False,
234+ help="Display each error discovered. May provide \
235+ very long output. Also, this option will only \
236+ provide a list of UNIQUE errors encountered in \
237+ the log file. It will not display duplicates. \
238+ Default is [%(default)s]")
239+ parser.add_argument('test',
240+ action='store',
241+ help='The test to check (s3 or s4)')
242+ parser.add_argument('logfile',
243+ action='store',
244+ help='The log file to parse')
245+
246+ args = parser.parse_args()
247+
248+ return_code = 0
249+
250+ #Create a generator and get our lines
251+ log = (line.rstrip() for line in open(args.logfile,'r'))
252+
253+ #Now parse and find out error lines. We're looking for specific keys that
254+ #occur in the summary section for each test run.
255+ #Error levels we care about:
256+ levels = ('critical', 'high', 'medium')
257+ errors = {}
258+ for level in levels:
259+ errors[level] = []
260+ for logline in log:
261+ for level in levels:
262+ if "%s: %s" % (args.test, level.upper()) in logline:
263+ line = logline.split(']',1)[1].strip()
264+ #Only include unique lines to avoid hundreds of repititions
265+ if line not in errors[level]:
266+ errors[level].append(line)
267+
268+ for level in levels:
269+ if errors[level]:
270+ return_code = 1
271+ print("%s errors: %s" % (level.upper(), len(errors[level])))
272+ if args.verbose:
273+ #Print the actual errors)
274+ print('='*40)
275+ for line in errors[level]:
276+ print(line)
277+ print('\n')
278+
279+ if return_code == 0:
280+ print("No errors detected")
281+
282+ return return_code
283+
284+if __name__ == '__main__':
285+ sys.exit(main())

Subscribers

People subscribed via source and target branches