Forum Discussion

oleksii's avatar
oleksii
Occasional Contributor
8 years ago

Stop load test suite execution from groovy script.

Hi.

 

The first step in my test suite is SOAP ping request. I want to stop further test suite execution if ping step does not return "alive".

What I tried to do:

  • Add a groovy step after SOAP ping step which would validate ping response and run this (tried testRunner and other handlers; compare with "true" to make it executed - will change to false when I find a solution):
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "ping#Response" )

log.info holder["//Message"]

if(holder["//Message"].contains('alive') == true) {
	log.info "Test execution stopped as ping was unsuccessful."
	loadTestRunner.cancel("Test execution stopped as ping was unsuccessful.")
}
  • Tried to add the script above to teardown tab of the corresponding ping load test.

Neither of this worked - . Can anyone give me a piece of advice on how to accomplish this?

2 Replies

  • oleksii's avatar
    oleksii
    Occasional Contributor

    The more I work with SoapUI the more **bleep**ty it seems to me :(

     

    This:

    loadTestRunner.cancel( "Cancelling LoadTest" )

    being placed in load test setup script has no effect on load test execution at all. How to use it then??

    • rupert_anderson's avatar
      rupert_anderson
      Valued Contributor

      Hi,

       

      Whilst SoapUI has its aged parts and rough edges, I prefer to think of them as opportunities for improvement! :-)

       

      In terms of your problem, if I am understanding you right you have something like:

       

      TestCase:

      1.Soap Request (get ping result)

      2.Groovy TestStep (test ping result and conditionally stop load test)

       

      The above TestCase is then run from a load test.

       

      Could you instead maybe try to conditionally stop the load test from within the TestCase rather than in the Load Test's setup script? Maybe something like:

       

      if( context.LoadTestRunner!= null )
      context.LoadTestRunner.cancel( "Cancelling LoadTest" )

       

      Related post:

      https://community.smartbear.com/t5/SoapUI-NG/Resolved-How-to-stop-loadtest-from-groovy-script/td-p/20898

       

      Regards,

      Rupert