|
Project Information
Members
Featured
Downloads
Wiki pages
Links
|
Multi-Mechanize - web performance and load testing framework
What is Multi-Mechanize? (the framework)Multi-Mechanize is an open source framework for API performance and load testing. It allows you to run simultaneous python scripts to generate load (synthetic transactions) against a web site or API/service. In your scripts, you have the convenience of mechanize along with the power of the full Python programming language at your disposal. You programmatically create test scripts to simulate virtual user activity. Your scripts will then generate HTTP requests to intelligently navigate a web site or send requests to a web service. Multi-Mechanize uses a multi-process, multi-threaded engine to replay your scripts and generate concurrent virtual users. Results are saved in CSV format along with an HTML report containing stats and graphs. Optionally, results can be saved as XML (J-Meter compatible .JTL format) Optionally, results can be stored in a database: You should be proficient with Python, HTTP, and performance/load testing to use multi-mechanize successfully. What is python-mechanize? (scripting language: python + mechanize)Mechanize is a Python module for stateful programmatic web browsing, used for automating interaction with websites. It is similar to WWW::Mechanize for Perl. Test scripts are written in python using mechanize*. Features include:
* scripts can also be written using any of Python's web/network modules (httplib, urllib, socket) or any third-party modules Quick Instructionsfrom the command line: $ python multi-mechanize.py default_project (this will run the mock project, which just generates random data) Detailed InstructionsTo begin, you can use the "default_project" supplied with the release. If you need to manage multiple projects, just create a directory for each one and copy the contents/structure of the default project. You will specify the project you are running on the command line when you invoke a test run. Each project contains the following:
Steps:
Once your project is configured, you can run your test from the command line like this: $ python multi-mechanize.py default_project Multi-Mechanize config.cfg fileHere is a sample config file: [global] run_time: 300 rampup: 300 console_logging: on results_ts_interval: 30 [user_group-1] threads: 10 script: search_simple.py [user_group-2] threads: 5 script: search_complex.py Developing Virtual User Scriptsscript development guide: DevelopingScripts Sample Scripts (Virtual User Transactions)simple web requestimport mechanize
class Transaction:
def run(self):
br = mechanize.Browser()
br.set_handle_robots(False)
resp = br.open('http://www.example.com/')
resp.read()web request with timer and assertionsimport mechanize
import time
class Transaction:
def run(self):
self.custom_timers = {}
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), 'Bad HTTP Response'
assert ('Example Web Page' in resp.get_data()), 'Failed Content Verification'Help / DiscussionFrequently Asked Questions: FAQ
Corey Goldberg © 2010-2011 |