waeup.stresstest
****************

This package provides stresstests for *existing* WAeUP SIRP sites.

It deploys the Python multi-mechanize programme/library to fire tons
of requests against a running site. So, you don't want to use it with
sites that are under load already. The requests try to simulate users
using the portal simultanously.

multi-mechanize registers the numbers and latencies of single requests
and generates graphics/tables with the results. This way you can see
what actions/requests need how much time. You can also see how the
server reacts when many concurrent users use the portal.

`waeup.stresstest` is code-wise independent from `waeup.sirp`. You can
run it on any machine that can do HTTP requests to the target machine
(which means the machine that should be stress-tested).

Installation is a bit difficult (numpy and matplotlib, two complex
Python libs for statistical computations) are required and not easily
installable in the usual buildout-way (well, numpy is but matplotlib
is a constant source of trouble in that respect). Please refer to the
``Installation`` section below.

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

The following steps are tested on Ubuntu Linux only.

Requirements
------------

* Python 2.6 or Python 2.7.

On the shell (after, optionally, enabling a virtual environment) run::

  $ python bootstrap/bootstrap.py
  $ ./bin/buildout

Usage (outdated)
================

Quick guide:

1) Make sure configuration is up-to-date in
   `multi-mechanize/projects/sirp1/config.cfg`. This 'project' will
   run against a SIRP portal installed locally as ``app-stress``

2) Create a local waeup.sirp portal running on localhost:8080 and
   named ``app-stress``

3) Start the portal.

4) On the shell, run::

     $ cd multi-mechanize
     $ python multi-mechanize sirp1

The latter tells multi mechanize to run the stress tests in the
``projects/sirp1`` directory. Make sure that the Python interpreter
you use here is the one that has support for matplotlib and numpy.

Results will be as HTML page in ``projects/sirp1/results/``.


Tweaking and Playing Around
===========================

The current stress tests only include simulation of a bunch of users
simultaneously trying to access the portal home page and the portal
applicants page (as anonymous users).

You can tweak and change ``projects/sirp1/test_scripts/`` to do
different things. See http://code.google.com/p/multi-mechanize/ for
first steps/hints.


ToDo
====

multi-mechanize currently makes no use of Python packaging,
entry-points and the like. Improving it in this way and making it a
first-class-citizen of the Python 'packaging' community would be a
first step to make it more useful for others.

Notes
=====

Installing matplotlib with buildout
-----------------------------------

To install `waeup.stresstest` you need matplotlib which in turn
depends on `numpy`. While `numpy` can be installed during
buildout-runs, `matplotlib` is a bit difficult. It does a manual check
for already installed packages and does not detect already fetched
numpy installs. As a result matplotlib cannot be installed easily with
buildout, although there are a few workarounds:

http://comments.gmane.org/gmane.comp.python.distutils.devel/13590

Installing on an old Ubuntu with virtualenv
-------------------------------------------

Just for the logs, this is what I did to make it work::

  $ virtualenv --no-site-packages -p <PATH-TO-PYTHON-2.6> sandbox26
  $ source sandbox26/bin/activate
  $ pip install mechanize
  $ pip install numpy
  $ pip install matplotlib

Then (on a different shell):

  - Started waeup.sirp::

    $ ./bin/sirpctl fg


  - Added a University instance named 'app-stress'

Back on the first shell::

  $ python multi-mechanize.py sirp1

