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
=== modified file 'data/whitelists/sru.whitelist'
--- data/whitelists/sru.whitelist 2013-04-22 23:48:18 +0000
+++ data/whitelists/sru.whitelist 2013-04-24 14:32:29 +0000
@@ -95,6 +95,7 @@
95suspend/network_before_suspend95suspend/network_before_suspend
96suspend/memory_before_suspend96suspend/memory_before_suspend
97suspend/suspend_advanced_auto97suspend/suspend_advanced_auto
98suspend/suspend-single-log-check
98suspend/audio_after_suspend_auto99suspend/audio_after_suspend_auto
99suspend/network_resume_time100suspend/network_resume_time
100suspend/wifi_resume_time101suspend/wifi_resume_time
101102
=== modified file 'debian/changelog'
--- debian/changelog 2013-04-24 13:33:15 +0000
+++ debian/changelog 2013-04-24 14:32:29 +0000
@@ -18,6 +18,14 @@
18 plugins/persist_prompt.py: promoted save to run before lock release.18 plugins/persist_prompt.py: promoted save to run before lock release.
19 checkbox/lib/fifo.py: trap OSError exception at close when the input/output19 checkbox/lib/fifo.py: trap OSError exception at close when the input/output
20 fifo fds disappear before fifo.close() can get to them. (LP: #115561)20 fifo fds disappear before fifo.close() can get to them. (LP: #115561)
21 * scripts/sleep_test_log_check: added new script to parse fwts logs for
22 errors
23 jobs/hibernate.txt.in, jobs/stress.txt.in, jobs/suspend.txt.in: added jobs
24 to use the sleep_test_log_check script after s3/s4 tests. Modified current
25 s3/s4 tests to use the new None fail level for fwts_test
26 scripts/fwts_test: no longer fails on fwts errors if "-f none" is chosen.
27 Now it should only fail by manual indication if the actual sleep action
28 fails. (LP: #1169922)
2129
22 [ Brendan Donegan ]30 [ Brendan Donegan ]
23 * scripts/sources_test - modified script so that it takes sources list31 * scripts/sources_test - modified script so that it takes sources list
2432
=== modified file 'jobs/hibernate.txt.in'
--- jobs/hibernate.txt.in 2013-01-03 14:58:32 +0000
+++ jobs/hibernate.txt.in 2013-04-24 14:32:29 +0000
@@ -6,7 +6,7 @@
6command:6command:
7 if type -P fwts >/dev/null; then7 if type -P fwts >/dev/null; then
8 echo "Calling fwts"8 echo "Calling fwts"
9 fwts_test -l $CHECKBOX_DATA/hibernate-single -s s4 --s4-device-check --s4-device-check-delay=45 --s4-sleep-delay=1209 fwts_test -l $CHECKBOX_DATA/hibernate-single -f none -s s4 --s4-device-check --s4-device-check-delay=45 --s4-sleep-delay=120
10 else10 else
11 echo "Calling sleep_test"11 echo "Calling sleep_test"
12 sleep_test -s disk -w 12012 sleep_test -s disk -w 120
@@ -22,7 +22,13 @@
22 VERIFICATION:22 VERIFICATION:
23 Did the system successfully hibernate and did it work properly after waking up?23 Did the system successfully hibernate and did it work properly after waking up?
2424
25plugin: shell
26name: power-management/hibernate-single-log-check
27command: [ -e $CHECKBOX_DATA/hibernate-single.log ] && sleep_test_log_check -v s4 $CHECKBOX_DATA/hibernate-single.log
28_description:
29 Automated check of the hibernate log for errors discovered by fwts
30
25plugin: attachment31plugin: attachment
26name: power-management/hibernate-single-log-attach32name: power-management/hibernate-single-log-attach
27command: [ -e $CHECKBOX_DATA/hibernate-single.log ] && cat $CHECBOX_DATA/hibernate-single.log33command: [ -e $CHECKBOX_DATA/hibernate-single.log ] && cat $CHECKBOX_DATA/hibernate-single.log
28description: attaches log from single hibernate/resume test to results34description: attaches log from single hibernate/resume test to results
2935
=== modified file 'jobs/stress.txt.in'
--- jobs/stress.txt.in 2013-04-04 16:06:42 +0000
+++ jobs/stress.txt.in 2013-04-24 14:32:29 +0000
@@ -16,7 +16,7 @@
16command:16command:
17 if type -P fwts >/dev/null; then17 if type -P fwts >/dev/null; then
18 echo "Calling fwts"18 echo "Calling fwts"
19 fwts_test -l $CHECKBOX_DATA/hibernate_30_cycles -s s4 --s4-device-check --s4-device-check-delay=45 --s4-sleep-delay=120 --s4-multiple=3019 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
20 else20 else
21 echo "Calling sleep_test"21 echo "Calling sleep_test"
22 sleep_test -s disk -i 30 -w 12022 sleep_test -s disk -i 30 -w 120
@@ -25,6 +25,12 @@
25 PURPOSE:25 PURPOSE:
26 This is an automated stress test that will force the system to hibernate/resume for 30 cycles26 This is an automated stress test that will force the system to hibernate/resume for 30 cycles
2727
28plugin: shell
29name: power-management/hibernate-30-cycles-log-check
30command: [ -e $CHECKBOX_DATA/hibernate_30_cycles.log ] && sleep_test_log_check -v s4 $CHECKBOX_DATA/hibernate_30_cycles.log
31_description:
32 Automated check of the 30 cycle hibernate log for errors detected by fwts.
33
28plugin: attachment34plugin: attachment
29name: power-management/hibernate-30-cycle-log-attach35name: power-management/hibernate-30-cycle-log-attach
30command: [ -e $CHECKBOX_DATA/hibernate_30_cycles.log ] && cat $CHECKBOX_DATA/hibernate_30_cycles.log36command: [ -e $CHECKBOX_DATA/hibernate_30_cycles.log ] && cat $CHECKBOX_DATA/hibernate_30_cycles.log
@@ -39,7 +45,7 @@
39command: 45command:
40 if type -P fwts >/dev/null; then46 if type -P fwts >/dev/null; then
41 echo "Calling fwts"47 echo "Calling fwts"
42 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.log48 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
43 else49 else
44 echo "Calling sleep_test"50 echo "Calling sleep_test"
45 set -o pipefail; sleep_test -p s mem -i 30 | tee $CHECKBOX_DATA/suspend_30_cycles_times.log51 set -o pipefail; sleep_test -p s mem -i 30 | tee $CHECKBOX_DATA/suspend_30_cycles_times.log
@@ -48,6 +54,12 @@
48 PURPOSE:54 PURPOSE:
49 This is an automated stress test that will force the system to suspend/resume for 30 cycles.55 This is an automated stress test that will force the system to suspend/resume for 30 cycles.
5056
57plugin: shell
58name: power-management/suspend-30-cycles-log-check
59command: [ -e $CHECKBOX_DATA/suspend_30_cycles.log ] && sleep_test_log_check -v s3 $CHECKBOX_DATA/suspend_30_cycles.log
60_description:
61 Automated check of the 30 cycle hibernate log for errors detected by fwts.
62
51plugin: attachment63plugin: attachment
52name: power-management/suspend-30-cycle-log-attach64name: power-management/suspend-30-cycle-log-attach
53command: [ -e $CHECKBOX_DATA/suspend_30_cycles.log ] && cat $CHECKBOX_DATA/suspend_30_cycles.log65command: [ -e $CHECKBOX_DATA/suspend_30_cycles.log ] && cat $CHECKBOX_DATA/suspend_30_cycles.log
5466
=== modified file 'jobs/suspend.txt.in'
--- jobs/suspend.txt.in 2013-04-24 03:40:17 +0000
+++ jobs/suspend.txt.in 2013-04-24 14:32:29 +0000
@@ -168,7 +168,7 @@
168command:168command:
169 if type -P fwts >/dev/null; then169 if type -P fwts >/dev/null; then
170 echo "Calling fwts"170 echo "Calling fwts"
171 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.log171 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
172 else172 else
173 echo "Calling sleep_test"173 echo "Calling sleep_test"
174 set -o pipefail; sleep_test -p | tee $CHECKBOX_DATA/suspend_single_times.log174 set -o pipefail; sleep_test -p | tee $CHECKBOX_DATA/suspend_single_times.log
@@ -194,7 +194,13 @@
194 This is the automated version of suspend/suspend_advanced.194 This is the automated version of suspend/suspend_advanced.
195user: root195user: root
196environ: CHECKBOX_DATA196environ: CHECKBOX_DATA
197command: 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.log197command: 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
198
199plugin: shell
200name: suspend/suspend-single-log-check
201command: [ -e $CHECKBOX_DATA/suspend_single.log ] && sleep_test_log_check -v s3 $CHECKBOX_DATA/suspend_single.log
202_description:
203 Automated check of the suspend log to look for errors reported by fwts
198204
199plugin: attachment205plugin: attachment
200name: suspend/suspend-single-log-attach206name: suspend/suspend-single-log-attach
201207
=== modified file 'scripts/fwts_test'
--- scripts/fwts_test 2013-01-15 23:03:42 +0000
+++ scripts/fwts_test 2013-04-24 14:32:29 +0000
@@ -125,7 +125,7 @@
125 '[Default: %(default)s]'))125 '[Default: %(default)s]'))
126 parser.add_argument('-f', '--fail-level',126 parser.add_argument('-f', '--fail-level',
127 default='high',127 default='high',
128 choices=['critical', 'high', 'medium', 'low'],128 choices=['critical', 'high', 'medium', 'low', 'none'],
129 help=('Specify the FWTS failure level that will trigger '129 help=('Specify the FWTS failure level that will trigger '
130 'this script to return a failing exit code. For '130 'this script to return a failing exit code. For '
131 'example, if you chose "critical" as the '131 'example, if you chose "critical" as the '
@@ -188,15 +188,17 @@
188 passed = []188 passed = []
189 189
190 # Set correct fail level190 # Set correct fail level
191 args.fail_level = 'FAILED_%s' % args.fail_level.upper()191 if args.fail_level is not 'none':
192 192 args.fail_level = 'FAILED_%s' % args.fail_level.upper()
193 # Get our failure priority and create the priority values193
194 fail_levels = {'FAILED_CRITICAL':4,194 # Get our failure priority and create the priority values
195 'FAILED_HIGH':3,195 fail_levels = {'FAILED_CRITICAL':4,
196 'FAILED_MEDIUM':2,196 'FAILED_HIGH':3,
197 'FAILED_LOW':1}197 'FAILED_MEDIUM':2,
198 fail_priority = fail_levels[args.fail_level]198 'FAILED_LOW':1,
199199 'FAILED_NONE':0}
200 fail_priority = fail_levels[args.fail_level]
201
200 # Enforce only using sleep opts with --sleep202 # Enforce only using sleep opts with --sleep
201 if args.sleep_time or args.resume_time and not args.sleep:203 if args.sleep_time or args.resume_time and not args.sleep:
202 parser.error('--sleep-time and --resume-time only apply to the '204 parser.error('--sleep-time and --resume-time only apply to the '
@@ -327,19 +329,20 @@
327 print("Passed: %d" % len(passed))329 print("Passed: %d" % len(passed))
328 for test in passed: 330 for test in passed:
329 print(" - " + test)331 print(" - " + test)
330332
331 if fail_priority == fail_levels['FAILED_CRITICAL']:333 if args.fail_level is not 'none':
332 if critical_fails:334 if fail_priority == fail_levels['FAILED_CRITICAL']:
333 return 1335 if critical_fails:
334 if fail_priority == fail_levels['FAILED_HIGH']:336 return 1
335 if critical_fails or high_fails:337 if fail_priority == fail_levels['FAILED_HIGH']:
336 return 1338 if critical_fails or high_fails:
337 if fail_priority == fail_levels['FAILED_MEDIUM']:339 return 1
338 if critical_fails or high_fails or medium_fails:340 if fail_priority == fail_levels['FAILED_MEDIUM']:
339 return 1341 if critical_fails or high_fails or medium_fails:
340 if fail_priority == fail_levels['FAILED_LOW']:342 return 1
341 if critical_fails or high_fails or medium_fails or low_fails:343 if fail_priority == fail_levels['FAILED_LOW']:
342 return 1344 if critical_fails or high_fails or medium_fails or low_fails:
345 return 1
343 346
344 return 0347 return 0
345348
346349
=== added file 'scripts/sleep_test_log_check'
--- scripts/sleep_test_log_check 1970-01-01 00:00:00 +0000
+++ scripts/sleep_test_log_check 2013-04-24 14:32:29 +0000
@@ -0,0 +1,72 @@
1#!/usr/bin/env python3
2'''
3This script is used to parse the log generated by fwts and check it for certain
4errors detected during testing. It expects that this is a log file created by
5fwts at runtime using the -l <log name> option.
6
7It's written now specifically for checking ater the fwts s3 and s4 tests but
8can be adapted to look for other tests, or all tests.
9'''
10
11import sys
12
13from argparse import ArgumentParser, RawTextHelpFormatter
14
15
16def main():
17 parser = ArgumentParser()
18 parser.add_argument('-v', '--verbose',
19 action='store_true',
20 default=False,
21 help="Display each error discovered. May provide \
22 very long output. Also, this option will only \
23 provide a list of UNIQUE errors encountered in \
24 the log file. It will not display duplicates. \
25 Default is [%(default)s]")
26 parser.add_argument('test',
27 action='store',
28 help='The test to check (s3 or s4)')
29 parser.add_argument('logfile',
30 action='store',
31 help='The log file to parse')
32
33 args = parser.parse_args()
34
35 return_code = 0
36
37 #Create a generator and get our lines
38 log = (line.rstrip() for line in open(args.logfile,'r'))
39
40 #Now parse and find out error lines. We're looking for specific keys that
41 #occur in the summary section for each test run.
42 #Error levels we care about:
43 levels = ('critical', 'high', 'medium')
44 errors = {}
45 for level in levels:
46 errors[level] = []
47 for logline in log:
48 for level in levels:
49 if "%s: %s" % (args.test, level.upper()) in logline:
50 line = logline.split(']',1)[1].strip()
51 #Only include unique lines to avoid hundreds of repititions
52 if line not in errors[level]:
53 errors[level].append(line)
54
55 for level in levels:
56 if errors[level]:
57 return_code = 1
58 print("%s errors: %s" % (level.upper(), len(errors[level])))
59 if args.verbose:
60 #Print the actual errors)
61 print('='*40)
62 for line in errors[level]:
63 print(line)
64 print('\n')
65
66 if return_code == 0:
67 print("No errors detected")
68
69 return return_code
70
71if __name__ == '__main__':
72 sys.exit(main())

Subscribers

People subscribed via source and target branches