|Author:||Corey Goldberg - copyright © 2010-2012|
Multi-Mechanize is an open source framework for performance and load testing. It runs concurrent Python scripts to generate load (synthetic transactions) against a remote site or service.
Multi-Mechanize is most commonly used for web performance and scalability testing, but can be used to generate workload against any remote API accessible from Python.
Test output reports are saved as HTML or JMeter-compatible XML.
pip install -U multi-mechanize
... or download the source distribution from PyPI, unarchive, and run:
python setup.py install
(for more setup and installation instructions, see Detailed Install and Setup)
Create a new test project with multimech-newproject:
$ multimech-newproject my_project
Each test project contains the following:
- config.cfg: configuration file. set your test options here.
- test_scripts/: directory for virtual user scripts. add your test scripts here.
- results/: directory for results storage. a timestamped directory is created for each test run, containing the results report.
multimech-newproject will create a mock project, using a single script that generates random timer data. Check it out for a basic example.
HTTP GETs using Requests:
import requests class Transaction(object): def run(self): r = requests.get('https://github.com/timeline.json') r.raw.read()
HTTP GETs using Mechanize (with timer and assertions):
import mechanize import time class Transaction(object): def run(self): br = mechanize.Browser() br.set_handle_robots(False) start_timer = time.time() resp = br.open('http://www.example.com/') resp.read() latency = time.time() - start_timer self.custom_timers['Example_Homepage'] = latency assert (resp.code == 200) assert ('Example Web Page' in resp.get_data())