Ticket #1456: test-run.sh

File test-run.sh, 3.5 KB (added by T_X, at 2011-08-07T19:06:28Z)

updated version of the test script

Line 
1#!/bin/sh
2
3#BIN="/home/mesh-node/allmydata-tahoe-1.8.2/bin/tahoe"
4BIN="/mnt/dev/tahoe-lafs/bin/tahoe"
5#BIN="/mnt/dev/tahoe-lafs.git/bin/tahoe"
6UPLOAD="/mnt/tahoe-file2upload"
7TAHOE_INTRO_DIR="~/.tahoe-intro"
8TAHOE_1_DIR="~/.tahoe-1"
9TAHOE_2_DIR="~/.tahoe-2"
10TMP_DIR="/tmp"
11#TEST_TEXT="test download text"
12TEST_TEXT="test download text test download text test download text test download text test download text"
13NUM_TEST_ROUNDS="1"
14
15# Requirements for this test configuration:
16# - tahoe-lafs
17# - trickle
18# - vnstat
19# - TCP Vegas
20
21runtest(){
22        TOTAL=0
23        #[ -f $TMP_DIR/tahoe-stats-$1.log ] && rm $TMP_DIR/tahoe-stats-$1.log
24        date > $TMP_DIR/tahoe-stats-$1.log
25
26        for i in `seq 1 $NUM_TEST_ROUNDS`; do
27                [ -f $TMP_DIR/tahoe-file2download ] && rm $TMP_DIR/tahoe-file2download
28                /usr/bin/time -o $TMP_DIR/tahoe-stats-$1.log -a -f "%e" $BIN get -d $TAHOE_2_DIR tahoe:tahoe-file2download $TMP_DIR/tahoe-file2download
29                [ -z "`grep "$TEST_TEXT" $TMP_DIR/tahoe-file2download`" ] && echo "tahoe get ERROR!" >> $TMP_DIR/tahoe-stats-$1.log
30        done
31        cat $TMP_DIR/tahoe-stats-$1.log | awk -v ave=0 -v count=$NUM_TEST_ROUNDS '{ ave+=$1; print $1}; END { print "Average: " ave / count }'
32}
33
34prepare() {
35        # Use TCP Vegas to minimize network latency
36        [ -z "`grep "vegas" /proc/sys/net/ipv4/tcp_available_congestion_control`" ] && \
37                sudo modprobe tcp_vegas
38        [ -z "`grep "vegas" /proc/sys/net/ipv4/tcp_congestion_control`" ] && \
39                sudo su -c "echo vegas > /proc/sys/net/ipv4/tcp_congestion_control"
40
41        # Tahoe-1: Storage node
42        # Tahoe-2: Gateway node, no storage
43        killall tahoe
44        $BIN start -d $TAHOE_INTRO_DIR
45        $BIN start -d $TAHOE_1_DIR
46        $BIN start -d $TAHOE_2_DIR
47        sleep 3
48
49        # Prepare and upload the small file which we want to download later
50        echo "$TEST_TEXT" > $TMP_DIR/tahoe-file2download2
51        $BIN put -d $TAHOE_2_DIR $TMP_DIR/tahoe-file2download2 tahoe:tahoe-file2download
52}
53
54vnstatwait() {
55        echo "Starting upload. Press enter after you see the speed reaching about 800kbit/s"
56        vnstat -i lo -l &
57        read FOO
58        killall vnstat
59}
60
61### Test 0: Download with no parallel upload or limitations
62test0() {
63        killall tahoe
64        $BIN start -d $TAHOE_INTRO_DIR
65        $BIN start -d $TAHOE_1_DIR
66        $BIN start -d $TAHOE_2_DIR
67        sleep 3
68
69        echo "### Running Test 0: Download with no parallel upload or limitations..."
70        runtest 0
71}
72
73### Test 1: Parallel 'tahoe put', limited to 800kbit/s ###
74test1() {
75        killall tahoe
76        $BIN start -d $TAHOE_INTRO_DIR
77        $BIN start -d $TAHOE_1_DIR
78        $BIN start -d $TAHOE_2_DIR
79        sleep 3
80
81        trickle -s -u 100 -d 100 $BIN put -d $TAHOE_2_DIR $UPLOAD tahoe:tahoe-file2upload 2> /dev/null &
82        vnstatwait
83
84        echo "### Running Test 1: Parallel 'tahoe put', limited to 800kbit/s..."
85        runtest 1
86}
87
88### Test 2: Parallel 'tahoe put', tahoe-2 (gateway) limited to 800kbit/s ###
89test2() {
90        killall tahoe
91        $BIN start -d $TAHOE_INTRO_DIR
92        $BIN start -d $TAHOE_1_DIR
93        trickle -s -u 100 -d 100 $BIN run -d $TAHOE_2_DIR &
94        sleep 3
95
96        $BIN put -d $TAHOE_2_DIR $UPLOAD tahoe:tahoe-file2upload 2> /dev/null &
97        vnstatwait
98
99        echo "### Running Test 2: Parallel 'tahoe put', tahoe-2 (gateway) limited to 800kbit/s..."
100        runtest 2
101}
102
103### Test 3: Parallel 'tahoe put', tahoe-1 (storage) limited to 800kbit/s ###
104test3() {
105        killall tahoe
106        $BIN start -d $TAHOE_INTRO_DIR
107        $BIN start -d $TAHOE_2_DIR
108        trickle -s -u 100 -d 100 $BIN run -d $TAHOE_1_DIR &
109        sleep 3
110
111        $BIN put -d $TAHOE_2_DIR $UPLOAD tahoe:tahoe-file2upload 2> /dev/null &
112        vnstatwait
113
114        echo "### Running Test 3: Parallel 'tahoe put', tahoe-1 (storage) limited to 800kbit/s..."
115        runtest 3
116}
117
118
119prepare
120
121test0
122test1
123test2
124test3