You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Paul Robinson <pa...@arjuna.com> on 2009/03/23 15:59:10 UTC

Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Hello,

I have written a Custom Sampler by extending "AbstractJavaSamplerClient". My
sampler is very simple, it just logs the method being invoked.

If i run the sampler for 2 threads with "loop count" of 1, I see the
following output:

INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest

Here you will observe that the "runTest" method of the first thread is
invoked before the "setupTest" of the 2nd thread. For my test I need to
ensure that all threads have their setupTest method invoked before any of
them have their "runTest" method ivoked.

Does anyone know how I can do this?

Thanks,

Paul.

Re: Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Posted by Paul Robinson <pa...@arjuna.com>.
Excellent,

The thing I was missing was the fact that you can put variables in the UDV.
Apart from adding complexity to my Sampler, I think this is a good solution.

I'll do this,

Thanks a lot for your help,

Paul.

2009/3/23 Ian Blavins <ib...@temenos.com>

> G'day
>
> I had the same problem.
>
> I define a user defined variable to hold the thread count. I populate the
> Number of Threads field on the thread group from the UDV (the field accepts
> an expression). Then you have the thread count in a variable which you can
> give to the sampler in the normal way without having two places to update
> the thread count.
>
>
>
> Ian Blavins
> Software performance specialist
> .
> TEMENOS
> The Banking Software Company
> .
> PeopleBuilding 2, Maylands Av
> Hemel Hempstead   UK   HP2 4NW
> .
> T:  +44 (0) 1442 431 106
> E:  iblavins@temenos.com
> .
> www.temenos.com
> .
>
>
> -----Original Message-----
> From: paul.robinson.arjuna@googlemail.com [mailto:
> paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
> Sent: Monday, 23 March 2009 4:19 PM
> To: JMeter Users List
> Subject: Re: Custom Sampler: Force all setupTest methods to be invoked
> before runTest methods
>
> Ian,
>
> I see what you mean now. We have considered this approach already and we
> plan to use it as a fall back. The problem with the approach is as you
> suggest, you need to tell the sampler how many client threads to expect.
> I've inspected the JavaSamplerContext and can't find a thread count.
>
> Thanks,
>
> Paul.
>
> 2009/3/23 Ian Blavins <ib...@temenos.com>
>
> > G'day
> >
> > I wasn't suggesting static for the connection - just to control
> > initialization.  Don't let any thread exit from initialization until all
> > have completed initialization. You will need a static variable to keep
> count
> > of threads that have initialized and a static synchronized method to
> update
> > it in a thread safe manner. You will also need to tell the sampler the
> > number of threads in the run. You may be able to get this from the
> > environment with a method call or you may have to pass it in.
> >
> > There are probably other ways to do this if getting the number of threads
> > in the run proves awkward.
> >
> >
> >
> > Ian Blavins
> > Software performance specialist
> > .
> > TEMENOS
> > The Banking Software Company
> > .
> > PeopleBuilding 2, Maylands Av
> > Hemel Hempstead   UK   HP2 4NW
> > .
> > T:  +44 (0) 1442 431 106
> > E:  iblavins@temenos.com
> > .
> > www.temenos.com
> > .
> >
> >
> > -----Original Message-----
> > From: paul.robinson.arjuna@googlemail.com [mailto:
> > paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
> > Sent: Monday, 23 March 2009 4:09 PM
> > To: JMeter Users List
> > Subject: Re: Custom Sampler: Force all setupTest methods to be invoked
> > before runTest methods
> >
> > Hi,
> >
> > Thanks for the quick reply. Static variables would be a good idea,
> however,
> > I require that each thread has it's own connection, in order to simulate
> > multiple separate users. Sharing a connection through a static variable
> > would break my test unfortunately.
> >
> > For some reason, the system I am testing requires that all connections
> are
> > established before any of them are used. Therefore I really need to
> ensure
> > all the setupTest methods are invoked before any of the runTest methods
> are
> > invoked.
> >
> > Thanks for the help,
> >
> > Paul.
> >
> >
> > 2009/3/23 Ian Blavins <ib...@temenos.com>
> >
> > > G'day
> > >
> > > Because they all run under one JVM all instances of the sampler within
> a
> > > JMeter server can share memory through static variables.
> > >
> > > If you are familiar with static variables that should be enough to get
> > you
> > > going.
> > >
> > >
> > > Ian Blavins
> > > Software performance specialist
> > > .
> > > TEMENOS
> > > The Banking Software Company
> > > .
> > > PeopleBuilding 2, Maylands Av
> > > Hemel Hempstead   UK   HP2 4NW
> > > .
> > > T:  +44 (0) 1442 431 106
> > > E:  iblavins@temenos.com
> > > .
> > > www.temenos.com
> > > .
> > >
> > > -----Original Message-----
> > > From: paul.robinson.arjuna@googlemail.com [mailto:
> > > paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
> > > Sent: Monday, 23 March 2009 2:59 PM
> > > To: jmeter-user@jakarta.apache.org
> > > Subject: Custom Sampler: Force all setupTest methods to be invoked
> before
> > > runTest methods
> > >
> > > Hello,
> > >
> > > I have written a Custom Sampler by extending
> "AbstractJavaSamplerClient".
> > > My
> > > sampler is very simple, it just logs the method being invoked.
> > >
> > > If i run the sampler for 2 threads with "loop count" of 1, I see the
> > > following output:
> > >
> > > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> > > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> > > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> > > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> > > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> > > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> > > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
> > > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
> > >
> > > Here you will observe that the "runTest" method of the first thread is
> > > invoked before the "setupTest" of the 2nd thread. For my test I need to
> > > ensure that all threads have their setupTest method invoked before any
> of
> > > them have their "runTest" method ivoked.
> > >
> > > Does anyone know how I can do this?
> > >
> > > Thanks,
> > >
> > > Paul.
> > > Disclaimer:
> > > If you have received this e-mail in error please notify the sender.
> > > Please note that any views or opinions presented in this e-mail are
> > solely
> > > those of the author and do not necessarily represent those of TEMENOS.
> > > We recommend that you check this e-mail and any attachments against
> > > viruses.
> > > TEMENOS accepts no liability for any damage caused by any malicious
> code
> > > or virus transmitted by this e-mail.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> > --
> > Dr Paul Robinson
> > Senior Consultant Engineer
> > Arjuna Technologies Ltd
> >
> > Tel: +44 191 243 0676
> > Mob: +44 772 920 7346
> > Fax: +44 191 243 0677
> > Web: www.arjuna.com
> >
> > Registered Office: Floor A, Milburn House, Dean Street, Newcastle upon
> > Tyne, NE1 1LE
> >
> > VAT Registration No: 764173128. Company registered in England
> >
> > Registration No: 4497081
> > Disclaimer:
> > If you have received this e-mail in error please notify the sender.
> > Please note that any views or opinions presented in this e-mail are
> solely
> > those of the author and do not necessarily represent those of TEMENOS.
> > We recommend that you check this e-mail and any attachments against
> > viruses.
> > TEMENOS accepts no liability for any damage caused by any malicious code
> > or virus transmitted by this e-mail.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
>
>
> --
> Dr Paul Robinson
> Senior Consultant Engineer
> Arjuna Technologies Ltd
>
> Tel: +44 191 243 0676
> Mob: +44 772 920 7346
> Fax: +44 191 243 0677
> Web: www.arjuna.com
>
> Registered Office: Floor A, Milburn House, Dean Street, Newcastle upon
> Tyne, NE1 1LE
>
> VAT Registration No: 764173128. Company registered in England
>
> Registration No: 4497081
> Disclaimer:
> If you have received this e-mail in error please notify the sender.
> Please note that any views or opinions presented in this e-mail are solely
> those of the author and do not necessarily represent those of TEMENOS.
> We recommend that you check this e-mail and any attachments against
> viruses.
> TEMENOS accepts no liability for any damage caused by any malicious code
> or virus transmitted by this e-mail.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


-- 
Dr Paul Robinson
Senior Consultant Engineer
Arjuna Technologies Ltd

Tel: +44 191 243 0676
Mob: +44 772 920 7346
Fax: +44 191 243 0677
Web: www.arjuna.com

Registered Office: Floor A, Milburn House, Dean Street, Newcastle upon
Tyne, NE1 1LE

VAT Registration No: 764173128. Company registered in England

Registration No: 4497081

RE: Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Posted by Ian Blavins <ib...@temenos.com>.
G'day

I had the same problem.

I define a user defined variable to hold the thread count. I populate the Number of Threads field on the thread group from the UDV (the field accepts an expression). Then you have the thread count in a variable which you can give to the sampler in the normal way without having two places to update the thread count.
 


Ian Blavins
Software performance specialist
.
TEMENOS
The Banking Software Company
.
PeopleBuilding 2, Maylands Av
Hemel Hempstead   UK   HP2 4NW
.
T:  +44 (0) 1442 431 106
E:  iblavins@temenos.com
.
www.temenos.com
.


-----Original Message-----
From: paul.robinson.arjuna@googlemail.com [mailto:paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
Sent: Monday, 23 March 2009 4:19 PM
To: JMeter Users List
Subject: Re: Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Ian,

I see what you mean now. We have considered this approach already and we
plan to use it as a fall back. The problem with the approach is as you
suggest, you need to tell the sampler how many client threads to expect.
I've inspected the JavaSamplerContext and can't find a thread count.

Thanks,

Paul.

2009/3/23 Ian Blavins <ib...@temenos.com>

> G'day
>
> I wasn't suggesting static for the connection - just to control
> initialization.  Don't let any thread exit from initialization until all
> have completed initialization. You will need a static variable to keep count
> of threads that have initialized and a static synchronized method to update
> it in a thread safe manner. You will also need to tell the sampler the
> number of threads in the run. You may be able to get this from the
> environment with a method call or you may have to pass it in.
>
> There are probably other ways to do this if getting the number of threads
> in the run proves awkward.
>
>
>
> Ian Blavins
> Software performance specialist
> .
> TEMENOS
> The Banking Software Company
> .
> PeopleBuilding 2, Maylands Av
> Hemel Hempstead   UK   HP2 4NW
> .
> T:  +44 (0) 1442 431 106
> E:  iblavins@temenos.com
> .
> www.temenos.com
> .
>
>
> -----Original Message-----
> From: paul.robinson.arjuna@googlemail.com [mailto:
> paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
> Sent: Monday, 23 March 2009 4:09 PM
> To: JMeter Users List
> Subject: Re: Custom Sampler: Force all setupTest methods to be invoked
> before runTest methods
>
> Hi,
>
> Thanks for the quick reply. Static variables would be a good idea, however,
> I require that each thread has it's own connection, in order to simulate
> multiple separate users. Sharing a connection through a static variable
> would break my test unfortunately.
>
> For some reason, the system I am testing requires that all connections are
> established before any of them are used. Therefore I really need to ensure
> all the setupTest methods are invoked before any of the runTest methods are
> invoked.
>
> Thanks for the help,
>
> Paul.
>
>
> 2009/3/23 Ian Blavins <ib...@temenos.com>
>
> > G'day
> >
> > Because they all run under one JVM all instances of the sampler within a
> > JMeter server can share memory through static variables.
> >
> > If you are familiar with static variables that should be enough to get
> you
> > going.
> >
> >
> > Ian Blavins
> > Software performance specialist
> > .
> > TEMENOS
> > The Banking Software Company
> > .
> > PeopleBuilding 2, Maylands Av
> > Hemel Hempstead   UK   HP2 4NW
> > .
> > T:  +44 (0) 1442 431 106
> > E:  iblavins@temenos.com
> > .
> > www.temenos.com
> > .
> >
> > -----Original Message-----
> > From: paul.robinson.arjuna@googlemail.com [mailto:
> > paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
> > Sent: Monday, 23 March 2009 2:59 PM
> > To: jmeter-user@jakarta.apache.org
> > Subject: Custom Sampler: Force all setupTest methods to be invoked before
> > runTest methods
> >
> > Hello,
> >
> > I have written a Custom Sampler by extending "AbstractJavaSamplerClient".
> > My
> > sampler is very simple, it just logs the method being invoked.
> >
> > If i run the sampler for 2 threads with "loop count" of 1, I see the
> > following output:
> >
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
> >
> > Here you will observe that the "runTest" method of the first thread is
> > invoked before the "setupTest" of the 2nd thread. For my test I need to
> > ensure that all threads have their setupTest method invoked before any of
> > them have their "runTest" method ivoked.
> >
> > Does anyone know how I can do this?
> >
> > Thanks,
> >
> > Paul.
> > Disclaimer:
> > If you have received this e-mail in error please notify the sender.
> > Please note that any views or opinions presented in this e-mail are
> solely
> > those of the author and do not necessarily represent those of TEMENOS.
> > We recommend that you check this e-mail and any attachments against
> > viruses.
> > TEMENOS accepts no liability for any damage caused by any malicious code
> > or virus transmitted by this e-mail.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
>
>
> --
> Dr Paul Robinson
> Senior Consultant Engineer
> Arjuna Technologies Ltd
>
> Tel: +44 191 243 0676
> Mob: +44 772 920 7346
> Fax: +44 191 243 0677
> Web: www.arjuna.com
>
> Registered Office: Floor A, Milburn House, Dean Street, Newcastle upon
> Tyne, NE1 1LE
>
> VAT Registration No: 764173128. Company registered in England
>
> Registration No: 4497081
> Disclaimer:
> If you have received this e-mail in error please notify the sender.
> Please note that any views or opinions presented in this e-mail are solely
> those of the author and do not necessarily represent those of TEMENOS.
> We recommend that you check this e-mail and any attachments against
> viruses.
> TEMENOS accepts no liability for any damage caused by any malicious code
> or virus transmitted by this e-mail.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


-- 
Dr Paul Robinson
Senior Consultant Engineer
Arjuna Technologies Ltd

Tel: +44 191 243 0676
Mob: +44 772 920 7346
Fax: +44 191 243 0677
Web: www.arjuna.com

Registered Office: Floor A, Milburn House, Dean Street, Newcastle upon
Tyne, NE1 1LE

VAT Registration No: 764173128. Company registered in England

Registration No: 4497081
Disclaimer:
If you have received this e-mail in error please notify the sender. 
Please note that any views or opinions presented in this e-mail are solely 
those of the author and do not necessarily represent those of TEMENOS. 
We recommend that you check this e-mail and any attachments against viruses. 
TEMENOS accepts no liability for any damage caused by any malicious code 
or virus transmitted by this e-mail.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Posted by Paul Robinson <pa...@arjuna.com>.
Ian,

I see what you mean now. We have considered this approach already and we
plan to use it as a fall back. The problem with the approach is as you
suggest, you need to tell the sampler how many client threads to expect.
I've inspected the JavaSamplerContext and can't find a thread count.

Thanks,

Paul.

2009/3/23 Ian Blavins <ib...@temenos.com>

> G'day
>
> I wasn't suggesting static for the connection - just to control
> initialization.  Don't let any thread exit from initialization until all
> have completed initialization. You will need a static variable to keep count
> of threads that have initialized and a static synchronized method to update
> it in a thread safe manner. You will also need to tell the sampler the
> number of threads in the run. You may be able to get this from the
> environment with a method call or you may have to pass it in.
>
> There are probably other ways to do this if getting the number of threads
> in the run proves awkward.
>
>
>
> Ian Blavins
> Software performance specialist
> .
> TEMENOS
> The Banking Software Company
> .
> PeopleBuilding 2, Maylands Av
> Hemel Hempstead   UK   HP2 4NW
> .
> T:  +44 (0) 1442 431 106
> E:  iblavins@temenos.com
> .
> www.temenos.com
> .
>
>
> -----Original Message-----
> From: paul.robinson.arjuna@googlemail.com [mailto:
> paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
> Sent: Monday, 23 March 2009 4:09 PM
> To: JMeter Users List
> Subject: Re: Custom Sampler: Force all setupTest methods to be invoked
> before runTest methods
>
> Hi,
>
> Thanks for the quick reply. Static variables would be a good idea, however,
> I require that each thread has it's own connection, in order to simulate
> multiple separate users. Sharing a connection through a static variable
> would break my test unfortunately.
>
> For some reason, the system I am testing requires that all connections are
> established before any of them are used. Therefore I really need to ensure
> all the setupTest methods are invoked before any of the runTest methods are
> invoked.
>
> Thanks for the help,
>
> Paul.
>
>
> 2009/3/23 Ian Blavins <ib...@temenos.com>
>
> > G'day
> >
> > Because they all run under one JVM all instances of the sampler within a
> > JMeter server can share memory through static variables.
> >
> > If you are familiar with static variables that should be enough to get
> you
> > going.
> >
> >
> > Ian Blavins
> > Software performance specialist
> > .
> > TEMENOS
> > The Banking Software Company
> > .
> > PeopleBuilding 2, Maylands Av
> > Hemel Hempstead   UK   HP2 4NW
> > .
> > T:  +44 (0) 1442 431 106
> > E:  iblavins@temenos.com
> > .
> > www.temenos.com
> > .
> >
> > -----Original Message-----
> > From: paul.robinson.arjuna@googlemail.com [mailto:
> > paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
> > Sent: Monday, 23 March 2009 2:59 PM
> > To: jmeter-user@jakarta.apache.org
> > Subject: Custom Sampler: Force all setupTest methods to be invoked before
> > runTest methods
> >
> > Hello,
> >
> > I have written a Custom Sampler by extending "AbstractJavaSamplerClient".
> > My
> > sampler is very simple, it just logs the method being invoked.
> >
> > If i run the sampler for 2 threads with "loop count" of 1, I see the
> > following output:
> >
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
> > INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
> >
> > Here you will observe that the "runTest" method of the first thread is
> > invoked before the "setupTest" of the 2nd thread. For my test I need to
> > ensure that all threads have their setupTest method invoked before any of
> > them have their "runTest" method ivoked.
> >
> > Does anyone know how I can do this?
> >
> > Thanks,
> >
> > Paul.
> > Disclaimer:
> > If you have received this e-mail in error please notify the sender.
> > Please note that any views or opinions presented in this e-mail are
> solely
> > those of the author and do not necessarily represent those of TEMENOS.
> > We recommend that you check this e-mail and any attachments against
> > viruses.
> > TEMENOS accepts no liability for any damage caused by any malicious code
> > or virus transmitted by this e-mail.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
>
>
> --
> Dr Paul Robinson
> Senior Consultant Engineer
> Arjuna Technologies Ltd
>
> Tel: +44 191 243 0676
> Mob: +44 772 920 7346
> Fax: +44 191 243 0677
> Web: www.arjuna.com
>
> Registered Office: Floor A, Milburn House, Dean Street, Newcastle upon
> Tyne, NE1 1LE
>
> VAT Registration No: 764173128. Company registered in England
>
> Registration No: 4497081
> Disclaimer:
> If you have received this e-mail in error please notify the sender.
> Please note that any views or opinions presented in this e-mail are solely
> those of the author and do not necessarily represent those of TEMENOS.
> We recommend that you check this e-mail and any attachments against
> viruses.
> TEMENOS accepts no liability for any damage caused by any malicious code
> or virus transmitted by this e-mail.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


-- 
Dr Paul Robinson
Senior Consultant Engineer
Arjuna Technologies Ltd

Tel: +44 191 243 0676
Mob: +44 772 920 7346
Fax: +44 191 243 0677
Web: www.arjuna.com

Registered Office: Floor A, Milburn House, Dean Street, Newcastle upon
Tyne, NE1 1LE

VAT Registration No: 764173128. Company registered in England

Registration No: 4497081

RE: Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Posted by Ian Blavins <ib...@temenos.com>.
G'day

I wasn't suggesting static for the connection - just to control initialization.  Don't let any thread exit from initialization until all have completed initialization. You will need a static variable to keep count of threads that have initialized and a static synchronized method to update it in a thread safe manner. You will also need to tell the sampler the number of threads in the run. You may be able to get this from the environment with a method call or you may have to pass it in.

There are probably other ways to do this if getting the number of threads in the run proves awkward.



Ian Blavins
Software performance specialist
.
TEMENOS
The Banking Software Company
.
PeopleBuilding 2, Maylands Av
Hemel Hempstead   UK   HP2 4NW
.
T:  +44 (0) 1442 431 106
E:  iblavins@temenos.com
.
www.temenos.com
.


-----Original Message-----
From: paul.robinson.arjuna@googlemail.com [mailto:paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
Sent: Monday, 23 March 2009 4:09 PM
To: JMeter Users List
Subject: Re: Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Hi,

Thanks for the quick reply. Static variables would be a good idea, however,
I require that each thread has it's own connection, in order to simulate
multiple separate users. Sharing a connection through a static variable
would break my test unfortunately.

For some reason, the system I am testing requires that all connections are
established before any of them are used. Therefore I really need to ensure
all the setupTest methods are invoked before any of the runTest methods are
invoked.

Thanks for the help,

Paul.


2009/3/23 Ian Blavins <ib...@temenos.com>

> G'day
>
> Because they all run under one JVM all instances of the sampler within a
> JMeter server can share memory through static variables.
>
> If you are familiar with static variables that should be enough to get you
> going.
>
>
> Ian Blavins
> Software performance specialist
> .
> TEMENOS
> The Banking Software Company
> .
> PeopleBuilding 2, Maylands Av
> Hemel Hempstead   UK   HP2 4NW
> .
> T:  +44 (0) 1442 431 106
> E:  iblavins@temenos.com
> .
> www.temenos.com
> .
>
> -----Original Message-----
> From: paul.robinson.arjuna@googlemail.com [mailto:
> paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
> Sent: Monday, 23 March 2009 2:59 PM
> To: jmeter-user@jakarta.apache.org
> Subject: Custom Sampler: Force all setupTest methods to be invoked before
> runTest methods
>
> Hello,
>
> I have written a Custom Sampler by extending "AbstractJavaSamplerClient".
> My
> sampler is very simple, it just logs the method being invoked.
>
> If i run the sampler for 2 threads with "loop count" of 1, I see the
> following output:
>
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
>
> Here you will observe that the "runTest" method of the first thread is
> invoked before the "setupTest" of the 2nd thread. For my test I need to
> ensure that all threads have their setupTest method invoked before any of
> them have their "runTest" method ivoked.
>
> Does anyone know how I can do this?
>
> Thanks,
>
> Paul.
> Disclaimer:
> If you have received this e-mail in error please notify the sender.
> Please note that any views or opinions presented in this e-mail are solely
> those of the author and do not necessarily represent those of TEMENOS.
> We recommend that you check this e-mail and any attachments against
> viruses.
> TEMENOS accepts no liability for any damage caused by any malicious code
> or virus transmitted by this e-mail.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


-- 
Dr Paul Robinson
Senior Consultant Engineer
Arjuna Technologies Ltd

Tel: +44 191 243 0676
Mob: +44 772 920 7346
Fax: +44 191 243 0677
Web: www.arjuna.com

Registered Office: Floor A, Milburn House, Dean Street, Newcastle upon
Tyne, NE1 1LE

VAT Registration No: 764173128. Company registered in England

Registration No: 4497081
Disclaimer:
If you have received this e-mail in error please notify the sender. 
Please note that any views or opinions presented in this e-mail are solely 
those of the author and do not necessarily represent those of TEMENOS. 
We recommend that you check this e-mail and any attachments against viruses. 
TEMENOS accepts no liability for any damage caused by any malicious code 
or virus transmitted by this e-mail.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Posted by Paul Robinson <pa...@arjuna.com>.
Hi,

Thanks for the quick reply. Static variables would be a good idea, however,
I require that each thread has it's own connection, in order to simulate
multiple separate users. Sharing a connection through a static variable
would break my test unfortunately.

For some reason, the system I am testing requires that all connections are
established before any of them are used. Therefore I really need to ensure
all the setupTest methods are invoked before any of the runTest methods are
invoked.

Thanks for the help,

Paul.


2009/3/23 Ian Blavins <ib...@temenos.com>

> G'day
>
> Because they all run under one JVM all instances of the sampler within a
> JMeter server can share memory through static variables.
>
> If you are familiar with static variables that should be enough to get you
> going.
>
>
> Ian Blavins
> Software performance specialist
> .
> TEMENOS
> The Banking Software Company
> .
> PeopleBuilding 2, Maylands Av
> Hemel Hempstead   UK   HP2 4NW
> .
> T:  +44 (0) 1442 431 106
> E:  iblavins@temenos.com
> .
> www.temenos.com
> .
>
> -----Original Message-----
> From: paul.robinson.arjuna@googlemail.com [mailto:
> paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
> Sent: Monday, 23 March 2009 2:59 PM
> To: jmeter-user@jakarta.apache.org
> Subject: Custom Sampler: Force all setupTest methods to be invoked before
> runTest methods
>
> Hello,
>
> I have written a Custom Sampler by extending "AbstractJavaSamplerClient".
> My
> sampler is very simple, it just logs the method being invoked.
>
> If i run the sampler for 2 threads with "loop count" of 1, I see the
> following output:
>
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
> INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
>
> Here you will observe that the "runTest" method of the first thread is
> invoked before the "setupTest" of the 2nd thread. For my test I need to
> ensure that all threads have their setupTest method invoked before any of
> them have their "runTest" method ivoked.
>
> Does anyone know how I can do this?
>
> Thanks,
>
> Paul.
> Disclaimer:
> If you have received this e-mail in error please notify the sender.
> Please note that any views or opinions presented in this e-mail are solely
> those of the author and do not necessarily represent those of TEMENOS.
> We recommend that you check this e-mail and any attachments against
> viruses.
> TEMENOS accepts no liability for any damage caused by any malicious code
> or virus transmitted by this e-mail.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


-- 
Dr Paul Robinson
Senior Consultant Engineer
Arjuna Technologies Ltd

Tel: +44 191 243 0676
Mob: +44 772 920 7346
Fax: +44 191 243 0677
Web: www.arjuna.com

Registered Office: Floor A, Milburn House, Dean Street, Newcastle upon
Tyne, NE1 1LE

VAT Registration No: 764173128. Company registered in England

Registration No: 4497081

RE: Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Posted by Ian Blavins <ib...@temenos.com>.
G'day

Because they all run under one JVM all instances of the sampler within a JMeter server can share memory through static variables.

If you are familiar with static variables that should be enough to get you going.


Ian Blavins
Software performance specialist
.
TEMENOS
The Banking Software Company
.
PeopleBuilding 2, Maylands Av
Hemel Hempstead   UK   HP2 4NW
.
T:  +44 (0) 1442 431 106
E:  iblavins@temenos.com
.
www.temenos.com
.

-----Original Message-----
From: paul.robinson.arjuna@googlemail.com [mailto:paul.robinson.arjuna@googlemail.com] On Behalf Of Paul Robinson
Sent: Monday, 23 March 2009 2:59 PM
To: jmeter-user@jakarta.apache.org
Subject: Custom Sampler: Force all setupTest methods to be invoked before runTest methods

Hello,

I have written a Custom Sampler by extending "AbstractJavaSamplerClient". My
sampler is very simple, it just logs the method being invoked.

If i run the sampler for 2 threads with "loop count" of 1, I see the
following output:

INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler Constructor
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler setupTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler runTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest
INFO  03/23, 02:49:18 hat.test.jms.test.DummySampler teardownTest

Here you will observe that the "runTest" method of the first thread is
invoked before the "setupTest" of the 2nd thread. For my test I need to
ensure that all threads have their setupTest method invoked before any of
them have their "runTest" method ivoked.

Does anyone know how I can do this?

Thanks,

Paul.
Disclaimer:
If you have received this e-mail in error please notify the sender. 
Please note that any views or opinions presented in this e-mail are solely 
those of the author and do not necessarily represent those of TEMENOS. 
We recommend that you check this e-mail and any attachments against viruses. 
TEMENOS accepts no liability for any damage caused by any malicious code 
or virus transmitted by this e-mail.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org