summaryrefslogtreecommitdiff
path: root/service/test/load/attachment_load.sh
blob: 740dd846d9c6198d9b70dde01577be236bd30d50 (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

number=$1
csrf=$2
session=$3

if [ -z $sleep_time ]
then
    sleep_time=0.5
fi

if [ -z $host ]
then
    host='https://unstable.pixelated-project.org:8080'
fi

echo "upload $number files"
echo "with csrf $csrf"
echo "and session $session"
echo "in $host"

echo "Generating $number attachements of 5Mb size..."
for i in `seq 1 $number`; do
    rm -rf /tmp/test$i
    dd if=/dev/urandom of=/tmp/test$i bs=1M count=5
done

new_line=""

echo "Uploading..."
for i in `seq 1 $number`; do
    echo $new_line
    echo "Attachment $i"
    curl -sS -k -X POST --cookie "XSRF-TOKEN=$csrf; TWISTED_SESSION=$session;" \
         --header "X-XSRF-TOKEN=$csrf"  -F attachment=@/tmp/test$i -F csrftoken=$csrf \
         $host/attachment &
    sleep $sleep_time
done

echo $new_line
echo "Done..."