Skip to main content

My first grinder runs

I downloaded grinder 3.4, and unpacked. I installed java jdk 1.6.0.20 on my machine. Inside the root directory of my installation I added following scripts: setGrinderEnv.cmd
set GRINDERPATH=C:\development\grinder-3.4
set GRINDERPROPERTIES=C:\development\grinder-3.4\grinder.properties
set CLASSPATH=%GRINDERPATH%\lib\grinder.jar;%CLASSPATH%
set JAVA_HOME=C:\Programme\Java\jdk1.6.0_20
PATH=%JAVA_HOME%\bin;%PATH%
startProxy.cmd
set GRINDERPATH=C:\development\grinder-3.4
call %GRINDERPATH%\setGrinderEnv.cmd
echo %CLASSPATH%
java -Duser.language="en" -cp %CLASSPATH% net.grinder.TCPProxy -console -http > ipp.py
startConsole.cmd
set GRINDERPATH=C:\development\grinder-3.4
call %GRINDERPATH%\setGrinderEnv.cmd
echo %CLASSPATH%
java -Duser.language="en" -cp %CLASSPATH% net.grinder.Console
startAgent.cmd
set GRINDERPATH=C:\development\grinder-3.4
call %GRINDERPATH%\setGrinderEnv.cmd
echo %CLASSPATH%
java -Duser.language="en" -cp %CLASSPATH% net.grinder.Grinder %GRINDERPROPERTIES%
I also dropped a file grinder.properties in root directory of grinder-3.4:
grinder.script=HelloGrinder2.py
grinder.processes = 1
grinder.threads = 3
grinder.runs = 2
grinder.useConsole = false
grinder.dcrinstrumentation = true
grinder.logDirectory = logs
grinder.numberOfOldLogs = 0
grinder.initialSleepTime=50
With this grinder.properties, an agent will execute the HelloGrinder2.py script:
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder

test1 = Test(1, "Log method")

# Wrap the output() method with our Test and call the result logWrapper.
logWrapper = test1.wrap(grinder.getLogger().output)

class TestRunner:
    def __call__(self):
        logWrapper("Hello World2")
I can execute the script by calling startAgent.cmd. After execution I get a subdirectory called log, with data and output files in it. The output file shows:
04.06.10 10:47:40 (process emeafralp560-0): starting threads
04.06.10 10:47:40 (thread 2): starting, will do 2 runs
04.06.10 10:47:40 (thread 1): starting, will do 2 runs
04.06.10 10:47:40 (thread 0): starting, will do 2 runs
04.06.10 10:47:40 (process emeafralp560-0): start time is 1275641260135 ms since Epoch
04.06.10 10:47:40 (thread 0): sleeping for 10 ms
04.06.10 10:47:40 (thread 1): sleeping for 1 ms
04.06.10 10:47:40 (thread 2): sleeping for 4 ms
04.06.10 10:47:40 (thread 2 run 0 test 1): Hello World2
04.06.10 10:47:40 (thread 1 run 0 test 1): Hello World2
04.06.10 10:47:40 (thread 0 run 0 test 1): Hello World2
04.06.10 10:47:40 (thread 1 run 1 test 1): Hello World2
04.06.10 10:47:40 (thread 1 test 1): finished 2 runs
04.06.10 10:47:40 (thread 0 run 1 test 1): Hello World2
04.06.10 10:47:40 (thread 0 test 1): finished 2 runs
04.06.10 10:47:40 (thread 2 run 1 test 1): Hello World2
04.06.10 10:47:40 (thread 2 test 1): finished 2 runs
04.06.10 10:47:40 (process emeafralp560-0): elapsed time is 22 ms
As my grinder properties file tells to use 3 threads, and 2 runs for each thread, the Hello World2 got written 6 times. My data output shows the test times that the Test Proxy of the script recorded:
Thread, Run, Test, Start time (ms since Epoch), Test time, Errors
0, 0, 1, 1275641260152, 0, 0
1, 0, 1, 1275641260152, 0, 0
2, 0, 1, 1275641260152, 1, 0
1, 1, 1, 1275641260153, 0, 0
0, 1, 1, 1275641260154, 0, 0
2, 1, 1, 1275641260154, 0, 0
This output is a bit boring, as I did not make any http request. With the next file HelloGrinder3.py I do:
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from net.grinder.plugin.http import HTTPRequest

test1 = Test(1, "Request resource")
request1 = test1.wrap(HTTPRequest())

class TestRunner:
    def __call__(self):
        result = request1.GET("http://emeafraippqa08:80/")
I need to adapt grinder.properties to use this as grinder.script, and then can run startAgent.cmd again. Now my data output looks like:
Thread, Run, Test, Start time (ms since Epoch), Test time, Errors, HTTP response code, HTTP response length, HTTP response errors, Time to resolve host, Time to establish connection, Time to first byte
1, 0, 1, 1275650338473, 60, 0, 200, 327, 0, 23, 33, 50
1, 1, 1, 1275650338535, 2, 0, 200, 327, 0, 0, 0, 1
2, 0, 1, 1275650338473, 3105, 0, 200, 327, 0, 22, 3085, 3094
0, 0, 1, 1275650338481, 3097, 0, 200, 327, 0, 23, 3085, 3094
2, 1, 1, 1275650341579, 5, 0, 200, 327, 0, 0, 1, 3
0, 1, 1, 1275650341579, 7, 0, 200, 327, 0, 0, 1, 2

Comments

Popular posts from this blog

SSL handshake failed: Secure connection truncated

Got this problem on Ubuntu 9.10 and 10.10. svn co --username=xx https:/yy zz “SSL handshake failed: Secure connection truncated” According to this link bug-ubuntu The solution is: sudo apt-get install libneon27 cd /usr/lib/ sudo rm libneon-gnutls.so.27 sudo ln -s /usr/lib/libneon.so.27 libneon-gnutls.so.27

Junit4 running parallel junit classes

To run junit testcases parallel, you can create your own class to run junit with: Add this tag to your class declaration. @RunWith(Parallelized.class) Implementation of this class looks like: package mypackage; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.junit.runners.Parameterized; import org.junit.runners.model.RunnerScheduler; public class Parallelized extends Parameterized {         private static class ThreadPoolScheduler implements RunnerScheduler     {         private ExecutorService executor;                 public ThreadPoolScheduler()         {             String threads = System.getProperty("junit.parallel.threads", "16");    ...

Create a groovy console and bind to selenium

Required groovy files In the previous posting we defined the pom file that we need for our build environment. Now we will setup some groovy files to get selenium and groovy running interactively. ConsoleWaiter.groovy The idea of Groovy Console I found on some other sides. Honour goes for instance too: http://josefbetancourt.wordpress.com/tag/eclipse-2/ I copied some code of this, and put it under src/test/groovy/com/jankester/selenium/test/utils: package com.jankester.selenium.test.utils /** * File: ConsoleWaiter.groovy */ import groovy.lang.Binding; import groovy.ui.Console; /** * Provides a wrapper for the console. * * Based on source by John Green * Adapted from: http://www.oehive.org/files/ConsoleWaiter.groovy * Released under the Eclipse Public License * http://www.eclipse.org/legal/epl-v10.html * * I added methods to allow use from Java. * * The run() method launches the console and causes this thread * to sleep until the console's window is closed....