Personal tools

Nov 13, 2009

How to write funkload test in few minutes

After PloneConf2009 I noticed interesting changes in collective.recipe.funkload. Right now writing a simple test for funkload is just few steps.

After Plone Conference 2009 I noticed interesting changes in collective.recipe.funkload and in collective.funkload itself. Right now writing a simple stress test for funkload is much easier - you can do it in few steps.

Let's start with creating a simple package called mytest:

$ ls ./mytest buildout.cfg src

$ ls ./mytest/src/mytest tests

$ ls ./mytest/src/mytest/tests Simple.conf


buildout.cfg is also simple:

develop = .
parts = funkload    

recipe = collective.recipe.funkload
url =
eggs = mytest

where is the url to the site you want to test (it doesn't need to be on you localhost)

Now the funkload test configuration file (Simple.conf):

label=Simple test for
description=Simple test scenario

description=Simple test scenario

log_to = console file
log_path = Simple-test.log
result_path = Simple-test.xml

cycles =  5:15:30
duration = 100
startup_delay = 2
sleep_time = 2
cycle_time = 2
log_to = file
log_path = Simple-bench.log
result_path = Simple-bench.xml
sleep_time_min = 2
sleep_time_max = 2

In this example most important bench configurations:

  • cycles = 5:15:30  - contains 3 cycles: for 5, 15 and 30 concurrent users
  • duration = 100 - duration of one cycle in seconds
  • startup_delay = 2 - time to wait between starting-up threads in seconds
  • sleep_time = 2 - time to wait between test in seconds
  • cycle_time = 2 - time to wait between cycle in seconds

And the funkload test scenario (

import unittest
from collective.funkload import testcase

class Simple(testcase.FLTestCase):
    """Simple load test scenario."""

    def setUp(self):
        """Setting up test."""
        self.label = 'Simple test'
        self.server_url = self.conf_get('main', 'url')

    def test_ReadOnly(self):

        self.get(self.server_url + "/",
             description="Get /")

        self.get(self.server_url + "/login_form",
             description="Get /login_form") + "/login_form", params=[
            ['came_from', self.server_url],
            ['form.submitted', '1'],
            ['js_enabled', '0'],
            ['cookies_enabled', ''],
            ['login_name', ''],
            ['pwd_empty', '0'],
            ['__ac_name', 'admin'],
            ['__ac_password', 'admin'],
            ['submit', 'Login']],
            description="Post for login a user /login_form")

        self.get(self.server_url + "/folder/document1",
            description="Get /folder/document1")

        self.get(self.server_url + "/logout",
            description="Get /logout")

    def tearDown(self):
        """Setting up test."""

def test_suite():
    return unittest.makeSuite(Simple)

additional_tests = test_suite

if __name__ == '__main__':


It's a very simple scenario in which we are:

  • opening plone site (get /)
  • opening login_form (get /login_form)
  • sending a post with login credentials (post /login_form)
  • opening a document (get /folder/document1)
  • logout (get /logout).

Now you need to bootstrap the buildout:

$ cd mytest
$ python

lunch the buildout:

$ ./bin/buildout

and lunch the bench:

$ ./bin/funkload bench -t mytest.tests.test_Simple

final report you can find in your buildout directory:

$ ls ./var/funkload/reports/2009-11-11-19-40-20

$ ls ./var/funkload/reports/2009-11-11-19-40-20/test_Simple-20091111T194020
funkload.css  index.html  index.rst  tests.gplot  tests.png

For more information please check:

Filed under: , , ,
comments powered by Disqus