~ubuntuone-support/+junk/syncdaemon-perftest

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
80
81
82
83
84
85
86
#!/bin/bash
#
# Run syncdaemon-perftest.py for every shard we have tokens for
# 
# Usage: ./syncdaemon-perftest-run.sh
#

cd `dirname $0`

# If the configuration is not there, we will do nothing
CONFIG=syncdaemon-perftest.conf

if [ ! -f $CONFIG ]; then
    exit 0
fi

source $CONFIG

killall ubuntuone-syncdaemon

REALHOME=$HOME

export PYTHONPATH=$PWD/lib:.
export PATH=$PWD/bin:$PATH

TYPE=$1

[ -z "$TYPE" ] && TYPE="meta"

for X in ${TOKENS[@]}; do
    shard_id=`echo $X | cut -d '/' -f 1`
    oauth=`echo $X | cut -d '/' -f 2`

    export HOME="/tmp/sdperftest-$shard_id"
    rm -rf $HOME $HOME.result
    mkdir -p $HOME

    # Configure SD
    mkdir -p $HOME/.config/ubuntuone
    cat > $HOME/.config/ubuntuone/syncdaemon.conf <<EOF
[__main__]
oauth=$oauth
autoconnect=False

[logging]
level=DEBUG
file_size=0
EOF

    # Launch SD in new environment
    (
        # Run our own dbus session
        eval `dbus-launch`
        export DBUS_SESSION_BUS_ADDRESS
        OPTIONS=

        if [ "$TYPE" = "speed" ]; then
            OPTIONS="--file-count=1 --file-size=5242880 --track-speed"
        fi
        if [ "$TYPE" = "meta" ]; then
            OPTIONS="--file-count=200 --file-size=0 --track-queues"
        fi
        if [ "$TYPE" = "mixed" ]; then
            OPTIONS="--file-count=200 --file-size=..1048576 --track-speed --track-queues"
        fi

        # Syncdaemon will be autostarted
        python syncdaemon-perftest.py \
            --log $HOME.log \
            --graph-prefix="$STATSD_PREFIX.$shard_id" \
            $OPTIONS \
            --statsd $STATSD_HOST:$STATSD_PORT \
            --oauth "$oauth" \
            --timeout=$((8 * 60)) # 8 minutes

        kill $DBUS_SESSION_BUS_PID
    ) &

    echo "Started test for $shard_id"
done

# Waiting for children to complete
wait

echo "Done"