Overview

Snowfall

Snowfall is a restful api load testing tool for python.

Installation

$ pip install snowfall

Defining flakes

It works a little something like this:

from snowfall import flake, snow

@flake('/project', method='GET', params={'name':'project1'})
def index(req, resp):
    """ Query project
    """
    return resp.code == 200

import json

@flake('/project', method='POST', data={'name':'project2'})
def project_post(req, resp):
    """ Verify POST (new)
    """
    project2 = json.loads(resp.body)

    @flake('/project', method='PUT', data={'name','project2_updated'})
    def project_list(req, resp):
        """ Verify PUT (update)
        """
        project2_updated = json.loads(resp.body)

        @flake('/project/%s' % project2['uuid'], itr=5, random=3)
        def queryproject(req, resp):
            """ Query project2 by url
            """
            return resp.code == 200

        return project2_update['name'] == 'project2_updated'

    return project2['name'] == 'project2'

def show_response(result):
    print result

snow('http://sub.host.com', show_response)

The function is responsible to validating the test. So if you return True, the test registers as passed. And vice versa. You can also pass http headers, query params and form data. You can even nest tests. Start sprinkling flakes by calling snow, with a callback to handle/print/dump result.

Flake paramters

  • headers - http header parameters (dict)
  • params - http get parameters (dict)
  • data - form data (dict)
  • method - http method
  • random - random time delay 0 to x seconds
  • itr - number of iterations/calls
  • pre - run function before in addition to after calling url

pre

In first call to function resp object will be None. Handy for signing requests etc.

Snow paramters

  1. host - host to dump flakes on
  2. callback - callback to inspect result

Changelog

0.3.0

  • Moved all flake parameters to req.flake attribute
  • More generic parent determination
  • Callback with result leaving inspection to user

0.2.1dev

  • Added POST support

0.2.0dev

  • Moved host to first snow parameter
  • Rewrote and restructured for release

enjoy.