Yandex-tank add cookie and Host headers to requests from access log

1.1k Views Asked by At

I have an access.log nginx with cookie:

99.20.231.22 www.carite.com - [01/Dec/2015:03:00:10 -0600] "GET /?mode=_ajax&_imod[]=i159330&make=Mercedes-Benz&_=1448960297171 HTTP/1.1" 200 1182 "http://www.carite.com/" "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1" "PHPSESSID=ebg5n89m9pc1iamekii1qra5k0; chooseStoreNotificationShown=1; dfa_visit=1448960180633603603; dfa_visitor=1448960180633796491; mod-compare-box=%7B%22vehicles%22%3A%7B%22v11279294%22%3A%7B%22vuid%22%3A%2211279294%22%2C%22isCompared%22%3Afalse%7D%7D%2C%22compareAll%22%3Atrue%2C%22cookieLifeTime%22%3A30%2C%22cookiePath%22%3A%22%5C%2F%22%7D; _ga=GA1.2.10339867.1448960182; _gali=make; _gat_a1=1; _gat_a2=1; _gat_a3=1; _gat_a4=1; usy46gabsosd=collserve__-2_1448960382693_8786" 80 0.295

Can I specify Yandex-tank get cookie from access log and add it to every yandex-tank request?

Also I need get header "Host:" from access log instead of specify it in load.ini like: headers = [Host: www.carite.com]

1

There are 1 best solutions below

6
On

You have two options:

  1. to make stepper read cookies along with uri from access.log (it should be done around there https://github.com/yandex/yandex-tank/blob/master/yandextank/stepper/missile.py#L213)

  2. make a separate file from access.log, in https://yandextank.readthedocs.org/en/latest/tutorial.html#uri-style-uris-in-file format. Headers are overriden on the go, so you can redefine headers anywhere

    For example it could be like this:

    [Host: www.carite.com]
    [Cookie: PHPSESSID=ebg5n89m9pc1iamekii1qra5k0; chooseStoreNotificationShown=1; dfa_visit=1448960180633603603; dfa_visitor=1448960180633796491; ...]
    /?mode=_ajax&imod[]=i159330&make=Mercedes-Benz&=1448960297171
    ...
    [Host: example.com]
    [Cookie: myowncookie=1]
    /something
    ...

I would advice to use the 2nd way as an easiest one