~roadmr/checkbox/912946

« back to all changes in this revision

Viewing changes to scripts/storage_test

Imported scripts and jobs from Platform Services.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# take the path of the storage device and test is it a block device.
 
4
 
 
5
function run_bonnie() {
 
6
    echo "Running bonnie++ on $1..."
 
7
 
 
8
    # Determine where to put the scratchdisk
 
9
    mount_point=$(df -h | grep $1 | awk '{print $6}')
 
10
    echo "Putting scratch disk at $mount_point"
 
11
    mkdir -p "$mount_point/tmp/scratchdir"
 
12
    bonnie++ -d "$mount_point/tmp/scratchdir" -u root
 
13
}
 
14
 
 
15
disk=/dev/$1
 
16
 
 
17
if [ -b $disk ]
 
18
then
 
19
    echo "$disk is a block device"
 
20
    size=`parted -l | grep $disk | awk '{print $3}'`
 
21
 
 
22
    if [ -n "$size" ]
 
23
    then
 
24
        echo "$disk reports a size of $size."
 
25
        # Have to account for the end of the size descriptor
 
26
        size_range=${size:(-2)}
 
27
 
 
28
        if [ $size_range == "KB" ]
 
29
        then
 
30
            echo "$disk is too small to be functioning."
 
31
            exit 1
 
32
        elif [ $size_range == "MB" ]
 
33
        then
 
34
            size_int=${size::${#size}-2}
 
35
 
 
36
            if [ $size_int -gt 10 ]
 
37
            then
 
38
                run_bonnie $disk
 
39
            else
 
40
                echo "$disk is too small to be functioning."
 
41
                exit 1
 
42
            fi
 
43
        else
 
44
            run_bonnie $disk
 
45
        fi
 
46
    else
 
47
       echo "$disk doesn't report a size."
 
48
       exit 1
 
49
    fi
 
50
else
 
51
    echo "$disk is not listed as a block device."
 
52
    exit 1
 
53
fi