-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_child.sh
executable file
·80 lines (69 loc) · 1.75 KB
/
test_child.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Load a bunch of variables
. settings.sh
usage () {
echo "This script is supposed to be called from test_start.sh."
echo "Usage:"
echo "$0 <read|write>"
exit
}
timer_start () {
START=`python -c "import time; print time.time()"`
echo $START
}
timer_stop () {
START=$1
STOP=`python -c "import time; print time.time()"`
python -c "print 'time:'+str($STOP)+';'+str($TESTFILE_SIZE_KB/1024.0)+' MB; '+str($STOP-$START)+' sec; Throughput: '+str($TESTFILE_SIZE_KB/(($STOP-$START)*1024.0))+' MB/s.'"
}
get_random_file_number () {
if [ -z "$1" ] ; then
echo "Function get_random_file_number needs a max number."
exit 1
fi
a=`expr $RANDOM \* $1`
b=`expr $a / 32768`
NUMBER=`expr $b + 1`
echo $NUMBER
}
test_read () {
# Client read test
while true; do
NUMBER=`get_random_file_number $FILES`
START=`timer_start`
curl -s -S -k --user $USER:$PASSWD -L ${PROTOCOL}://${REMOTE_SERVER}/${STORAGE_PATH}/readtestfiles${TESTFILE_SIZE_KB}/testfile_${TESTFILE_SIZE_KB}_${NUMBER} -o /dev/null
timer_stop $START
done
}
test_write () {
# Client write test
DIR=writetestfiles${TESTFILE_SIZE_KB}`uuid`
curl -s -S -k --user $USER:$PASSWD -X MKCOL ${PROTOCOL}://${REMOTE_SERVER}/${STORAGE_PATH}/${DIR} >/dev/null 2>&1
i=1
while true; do
j=`expr $i % $FILES`
START=`timer_start`
curl -s -S -k --user $USER:$PASSWD -T $WRITEDIR/file${TESTFILE_SIZE_KB} -L ${PROTOCOL}://${REMOTE_SERVER}/${STORAGE_PATH}/${DIR}/testfile_${TESTFILE_SIZE_KB}_${j}
timer_stop $START
i=`expr $i + 1`
done
}
if [ $# -ne 1 ]; then
usage
exit 1
fi
test=$1
case $test in
"read" )
test_read
exit 0
;;
"write" )
test_write
exit 0
;;
* )
usage
exit 1
;;
esac