Merge lp:~asac/ubuntu-test-cases/use-top-and-always-dumb-toplog into lp:ubuntu-test-cases

Proposed by Alexander Sack
Status: Superseded
Proposed branch: lp:~asac/ubuntu-test-cases/use-top-and-always-dumb-toplog
Merge into: lp:ubuntu-test-cases
Diff against target: 376 lines (+286/-0)
16 files modified
ifconfig/tc_control (+14/-0)
install/tc_control (+13/-0)
master.run (+5/-0)
netstat/tc_control (+13/-0)
ping/tc_control (+13/-0)
pwd/tc_control (+10/-0)
pwd/test.sh (+7/-0)
route/tc_control (+13/-0)
systemsettle/systemsettle.sh (+125/-0)
systemsettle/tc_control (+10/-0)
ts_control (+3/-0)
tslist.run (+11/-0)
uname/tc_control (+13/-0)
unity8/tc_control (+10/-0)
update/tc_control (+13/-0)
vmstat/tc_control (+13/-0)
To merge this branch: bzr merge lp:~asac/ubuntu-test-cases/use-top-and-always-dumb-toplog
Reviewer Review Type Date Requested Status
Ubuntu Test Case Developers Pending
Review via email: mp+180827@code.launchpad.net

This proposal has been superseded by a proposal from 2013-08-19.

Description of the change

+ use top in batchmode instead of vmstat
+ improve logging; echo cli arguments given as well as
+ dumb top_log regardless of success and failyure
+ top_log is now more useful to see what was going on as we dumb exactly what was measured

To post a comment you must log in.
14. By Alexander Sack

fix idle_avg calc to deal better with non-natural numbers getting passed

15. By Alexander Sack

improve systemsettle idle measurement run logging now that we don't run vmstat anymore

16. By Alexander Sack

since we now use top instead of vmstat, let's use s/vmstat/top/ for all variables as well

17. By Alexander Sack

don't log the top command used in systemsettle anymore

Unmerged revisions

17. By Alexander Sack

don't log the top command used in systemsettle anymore

16. By Alexander Sack

since we now use top instead of vmstat, let's use s/vmstat/top/ for all variables as well

15. By Alexander Sack

improve systemsettle idle measurement run logging now that we don't run vmstat anymore

14. By Alexander Sack

fix idle_avg calc to deal better with non-natural numbers getting passed

13. By Alexander Sack

improve logging; echo cli args used and always echo top_log regardless of success/fail

12. By Alexander Sack

use top instead of vmstat; this gives us top measurements all time during run

11. By Paul Larson

Add options and extra configurability to systemsettle.sh

10. By Andy Doan

add systemsettle test that waits for idle

9. By Paul Larson

Add a smoke test for detecting presence of the UI on ubuntu-touch

8. By Paul Larson

Fix bug #1192166 - pwd test fails on touch images

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'ifconfig'
2=== added file 'ifconfig/tc_control'
3--- ifconfig/tc_control 1970-01-01 00:00:00 +0000
4+++ ifconfig/tc_control 2013-08-19 10:31:04 +0000
5@@ -0,0 +1,14 @@
6+description: make sure wlan0 exists
7+dependencies: none
8+action: |
9+ 1. ifconfig
10+ 2. Make sure there is a wlan0
11+expected_results: |
12+ 1. there is a wlan0 on the system
13+type: userland
14+timeout: 60
15+command: ifconfig; ifconfig | grep wlan0
16+run_as: phablet
17+#build_cmd:
18+#tc_setup:
19+#tc_cleanup:
20
21=== added directory 'install'
22=== added file 'install/tc_control'
23--- install/tc_control 1970-01-01 00:00:00 +0000
24+++ install/tc_control 2013-08-19 10:31:04 +0000
25@@ -0,0 +1,13 @@
26+description: apt-get install works
27+dependencies: openssh-server
28+action: |
29+ 1. apt-get install -y curl
30+expected_results: |
31+ 1. apt-get install can install a package and ends with exit code 0
32+type: userland
33+timeout: 120
34+command: apt-get install -y curl
35+run_as: root
36+#build_cmd:
37+#tc_setup:
38+tc_cleanup: apt-get remove -y curl
39
40=== added file 'master.run'
41--- master.run 1970-01-01 00:00:00 +0000
42+++ master.run 2013-08-19 10:31:04 +0000
43@@ -0,0 +1,5 @@
44+---
45+testsuites:
46+ - name: smoke_touch
47+ fetch_method: bzr # one of 'bzr', 'bzr-export', 'dev', 'git'
48+ fetch_location: lp:ubuntu-test-cases/touch
49
50=== added directory 'netstat'
51=== added file 'netstat/tc_control'
52--- netstat/tc_control 1970-01-01 00:00:00 +0000
53+++ netstat/tc_control 2013-08-19 10:31:04 +0000
54@@ -0,0 +1,13 @@
55+description: netstat -l lists all the services
56+dependencies: none
57+action: |
58+ 1. netstat -l
59+expected_results: |
60+ 1. netstat shows output and exists cleanly
61+type: userland
62+timeout: 60
63+command: netstat -l
64+run_as: phablet
65+#build_cmd:
66+#tc_setup:
67+#tc_cleanup:
68
69=== added directory 'ping'
70=== added file 'ping/tc_control'
71--- ping/tc_control 1970-01-01 00:00:00 +0000
72+++ ping/tc_control 2013-08-19 10:31:04 +0000
73@@ -0,0 +1,13 @@
74+description: ping -c 5 10.97.0.1
75+dependencies: None
76+action: |
77+ 1. ping -c 5 10.97.0.1
78+expected_results: |
79+ 1. ping ends without an error
80+type: userland
81+timeout: 60
82+command: ping -c 5 10.97.0.1
83+run_as: phablet
84+#build_cmd:
85+#tc_setup:
86+#tc_cleanup:
87
88=== added directory 'pwd'
89=== added file 'pwd/tc_control'
90--- pwd/tc_control 1970-01-01 00:00:00 +0000
91+++ pwd/tc_control 2013-08-19 10:31:04 +0000
92@@ -0,0 +1,10 @@
93+description: pwd works
94+dependencies: none
95+action: |
96+ 1. cd to /tmp and verify which is the current directory
97+expected_results: |
98+ 1. Current directory is /tmp
99+type: userland
100+timeout: 60
101+command: ./test.sh
102+run_as: phablet
103
104=== added file 'pwd/test.sh'
105--- pwd/test.sh 1970-01-01 00:00:00 +0000
106+++ pwd/test.sh 2013-08-19 10:31:04 +0000
107@@ -0,0 +1,7 @@
108+#!/bin/bash
109+echo pwd is: $(pwd)
110+echo Changing to /tmp...
111+cd /tmp
112+echo Checking that cd worked...
113+echo directory is now $(pwd), should be /tmp
114+/usr/bin/test $(pwd) == '/tmp'
115
116=== added directory 'route'
117=== added file 'route/tc_control'
118--- route/tc_control 1970-01-01 00:00:00 +0000
119+++ route/tc_control 2013-08-19 10:31:04 +0000
120@@ -0,0 +1,13 @@
121+description: route shows wlan0 routes
122+dependencies: none
123+action: |
124+ 1. route | grep wlan0
125+expected_results: |
126+ 1. route shows wlan0 routes
127+type: userland
128+timeout: 60
129+command: route | grep wlan0
130+run_as: phablet
131+#build_cmd:
132+#tc_setup:
133+#tc_cleanup:
134
135=== added directory 'systemsettle'
136=== added file 'systemsettle/systemsettle.sh'
137--- systemsettle/systemsettle.sh 1970-01-01 00:00:00 +0000
138+++ systemsettle/systemsettle.sh 2013-08-19 10:31:04 +0000
139@@ -0,0 +1,125 @@
140+#!/bin/bash
141+
142+set -e
143+
144+# default exit code storage
145+dump_error=1
146+
147+calc () { awk "BEGIN{ print $* }" ;}
148+
149+cleanup () {
150+ if ! test "$dump_error" = 0; then
151+ echo "Check out the following top log taken at each retry:"
152+
153+ echo
154+ # dumb toplog indented
155+ while read line; do
156+ echo " $line"
157+ done < $top_log
158+ # dont rerun this logic in case we get multiple signals
159+ dump_error=0
160+ fi
161+ rm -f $top_log $vmstat_log $vmstat_log.reduced
162+}
163+
164+function show_usage() {
165+ echo "Usage:"
166+ echo " $0 [options]"
167+ echo "Options:"
168+ echo " -r run forever without exiting"
169+ echo " -p minimum idle percent to wait for (Default: 99)"
170+ echo " -c number of times to run vmstat at each iteration (Default: 10)"
171+ echo " -d seconds to delay between each vmstat iteration (Default: 6)"
172+ echo " -i vmstat measurements to ignore from each loop (Default: 1)"
173+ echo " -m maximum loops of vmstat before giving up if minimum idle"
174+ echo " percent is not reached (Default: 1)"
175+ exit 129
176+}
177+
178+while getopts "h?rp:c:d:i:m:" opt; do
179+ case "$opt" in
180+ h|\?) show_usage
181+ ;;
182+ r) settle_prefix='-'
183+ ;;
184+ p) idle_avg_min=$OPTARG
185+ ;;
186+ c) vmstat_repeat=$OPTARG
187+ ;;
188+ d) vmstat_wait=$OPTARG
189+ ;;
190+ i) vmstat_ignore=$OPTARG
191+ ;;
192+ m) settle_max=$OPTARG
193+ ;;
194+ esac
195+done
196+
197+# minimum average idle level required to succeed
198+idle_avg_min=${idle_avg_min:-99}
199+# measurement details: vmstat $vmstat_wait $vmstat_repeat
200+vmstat_repeat=${vmstat_repeat:-10}
201+vmstat_wait=${vmstat_wait:-6}
202+# how many samples to ignore
203+vmstat_ignore=${vmstat_ignore:-1}
204+# how many total attempts to settle the system
205+settle_max=${settle_max:-10}
206+
207+# set and calc more runtime values
208+vmstat_tail=`calc $vmstat_repeat - $vmstat_ignore`
209+settle_count=0
210+idle_avg=0
211+
212+echo "System Settle run - quiesce the system"
213+echo "--------------------------------------"
214+echo
215+echo " cmd = 'top -b -d $vmstat_wait -n $vmstat_repeat' ignoring first $vmstat_ignore (tail: $vmstat_tail)"
216+echo " idle_avg_min = '$idle_avg_min'"
217+echo " vmstat_repeat = '$vmstat_repeat'"
218+echo " vmstat_wait = '$vmstat_wait'"
219+echo " vmstat_ignore = '$vmstat_ignore'"
220+echo " settle_max = '$settle_max'"
221+echo " run_forever = '$settle_prefix' (- = yes)"
222+echo
223+
224+trap cleanup EXIT INT QUIT ILL KILL SEGV TERM
225+vmstat_log=`mktemp -t`
226+top_log=`mktemp -t`
227+
228+while test `calc $idle_avg '<' $idle_avg_min` = 1 -a "$settle_prefix$settle_count" -lt "$settle_max"; do
229+ echo Starting settle run $settle_count:
230+
231+ # get vmstat
232+ echo "TOP DUMP (after settle run: $settle_count)" >> $top_log
233+ echo "========================" >> $top_log
234+ top -b -d $vmstat_wait -n $vmstat_repeat >> $top_log
235+ cat $top_log | grep '.Cpu.*' | tail -n $vmstat_tail > $vmstat_log.reduced
236+ echo >> $top_log
237+
238+ # calc average of idle field for this measurement
239+ sum=0
240+ count=0
241+ while read line; do
242+ idle=`echo $line | sed -e 's/.* \([0-9\.]*\) id.*/\1/'`
243+ sum=`calc $sum + $idle`
244+ count=`calc $count + 1`
245+ done < $vmstat_log.reduced
246+
247+ idle_avg=`calc $sum.0 / $count.0`
248+ settle_count=`calc $settle_count + 1`
249+
250+ echo
251+ echo "Measurement:"
252+ echo " + idle level: $idle_avg"
253+ echo " + idle sum: $sum / count: $count"
254+ echo
255+done
256+
257+if test `calc $idle_avg '<' $idle_avg_min` = 1; then
258+ echo "system not settled. FAIL"
259+ exit 1
260+else
261+ echo "system settled. SUCCESS"
262+ exit 0
263+fi
264+
265
266=== added file 'systemsettle/tc_control'
267--- systemsettle/tc_control 1970-01-01 00:00:00 +0000
268+++ systemsettle/tc_control 2013-08-19 10:31:04 +0000
269@@ -0,0 +1,10 @@
270+description: check if system settles to idle average > 99.25%
271+dependencies: none
272+action: |
273+ 1. Take CPU load samples for 10 minutes and fail if average idle never goes above 99.25% percent
274+expected_results: |
275+ 1. When doing nothing, system calms down to at least 99.25% idle level
276+type: userland
277+timeout: 720
278+command: ./systemsettle.sh -p 99.25
279+run_as: root
280
281=== added file 'ts_control'
282--- ts_control 1970-01-01 00:00:00 +0000
283+++ ts_control 2013-08-19 10:31:04 +0000
284@@ -0,0 +1,3 @@
285+#build_cmd: echo building
286+#ts_setup: echo setting up
287+#ts_cleanup: echo cleaning up
288
289=== added file 'tslist.run'
290--- tslist.run 1970-01-01 00:00:00 +0000
291+++ tslist.run 2013-08-19 10:31:04 +0000
292@@ -0,0 +1,11 @@
293+- test: pwd
294+- test: uname
295+- test: vmstat
296+- test: systemsettle
297+- test: netstat
298+- test: ifconfig
299+- test: route
300+- test: ping
301+- test: update
302+- test: install
303+- test: unity8
304
305=== added directory 'uname'
306=== added file 'uname/tc_control'
307--- uname/tc_control 1970-01-01 00:00:00 +0000
308+++ uname/tc_control 2013-08-19 10:31:04 +0000
309@@ -0,0 +1,13 @@
310+description: uname shows an ubuntu-phablet image installed
311+dependencies: CHANGE_ME
312+action: |
313+ 1. uname -a|grep ubuntu-phablet
314+expected_results: |
315+ 1. ubuntu-phablet is installed as expected
316+type: userland
317+timeout: 60
318+command: uname -a | grep ubuntu-phablet
319+run_as: phablet
320+#build_cmd:
321+#tc_setup:
322+#tc_cleanup:
323
324=== added directory 'unity8'
325=== added file 'unity8/tc_control'
326--- unity8/tc_control 1970-01-01 00:00:00 +0000
327+++ unity8/tc_control 2013-08-19 10:31:04 +0000
328@@ -0,0 +1,10 @@
329+description: check for unity8 process
330+dependencies: None
331+action: |
332+ 1. pgrep unity8
333+expected_results: |
334+ 1. pgrep exits with 0, indicating it found a matching process
335+type: userland
336+timeout: 60
337+command: /usr/bin/pgrep unity8
338+run_as: phablet
339
340=== added directory 'update'
341=== added file 'update/tc_control'
342--- update/tc_control 1970-01-01 00:00:00 +0000
343+++ update/tc_control 2013-08-19 10:31:04 +0000
344@@ -0,0 +1,13 @@
345+description: apt-get update works
346+dependencies: apt
347+action: |
348+ 1. apt-get update
349+expected_results: |
350+ 1. apt-get update works
351+type: userland
352+timeout: 120
353+command: apt-get update
354+run_as: root
355+#build_cmd:
356+#tc_setup:
357+#tc_cleanup:
358
359=== added directory 'vmstat'
360=== added file 'vmstat/tc_control'
361--- vmstat/tc_control 1970-01-01 00:00:00 +0000
362+++ vmstat/tc_control 2013-08-19 10:31:04 +0000
363@@ -0,0 +1,13 @@
364+description: Execute vmstat and capture output
365+dependencies: none
366+action: |
367+ 1. vmstat
368+expected_results: |
369+ 1. vmstat finishes without an error
370+type: userland
371+timeout: 60
372+command: vmstat
373+run_as: phablet
374+#build_cmd:
375+#tc_setup:
376+#tc_cleanup:

Subscribers

People subscribed via source and target branches