load-testingyandexyandex-tank

How to execute POST


Using curl I have:

$ curl -v -d "userName=user1&password=passwd1&language=en" http://myhost:23094/api/v2/authToken
...
> POST /api/v2/authToken HTTP/1.1
> User-Agent: curl/7.30.0
> Host: myhost:23094
> Accept: */*
> Content-Length: 39
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 39 out of 39 bytes
< HTTP/1.1 200 OK

I try to build a yandex tank script using this query:

My load.ini:

[phantom]
address=my.ip.v4.here
port=8094
rps_schedule=line(1, 10, 1m)
ammo_type=uripost

My ammo.txt

133 login
POST /api/v2/authToken HTTP/1.1
User-Agent: tank
Host: somemyhost.com
Content-Length: 39

userName=user1&password=passwd1&language=en

When I run yandex-tank ammo.txt, I get the 400 Bad Request error. It seems to me, that tank can't use the body parameters. How to make it use them? What do I do wrong?


Solution

  • Your ammo is not in uripost format. Don't specify ammo_type at all and it should work properly. If you want to use uripost format, specify your headers in load.ini and write something like the following in your ammo file:

    39 /api/v2/authToken login
    
    userName=user1&password=passwd1&language=en
    

    Here is the description of the uripost format.