You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by viet nguyen <vi...@gmail.com> on 2009/04/27 16:23:08 UTC

stop/shutdown test programmatically

I'm load testing a Java client that is part of a client-server system.

I wrote 2 custom samplers that are both extending AbstractJavaSamplerClient
- The setup sampler instantiates my test java application and performs
necessary data setup, eg connecting to the backend server.  The other
sampler performs the actual load test by calling various java methods on the
client application.

I'm looking for the ability to stop or shutdown the test if the setup
sampler fails for some reason.  
Calling StandardJMeterEngine.stopEngineNow() seems to stop some working
threads but some threads can't be stopped as I'm seeing "Thread won't die:
my thread" 


-- 
View this message in context: http://www.nabble.com/stop-shutdown-test-programmatically-tp23257446p23257446.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: stop/shutdown test programmatically

Posted by sebb <se...@gmail.com>.
On 27/04/2009, viet nguyen <vi...@gmail.com> wrote:
>
>  Thanks for getting back to me.
>  I want to completely automate the test execution via Bamboo continuous build
>  server so it's very important that jmeter can be run in non-gui mode.
>
>  For the time being what can I do to tell JMeter not to run the sample loop
>  if exceptions are caught in setupTest(JavaSamplerContext context) ?
>
>

Try adding a Result Status Action PostProcessor to stop the test if
the setup fails.

Obviously you'll need to code your setup sampler so it generates a
failed sample if it fails, and a successful one otherwise.

>
>
>
>  On 27/04/2009, viet nguyen <vi...@gmail.com> wrote:
>  >
>  >  I'm load testing a Java client that is part of a client-server system.
>  >
>  >  I wrote 2 custom samplers that are both extending
>  > AbstractJavaSamplerClient
>  >  - The setup sampler instantiates my test java application and performs
>  >  necessary data setup, eg connecting to the backend server.  The other
>  >  sampler performs the actual load test by calling various java methods on
>  > the
>  >  client application.
>  >
>  >  I'm looking for the ability to stop or shutdown the test if the setup
>  >  sampler fails for some reason.
>  >  Calling StandardJMeterEngine.stopEngineNow() seems to stop some working
>  >  threads but some threads can't be stopped as I'm seeing "Thread won't
>  > die:
>  >  my thread"
>  >
>
>  If the sampler thread does not react to Thread.interrupt(), then at
>  present the thread will carry on until the sample completes. For
>  example Thread.sleep() will be interrupted, but socket I/O is not.
>
>  The version of JMeter in SVN now has a new Interruptible interface
>  which samplers can implement. If so, then StopNow will invoke the
>  interrupt method on the sampler.
>
>  It is up to the sampler to determine how to implement this; in the
>  case of HTTP samplers, it's fairly easy as one can just call
>  disconnect() on the connection.
>
>  Also, for non-GUI test runs, if StopNow fails to stop the test within
>  the timeout, it will exit the JVM. There is no other safe way to
>  forcible stop a thread; Thread.stop() is deprecated.
>
>  This may be enough for your purposes.
>
>  If you want to be able to recover from timeouts, then you will need to
>  implement the Interruptible interface.
>
>  If you are willing to try a nightly build, I think you will find that
>  a lot of the work has been done.
>
>  Stopping a test from the GUI is also much more reliable and flexible:
>  you can try a graceful shutdown, and if that does not work, try a
>  forcible shutdown.
>
>  --
>
> View this message in context: http://www.nabble.com/stop-shutdown-test-programmatically-tp23257446p23260078.html
>
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

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


Re: stop/shutdown test programmatically

Posted by viet nguyen <vi...@gmail.com>.
Thanks for getting back to me.
I want to completely automate the test execution via Bamboo continuous build
server so it's very important that jmeter can be run in non-gui mode.

For the time being what can I do to tell JMeter not to run the sample loop
if exceptions are caught in setupTest(JavaSamplerContext context) ?





On 27/04/2009, viet nguyen <vi...@gmail.com> wrote:
>
>  I'm load testing a Java client that is part of a client-server system.
>
>  I wrote 2 custom samplers that are both extending
> AbstractJavaSamplerClient
>  - The setup sampler instantiates my test java application and performs
>  necessary data setup, eg connecting to the backend server.  The other
>  sampler performs the actual load test by calling various java methods on
> the
>  client application.
>
>  I'm looking for the ability to stop or shutdown the test if the setup
>  sampler fails for some reason.
>  Calling StandardJMeterEngine.stopEngineNow() seems to stop some working
>  threads but some threads can't be stopped as I'm seeing "Thread won't
> die:
>  my thread"
>

If the sampler thread does not react to Thread.interrupt(), then at
present the thread will carry on until the sample completes. For
example Thread.sleep() will be interrupted, but socket I/O is not.

The version of JMeter in SVN now has a new Interruptible interface
which samplers can implement. If so, then StopNow will invoke the
interrupt method on the sampler.

It is up to the sampler to determine how to implement this; in the
case of HTTP samplers, it's fairly easy as one can just call
disconnect() on the connection.

Also, for non-GUI test runs, if StopNow fails to stop the test within
the timeout, it will exit the JVM. There is no other safe way to
forcible stop a thread; Thread.stop() is deprecated.

This may be enough for your purposes.

If you want to be able to recover from timeouts, then you will need to
implement the Interruptible interface.

If you are willing to try a nightly build, I think you will find that
a lot of the work has been done.

Stopping a test from the GUI is also much more reliable and flexible:
you can try a graceful shutdown, and if that does not work, try a
forcible shutdown.

-- 
View this message in context: http://www.nabble.com/stop-shutdown-test-programmatically-tp23257446p23260078.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: stop/shutdown test programmatically

Posted by sebb <se...@gmail.com>.
On 27/04/2009, viet nguyen <vi...@gmail.com> wrote:
>
>  I'm load testing a Java client that is part of a client-server system.
>
>  I wrote 2 custom samplers that are both extending AbstractJavaSamplerClient
>  - The setup sampler instantiates my test java application and performs
>  necessary data setup, eg connecting to the backend server.  The other
>  sampler performs the actual load test by calling various java methods on the
>  client application.
>
>  I'm looking for the ability to stop or shutdown the test if the setup
>  sampler fails for some reason.
>  Calling StandardJMeterEngine.stopEngineNow() seems to stop some working
>  threads but some threads can't be stopped as I'm seeing "Thread won't die:
>  my thread"
>

If the sampler thread does not react to Thread.interrupt(), then at
present the thread will carry on until the sample completes. For
example Thread.sleep() will be interrupted, but socket I/O is not.

The version of JMeter in SVN now has a new Interruptible interface
which samplers can implement. If so, then StopNow will invoke the
interrupt method on the sampler.

It is up to the sampler to determine how to implement this; in the
case of HTTP samplers, it's fairly easy as one can just call
disconnect() on the connection.

Also, for non-GUI test runs, if StopNow fails to stop the test within
the timeout, it will exit the JVM. There is no other safe way to
forcible stop a thread; Thread.stop() is deprecated.

This may be enough for your purposes.

If you want to be able to recover from timeouts, then you will need to
implement the Interruptible interface.

If you are willing to try a nightly build, I think you will find that
a lot of the work has been done.

Stopping a test from the GUI is also much more reliable and flexible:
you can try a graceful shutdown, and if that does not work, try a
forcible shutdown.

>
>  --
>  View this message in context: http://www.nabble.com/stop-shutdown-test-programmatically-tp23257446p23257446.html
>  Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

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