Writing Performance Tests in Grinder using a Framework

by vivin

Package Structure

For the framework, I created a package structure (you can see it in the way I import the task files). Within my performance-testing directory where I have Grinder installed, I created a scripts directory, inside which I place the package:

scripts/
|-- grinder-frameworked.py
|-- grinder.properties
|-- grinder.py
`-- torqueo
    |-- __init__.py
    `-- test
        |-- __init__.py
        |-- framework
        |   |-- Scenario.py
        |   |-- Task.py
        |   `-- __init__.py
        `-- tasks
            |-- Affiliate
            |   |-- AddAffiliateTask.py
            |   `-- __init__.py
            |-- Appointment
            |   |-- AddAppointmentTask.py
            |   `-- __init__.py
            |-- Contact
            |   |-- AddContactTask.py
            |   `-- __init__.py
            |-- Opportunity
            |   |-- AddOpportunityTask.py
            |   `-- __init__.py
            |-- Reports
            |   |-- SearchAffiliateTask.py
            |   |-- SearchContactTask.py
            |   |-- SearchOpportunityTask.py
            |   `-- __init__.py
            |-- Task
            |   |-- AddTaskTask.py
            |   `-- __init__.py
            |-- __init__.py
            `-- login
                |-- LoginTask.py
                |-- LogoutTask.py
                `-- __init__.py

Of course, you can create it in any manner you see fit; this is just the way I did it.

Well, that’s the end of this tutorial! Hope it was informative and helpful! Please comment and let me know where I can improve. This was my first time doing a lot things; it was my first time writing a framework, my first time doing performance testing, and my first time doing anything serious (and by serious I mean more serious than “Hello World!”) in Python/Jython.

Download

If you want to check out the framework, here are the archives. They contain the Task and Scenario classes, and the Perl conversion script: