0

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]

r2d2
  • 183
  • 11

1 Answers1

0

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

r2d2
  • 183
  • 11
  • Second way an easiest if I have in access log requests to only one host. But I have different hosts, and need that header "Host" in requests change accordingly records in access log. Field request somehow recognized from access.log. Is it possible that another field (Header "Host") is recognized too? –  Dec 02 '15 at 13:49
  • Headers are overriden on the fly, i.e [Host: www.carite.com] will be used for request /?mode=_ajax&imod[]=i159330&make=Mercedes-Benz&=1448960297171, and if you write further [Host: example.com], it will be applied for all uri that will be read next. – r2d2 Dec 02 '15 at 14:19
  • I want to modify https://github.com/yandex/yandex-tank/blob/master/yandextank/stepper/missile.py#L213 but i dont quite realized how headers pass to it. Headers is a dict or massive? Which format? –  Dec 02 '15 at 17:53
  • https://github.com/yandex/yandex-tank/blob/master/yandextank/stepper/missile.py#L21 - here is headers example, it's simple set. – r2d2 Dec 03 '15 at 12:02
  • I try replace `https://github.com/yandex/yandex-tank/blob/master/yandextank/stepper/missile.py#L221` on `headers=['Host: www.carite.com']` but in access.log cant see host name. If I set `[Host: www.carite.com]` in load.ini it work. –  Dec 03 '15 at 13:33
  • As for `print HttpAmmo('/', ['Connection: Close', 'Content-Type: Application/JSON']).to_s()` -- headers are elements of list. And I try exactly the same. –  Dec 03 '15 at 13:36