4

I want to use yandex tank to test my web app, I want to test registration, so i need to send request like this

  • Header

    POST /registration HTTP/1.1
    Host: localhost:8080
    Connection: keep-alive
    Content-Length: 30
    Cache-Control: max-age=0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Origin: http://localhost:8080
    User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36
    Content-Type: application/x-www-form-urlencoded
    Referer: http://localhost:8080/registration
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: en-US,en;q=0.8,ru;q=0.6
    Cookie: csrftoken=XJ3oheJb0SndHfNAH2lSV2AtKNxxuXdv; JSESSIONID=igq9ejgl10jirr4t73mpjblp
    
  • Form Data

    login=abracadbra&password=brar
    

Is it possible to send that kind of requests with different login fields?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mike Minaev
  • 1,912
  • 4
  • 23
  • 33

2 Answers2

6

Yes, it's possible, for POST requests your should use request-style ammo file, see http://yandextank.readthedocs.org/en/latest/tutorial.html#request-style

You may specify ammo file as command line parameter or put it in tank .ini file in [phantom] section.

Remember that with phantom as load-generator it's not possible to perform scenario-based testing, so you should generate all necessary data for requests in advance. Yandex-tank will just send it according to desired load-scheme.

I'm not sure how CSRF protection works in your case, and if it does not permit re-use of session and csrftoken for multiple requests (and this parameters are mandatory for registration requests), you'll need to somehow obtain valid Cookies for each request to generate ammo. In this case I'd recommend you to switch to some scenario-based tool, i.e. jmeter. You may use jmeter as load-generator for yandex-tank as well, see http://yandextank.readthedocs.org/en/latest/configuration.html#jmeter

In case you may reuse same Cookie for multiple registrations, ammo file will be like that:

649 tag1
POST /registration HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 30
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://localhost:8080
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://localhost:8080/registration
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,ru;q=0.6
Cookie: csrftoken=XJ3oheJb0SndHfNAH2lSV2AtKNxxuXdv; JSESSIONID=igq9ejgl10jirr4t73mpjblp

login=abracadbra&password=brar

646 tag2
POST /registration HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 27
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://localhost:8080
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://localhost:8080/registration
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,ru;q=0.6
Cookie: csrftoken=XJ3oheJb0SndHfNAH2lSV2AtKNxxuXdv; JSESSIONID=igq9ejgl10jirr4t73mpjblp

login=sample2&password=brar

...
F2nd
  • 384
  • 1
  • 6
  • So i must generate big ammo file with 10000 request's and give it to yandex tank? – Mike Minaev Mar 11 '14 at 18:14
  • Yes, with phantom load generator (default) you have to provide complete POST requests in ammo file in advance. BTW, default behaivor is to loop ammo file, if you want to prevent it (for example using same name will cause an error) - add parameter loop=1 to [phantom] section of config file. – F2nd Mar 11 '14 at 18:34
  • while i test i have an error "17:18:56 ERROR: Not enough resources: free memory less than 512MB: 503MB", is it possible to give more space? – Mike Minaev Mar 13 '14 at 13:20
  • This check is done by **ResourceCheck** plugin and it ensures that you have enough free memory on machine running tank. Taking into account that it includes caches and buffers into free memory, 512MB is really small amount, i'd advise you to check resources and, probably, terminate some other applications. You could adjust this check via config file, add section **[rcheck]** with **mem_limit=XXX**, where XXX - desired amout of free memory (in megabytes). – F2nd Mar 13 '14 at 17:33
1

There is also URI+POST format similar to uri-style, but with post bodies:

load.ini:

ammo_type=uripost

ammo.uripost:

[Host: example.org]
[Connection: close] 
[User-Agent: Tank]  
5 /route/?rll=50.262025%2C53.276083~50.056015%2C53.495561&origin=1&simplify=1
class
10 /route/?rll=50.262025%2C53.276083~50.056015%2C53.495561&origin=1&simplify=1
hello!clas
7 /route/?rll=37.565147%2C55.695758~37.412796%2C55.691454&origin=1&simplify=1
uripost

Numbers at the beginnings of lines with uris are sizes of post bodies.

Direvius
  • 427
  • 3
  • 17