Skip to main content

Yandex-tank tools

Project description

https://travis-ci.org/travis-ci/travis-web.svg?branch=master https://codecov.io/gh/gaainf/tanktools/branch/master/graph/badge.svg

Yandex-tank prepare phout file with statistics after load testing. tanktools module helps to parse such files and convert to DataFrame. You can use pandas module in manual mode to handle DataFrame or use build-in functions.

To convert pcap file to Yandex-tank ammo format pcap2ammo tool was added. It should be available in your system bin directory right after the package installation. HTTP request from pcap file is extracted completely with line breackers headers and body.

So you can:

  • calc quantiles

  • get information about timings, latency, status codes

  • extract requests by timestamp, tag and other columns

  • group and analyze specific data like total/partial RPS, average request/response size

  • calc statistical metrics

  • convert pcap file to ammo

  • filter out and modify requests

Installation

pip install tanktools

Import

from tanktools import phout

Examples

Select DataFrame by timestamp

It is possible to parse a part of staistics by time and overal count

flags = {
    'from_date': '2018-01-18 20:09:50.123',
    'to_date'  : '2018-01-18 20:10:00.456',
    'limit': 100
}
data = phout.parse_phout(args.input, flags)
print("Total count: %d" % phout.size(data))
Total count: 100

Get RPS

data = phout.parse_phout('phout.log')
rps = phout.get_rps(data)

Select 200 OK responses and print latency median

data = phout.parse_phout('phout.log')
selected_http_responses = data[data.proto_code == 200]
print("Latency median for 200 OK: %d" %
      selected_http_responses.latency.median())
Latency median for 200 OK: 3539

pcap2ammo

Convert pcap file to Yandex-tank ammo

pcap2ammo -i file.pcap
73
GET https://rambler.ru/ HTTP/1.1\r\n
Host: rambler.ru\r\n
Content-Length: 0\r\n\r\n

Count statistics about HTTP requests

pcap2ammo -f "ip.src == 10.10.10.10" -i file.pcap -S

Stats:
    total: 1
    complete: 1
    incorrect: 0
    incomplete: 0

Add or delete headers

Applyed for all requests, containing specified headers

pcap2ammo -i file.pcap --add-header 'Referer: http://domain.com' --add-header 'X-Ip: 1.1.1.1'
pcap2ammo -i file.pcap --delete-header 'Content-Length'
pcap2ammo -i file.pcap --delete-header 'Connection' --add-header 'Connection: keep-alive'

Filter TCP/IP packets

pcap2ammo -i file.pcap -f 'ip.src==10.10.10.10 and tcp.dport==8080'

Filter HTTP packets

pcap2ammo -i file.pcap -F '"rambler.ru" in http["uri"]'

You can use logical expressions in filters

pcap2ammo -i file.pcap -F '"keep-alive" in http["headers"]["connection"] or "Keep-alive" in http["headers"]["connection"]'

String functions over HTTP headers

pcap2ammo -i file.pcap -F '"keep-alive" in http["headers"]["connection"].lower()'

Use excluding filters also

pcap2ammo -i file.pcap -F '"rambler.ru" in http["uri"]' -E '"dsp-rambler.ru" in http["uri"]'

See more information about filters in pcaper package description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tanktools-1.0.4.tar.gz (7.8 kB view hashes)

Uploaded Source

Built Distribution

tanktools-1.0.4-py2.py3-none-any.whl (8.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page