<commit_before>molotov
=======

Simple Python 3.5+ tool to write load tests.

Based on `asyncio <https://docs.python.org/3/library/asyncio.html>`_,
`aiohttp.client <http://aiohttp.readthedocs.io/en/stable/client.html>`_ and
`Urwid <http://urwid.org/>`_ for its curses console.



Installation
============

Make sure you are using Python 3.5+ with Pip installed, then:

.. code-block:: bash

   $ pip install molotov



Quickstart
==========

To create a load test, you need to create a Python module with some functions
decorated with the **scenario** decorator.

When executed, the function receives a **session** object inherited
from **aiohttp.ClientSession**.

Here's a full example :

.. literalinclude:: ../../molotov/tests/example.py

When a function is decorated with the :func:`setup` decorator, it will be
called with the command-line arguments and needs to send back a dict.
This dict will be passed to the :class:`ClientSession` class when it's
created. This is useful when you need to set up session-wide options
like Authorization headers, or do whatever you need on startup.

When molotov runs, it creates some workers (coroutines) that will
run scenarii indefinitely until the test is done. A test is done
when the time in seconds provided by **-d** is reached.

Each worker randomly picks one scenario to execute, given their weights.
Once it's finished, it picks the next one, and so on. In our example,
**scenario_two** is picked ~40% of the time.


.. note::

   Check out aiohttp's documentation to understand how to work with
   a session object.

   Link: https://aiohttp.readthedocs.io/en/stable/client.html


To run the load script, you can provide its module name or its path.
In the example below, the script is executed in quiet mode with
10 processes and 200 workers for 60 seconds. It stops on the first failure:


.. code-block:: bash

    $ molotov molotov/tests/example.py -p 10 -w 200 -d 60 -qx


Next steps
==========

Check out the detailed documentation:

.. toctree::
   :maxdepth: 2

   cli
   slave
   design
   tutorial
<commit_msg>yeah, aiostatsd is a pain to install - fixes #23<commit_after>molotov
=======

Simple Python 3.5+ tool to write load tests.

Based on `asyncio <https://docs.python.org/3/library/asyncio.html>`_,
`aiohttp.client <http://aiohttp.readthedocs.io/en/stable/client.html>`_ and
`Urwid <http://urwid.org/>`_ for its curses console.



Installation
============

Make sure you are using Python 3.5+ with Pip installed, then:

.. code-block:: bash

   $ pip install molotov


If you want to use statsd, you need to install `aiostatsd <https://github.com/scivey/aiostatsd>`_.

.. code-block:: bash

   $ pip install cython aiostatsd

If you have any trouble installing aiostatsd, try to install Tarek's cystatsd fork
first with MACOSX_DEPLOYMENT_TARGET header.

.. code-block:: bash

    $ MACOSX_DEPLOYMENT_TARGET=10.10 pip install cython git+https://github.com/tarekziade/cystatsd.git#egg=cystatsd

On linux, make usre you have g++ 4.8 and set up some compiler env:

.. code-block:: bash

    $ export CXXFLAGS="--std=c++0x"
    $ export CXX="g++-4.9"
    $ export CC="g++-4.9"
    $ pip install cython git+https://github.com/tarekziade/cystatsd.git#egg=cystatsd



Quickstart
==========

To create a load test, you need to create a Python module with some functions
decorated with the **scenario** decorator.

When executed, the function receives a **session** object inherited
from **aiohttp.ClientSession**.

Here's a full example :

.. literalinclude:: ../../molotov/tests/example.py

When a function is decorated with the :func:`setup` decorator, it will be
called with the command-line arguments and needs to send back a dict.
This dict will be passed to the :class:`ClientSession` class when it's
created. This is useful when you need to set up session-wide options
like Authorization headers, or do whatever you need on startup.

When molotov runs, it creates some workers (coroutines) that will
run scenarii indefinitely until the test is done. A test is done
when the time in seconds provided by **-d** is reached.

Each worker randomly picks one scenario to execute, given their weights.
Once it's finished, it picks the next one, and so on. In our example,
**scenario_two** is picked ~40% of the time.


.. note::

   Check out aiohttp's documentation to understand how to work with
   a session object.

   Link: https://aiohttp.readthedocs.io/en/stable/client.html


To run the load script, you can provide its module name or its path.
In the example below, the script is executed in quiet mode with
10 processes and 200 workers for 60 seconds. It stops on the first failure:


.. code-block:: bash

    $ molotov molotov/tests/example.py -p 10 -w 200 -d 60 -qx


Next steps
==========

Check out the detailed documentation:

.. toctree::
   :maxdepth: 2

   cli
   slave
   design
   tutorial

{'fraction_non_alphanumeric': 0.10260619741432382, 'fraction_numerical': 0.011697106505232917, 'mean_word_length': 3.773751224289912, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2932526', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1445, 'n_words': 634}