Pyak47 | Performance Test Framework¶
Dev: | Pyak47 source |
---|---|
PyPI: | Pyak47 package |
License: | GNU LGPLv3 |
Author: | Pierre-Francois Carpentier - copyright © 2014 |
Original author: | |
---|---|
Corey Goldberg - copyright © 2010-2013 | |
Original project: | |
multimechanize.com |
Performance & Load Tests in Python¶
Pyak47 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.
Pyak47 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.
Install / Setup¶
Pyak47 can be installed from PyPI using pip:
pip install -U pyak47
... 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 pyak47-newproject
:
$ pyak47-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.
pyak47-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 pyak47-run
:
$ pyak47-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())