6 Aug 2009, 16:53
Tags: , , , , ,
Comments Off

[FunkLoad] Random tests for benchmarking

I’ve recently started using FunkLoad to do benchmarking of websites. It works quite okay and I love the fact that it’s Python, since that’s my language of choice.

One thing that kept bugging me was that since FunkLoad is more a unittester, it can by default only run a single run multiple times against a site. That won’t do. You want several different kinds of users visiting your website when you’re benchmarking. But since everything is Python, I was able to solve that like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: iso-8859-15 -*-
"""loadtest FunkLoad test
 
$Id: $
"""
import unittest, random, sys
from funkload.FunkLoadTestCase import FunkLoadTestCase
from webunit.utility import Upload
from funkload.utils import Data
#from funkload.utils import xmlrpc_get_credential
 
class LoadTest(FunkLoadTestCase):
    """ Loadtest for website.
 
    This test use a configuration file LoadTest.conf.
    """
 
    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        self.server_url = self.conf_get('main', 'url')
 
    def doTest(self):
        # Picks a test at random
        tests = ["8081","8082","8083","8084","8085","8086"]
        rnd = random.choice(tests)
        return getattr(self, "test_"+str(rnd))()
 
    def test_8081(self):
        # The description should be set in the configuration file
        server_url = self.server_url
        # begin of test ---------------------------------------------
        # end of test---------------------------------------------
 
    def test_8082(self):
        # The description should be set in the configuration file
        server_url = self.server_url
        # begin of test ---------------------------------------------
        # end of test---------------------------------------------

(I left out the test themselves, but I’m sure you can find where to place them.)

The recorded tests are in the same class, and they’re called test_8081, test_8082, etc. up to test_8086. These corresponded to the proxy ports on which fl-record was listening when the session was recorded. Line 27 makes sure that the test that was chosen gets run.

You can of course expand this as much as you like, for example adding weights for certain tests. Kinda neat, python.

Tags: , , , , ,

 
 
  • Search


  • Twitter

    • @ArjenNL Awstats is not real-time :S Need it for monitoring, not trending. Kinda strange there are no solutions, really. in reply to ArjenNL 1 day ago
    • @ArjenNL Thx, but that's a mod_watch solution :) I don't want to use mod_watch, since it seems unmaintained :) in reply to ArjenNL 1 day ago
    • Anyone know of a maintained mod_watch-alike solution for Apache2? Preferably one that's packaged for Debian... 1 day ago
    • Seems that no month can pass without us calling our telephony provider about a screw up on their invoice to us... 1 day ago
    • @KroosSara Ik vond Inception erg stoer, ondanks Leonardo. Beetje Matrix-achtige sfeer, maar heel ander verhaal (uiteraard). 2 days ago
    • More updates...

    Powered by Twitter Tools

  • Calender

    July 2010
    M T W T F S S
    « Jun    
     1234
    567891011
    12131415161718
    19202122232425
    262728293031  
  • Archives