The Grinder is an open source load testing tool. The Grinder uses Jython scripts and the scripts are executed using agents which can be distributed over the network. Property file is used to define tests and load.
The Grinder framework comprises three types of process or programs;
- Worker Process: Interpret Jython test scripts and perform tests using a number of worker threads
- Agent Process: Manage worker processes
- The Console:
- Coordinate the other processes
- Collate and display statistics
- Script editing and distribution
We will create a couple of batch files to conveniently start up the agents and console.
- Extract the zip file and copy at any location. E.g. C:\grinder
- First batch file “setgrinderenv.bat” will have following commands.
- Second batch file “startconsole.bat”
java -cp %CLASSPATH% net.grinder.Console
- Third batch file “startagent.bat”
java -cp %CLASSPATH% net.grinder.Grinder %GRINDERPROPERTIES%
How to update Property file?
The load test is defined using the property file. The configuration entry grinder.script = http.py indicates the path of the Jython script which will be run. Other interesting configurations include the number of processes created by each agent (grinder.processes) and the number of threads for each process (grinder.threads).
I would also recommend to explicitly specify the log and the temporary directories:
# The directory in which worker process logs should be created.
grinder.logDirectory = log
# Additional arguments to worker process JVMs.
grinder.jvm.arguments = -Dpython.cachedir=”C:\\ grinder\\tmp”
The load test can be written manually or can be generated through the TCP proxy provided with The Grinder.
Starting the TCP proxy to generate the load case could be done through yet another batch file:
java -cp %CLASSPATH% net.grinder.TCPProxy -console -http > proxy-output.py
When TCP Proxy is started, display the following information:
Initializing as an HTTP/HTTPS proxy with the parameters:
Request filters: EchoFilter
Response filters: EchoFilter
Local address: localhost:8001
Engine initialised, listening on port 8001
This indicates that the TCPProxy is listening as an HTTP proxy on port 8001 (the default, but you can change it with -localPort).
Preparing the Browser
In the browser options dialog, set the proxy host to be the host on which the TCPProxy is running and proxy port to be 8001). Run through your test scenario on your website. Having finished your run through, press “Stop” on the TCPProxy console and the generated script will be written togrinder.py.
The grinder.py file contains headers, requests and a logical grouping of requests into pages, of the recorded tests.
Once you’ve recorded your script you have two methods that you can use to replay your script:
- You can create a simple grinder.properties file and you can replay the recorded scenario with The Grinder. Your properties file should at least set grinder.script to grinder.py.
- Alternately you can use the console to distribute your script to an agent and set it as the script to run. Each agent will still need a simple grinder.properties file containing the console address, though you will not need to set the grinder.script property.
Will be continued….