summaryrefslogtreecommitdiff
path: root/service/test/load/attachment_load.sh
blob: 5dce71b355d74df843e4d1d4caf24087be3c75b9 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
# Copyright (c) 2015 ThoughtWorks, Inc.
#
# Pixelated is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.

#!/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..."