summaryrefslogtreecommitdiffstats
path: root/qa/workunits/suites/fio.sh
blob: ee69de81cb2c086cc3fbf8d1a3bac9a63a6b78fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash

set -x

gen_fio_file() {
  iter=$1
  f=$2
  cat > randio-$$-${iter}.fio <<EOF
[randio]
blocksize_range=32m:128m
blocksize_unaligned=1
filesize=10G:20G
readwrite=randrw
runtime=300
size=20G
filename=${f}
EOF
}

sudo apt-get -y install fio
for i in $(seq 1 20); do
  fcount=$(ls donetestfile* 2>/dev/null | wc -l)
  donef="foo"
  fiof="bar"
  if test ${fcount} -gt 0; then
     # choose random file
     r=$[ ${RANDOM} % ${fcount} ]
     testfiles=( $(ls donetestfile*) )
     donef=${testfiles[${r}]}
     fiof=$(echo ${donef} | sed -e "s|done|fio|")
     gen_fio_file $i ${fiof}
  else
     fiof=fiotestfile.$$.$i
     donef=donetestfile.$$.$i
     gen_fio_file $i ${fiof}
  fi

  sudo rm -f ${donef}
  sudo fio randio-$$-$i.fio
  sudo ln ${fiof} ${donef}
  ls -la
done