Multi-Mechanize | Performance Test Framework


_images/multimech-450.png

_images/graphs.png
Web:multimechanize.com
PyPI:multi-mechanize package
Dev:GitHub
License:GNU LGPLv3
Author:Corey Goldberg - copyright © 2010-2012

Performance & Load Tests in Python

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.

Discussion / Help / Updates

Install / Setup

Multi-Mechanize can be installed from PyPI using pip:

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)

Usage Instructions

Create a Project

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.

Run a Project

Run a test project with multimech-run:

$ multimech-run my_project
  • for test configuration options, see Configuration
  • a timestamped results directory is created for each test run, containing the results report.

Test Scripts

Virtual User Scripting

  • written in Python
  • test scripts simulate virtual user activity against a site/service/api
  • scripts define user transactions
  • for help developing scripts, see Scripting Guide

Examples

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())

_images/python-powered.png