Skip to content

Commit

Permalink
Merge pull request #149 from netortik/master
Browse files Browse the repository at this point in the history
sample ammo generator script (python), updated copyright year
  • Loading branch information
direvius committed Apr 15, 2015
2 parents 00f667b + 96546c9 commit d7ecbc3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# General information about the project.
project = u'Yandex.Tank'
copyright = u'2012, Yandex'
copyright = u'2015, Yandex'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -248,7 +248,7 @@
epub_title = u'Yandex.Tank'
epub_author = u'Yandex'
epub_publisher = u'Yandex'
epub_copyright = u'2012, Yandex'
epub_copyright = u'2015, Yandex'

# The language of the text. It defaults to the language option
# or en if the language is not set.
Expand Down
65 changes: 64 additions & 1 deletion docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,70 @@ include them in a file after each request. '\r' is also required.
<wsw-fields><wsw-field name="moderate-code"><wsw-value>disable</wsw-value></wsw-field></wsw-fields>
--AGHTUNG--

**sample req-style ammo generator (python):**

``usage: cat data | python make_ammo.py``
For each line of 'data' file this script will generate phantom ammo.
Line format: ``GET||/url||case_tag||body(optional)``

.. code-block:: python
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
def make_ammo(method, url, headers, case, body):
""" makes phantom ammo """
#http request w/o entity body template
req_template = (
"%s %s HTTP/1.1\r\n"
"%s\r\n"
"\r\n"
)
#http request with entity body template
req_template_w_entity_body = (
"%s %s HTTP/1.1\r\n"
"%s\r\n"
"Content-Length: %d\r\n"
"\r\n"
"%s\r\n"
)
if not body:
req = req_template % (method, url, headers)
else:
req = req_template_w_entity_body % (method, url, headers, len(body), body)
#phantom ammo template
ammo_template = (
"%d %s\n"
"%s"
)
return ammo_template % (len(req), case, req)
def main():
for stdin_line in sys.stdin:
try:
method, url, case, body = stdin_line.split("||")
body = body.strip()
except:
method, url, case = stdin_line.split("||")
body = None
method, url, case = method.strip(), url.strip(), case.strip()
headers = "Host: hostname.com\r\n" + \
"User-Agent: tank\r\n" + \
"Accept: */*\r\n" + \
"Connection: Close"
sys.stdout.write(make_ammo(method, url, headers, case, body))
if __name__ == "__main__":
main()
Run Test!
~~~~~~~~~
Expand Down Expand Up @@ -517,4 +581,3 @@ that. Load.ini:
rps_schedule=const(10, 10m) ;load scheme
instances=10
gatling_ip = IP1 IP2

0 comments on commit d7ecbc3

Please sign in to comment.