Merge lp:~bladernr/checkbox/1217268 into lp:checkbox

Proposed by Jeff Lane 
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 2327
Merged at revision: 2328
Proposed branch: lp:~bladernr/checkbox/1217268
Merge into: lp:checkbox
Diff against target: 54 lines (+26/-5)
2 files modified
checkbox-old/debian/changelog (+4/-1)
checkbox-old/scripts/storage_test (+22/-4)
To merge this branch: bzr merge lp:~bladernr/checkbox/1217268
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+183056@code.launchpad.net

Commit message

scripts/storage test now checks to make sure there's enough free disk space before running bonnie++ and adjusts bonnie++ parameters accordingly if there is not enough free disk space. This avoids a bug causing false failures on systems with small disk drives.

Description of the change

scripts/storage_test now checks to make sure there's enough disk space and adjusts bonnie++ accordingly to avoid running out of disk space on small disks

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Looks good _BUT_ all the df / awk stuff makes me cry (it's very fragile, probably breaks when disk will have a space name in it) I would really like us to use saner APIs for that (udisks/gnome volume manager). This should also be reported upstream so that we don't have to carry patches like that in our tree.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-old/debian/changelog'
2--- checkbox-old/debian/changelog 2013-08-29 16:14:14 +0000
3+++ checkbox-old/debian/changelog 2013-08-29 23:49:56 +0000
4@@ -2,7 +2,10 @@
5
6 [ Jeff Lane ]
7 * scripts/memory_compare: output now displays kB properly, not bytes labled
8- * as kB. (LP: #1217506)
9+ as kB. (LP: #1217506)
10+ * scripts/storage_test: script now ensures there is enough free disk space
11+ before running bonnie++ and adjusts bonnie++ parameters accordingly if
12+ necessary (LP: #1217268)
13
14 [ Daniel Manrique ]
15 * scripts/storage_test: Use parted silent mode to avoid hanging on disks
16
17=== modified file 'checkbox-old/scripts/storage_test'
18--- checkbox-old/scripts/storage_test 2013-08-28 15:34:41 +0000
19+++ checkbox-old/scripts/storage_test 2013-08-29 23:49:56 +0000
20@@ -4,12 +4,30 @@
21
22 function run_bonnie() {
23 echo "Running bonnie++ on $1..."
24-
25- # Determine where to put the scratchdisk
26- mount_point=$(df -h | grep $1 | awk '{print $6}')
27+ mount_point=$(df -h | grep -m 1 $1 | awk '{print $6}')
28 echo "Putting scratch disk at $mount_point"
29 mkdir -p "$mount_point/tmp/scratchdir"
30- bonnie++ -d "$mount_point/tmp/scratchdir" -u root
31+
32+ # When running on disks with small drives (SSD/flash) we need to do
33+ # some tweaking. Bonnie uses 2x RAM by default to write data. If that's
34+ # more than available disk space, the test will fail inappropriately.
35+ free_space=$(df -m | grep -m 1 $1 | awk '{print $4}')
36+ echo " Disk $1 has ${free_space}MB available"
37+ memory=$(free -m |grep Mem|awk '{print $2}')
38+ echo " System has ${memory}MB RAM"
39+ disk_needed=$((memory * 2))
40+ echo " We need ${disk_needed}MB of disk space for testing"
41+ if [[ "$disk_needed" -ge "$free_space" ]]; then
42+ echo " Insufficient disk space available for defaults."
43+ echo " reducing memory footprint to be 1/2 of free disk space."
44+ # we need to pass an amount that's 1/2 the amount of available disk
45+ # space to bonnie++ so she doesn't overwrite and fail.
46+ disk_needed=$(($free_space/2))
47+ bonnie++ -d $mount_point/tmp/scratchdir -u root -r $disk_needed
48+ else
49+ echo " Free disk space is sufficient to continue testing."
50+ bonnie++ -d $mount_point/tmp/scratchdir -u root
51+ fi
52 }
53
54 disk=/dev/$1

Subscribers

People subscribed via source and target branches