Last active
March 16, 2018 09:20
-
-
Save Alykoff/1c6d3d64f2f57141e8f0e3ca94c666e9 to your computer and use it in GitHub Desktop.
tank.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
url=$1 | |
if [ -z "$url" ]; then | |
url=localhost | |
fi | |
rm ammo.txt | |
touch ammo.txt | |
cat >> ammo.txt << EOF | |
[Cookie: COOKIE_NAME=111111111111111] | |
73 /index?q=1 | |
{"json": "hahaha"} | |
73 /index?q=2 | |
{"json": "hahaha"} | |
EOF | |
rm config.yml | |
touch config.yml | |
cat >> config.yml << EOF | |
telegraf: | |
enabled: false | |
json_report: | |
enabled: true | |
phantom: | |
timeout: 70s | |
ammo_type: uripost | |
address: docker.for.mac.localhost:8080 | |
headers: | | |
[Host: www.target.com] | |
[Content-Type: application/json] | |
[Connection: keep-alive] | |
[Accept: application/json] | |
[Cache-Control: no-cache] | |
load_profile: | |
load_type: rps | |
schedule: const(10,18s) | |
header_http: '1.1' | |
package: yandextank.plugins.Phantom | |
ssl: false | |
overload: | |
enabled: true | |
package: yandextank.plugins.DataUploader | |
# api_address: https://overload.yandex.net | |
api_address: overload.com | |
token_file: token.txt | |
job_name: tteesstt | |
job_dsc: ttttt | |
operator: nop | |
[monitoring] | |
config=none | |
EOF | |
curl -v -c cookie.txt "http://$url:8080/login" -H 'Pragma: no-cache' -H 'Origin: http://localhost:8080' -H 'Content-type: application/json' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Referer: http://localhost:8080/login' --data-binary '{"login": "admin", "password": "3290gjlkhvo23", "isLK": false}' --compressed | |
token=`cat cookie.txt | tail -1 | awk '{print $NF}'` | |
echo "token" | |
echo $token | |
if [ -n "$token" ]; then | |
echo "insert token in ammo" | |
row="\[Cookie\: COOKIE_NAME\=$token\]" | |
sed -i'' -e "1 s/^.*$/[Cookie: COOKIE_NAME=$token]/" ammo.txt | |
fi | |
# --network=host | |
docker run -v $(pwd):/var/loadtest -v $HOME/.ssh:/root/.ssh --network=host -it direvius/yandex-tank -c config.yaml ammo.txt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment