Forum Discussion

selkind's avatar
selkind
Occasional Contributor
15 years ago

Having troubles running a load test from a Groovy script

I'm trying to do a single load test that has two phases to the test.  To do this, I'm creating a separate "Master Test case" with a load test whose setup script invokes the load test from another test case, then executes a load test made up of the test case(s) within the "Master".

The script is below.  First I find the Test Suite object by navigating up the hierarchy, then navigate back down to get the load test I want.  Printing out the names shows I'm getting the right objects.

However, when I invoke the run method, that load test does not execute, and in fact the run method returns null.  (I was getting an exception trying to invoke the hasStopped() method, so I added the log statement on the Runner's name and now get "Tue Mar 16 14:31:17 EDT 2010:ERROR:An error occured [Cannot get property 'name' on null object], see error log for details" in the log).

Can anyone spot what I'm doing wrong here?

This is soapUI 3.5, downloaded yesterday.

Thanks in advance for any help.


masterLoadTest = loadTestRunner.loadTest
parentTestCase = masterLoadTest.parent
parentTestSuite = parentTestCase.parent
parentProject =  parentTestSuite.parent

log.info "----------------------"
log.info "masterLoadTest: " + masterLoadTest.name
log.info "parentTestCase: " + parentTestCase.name
log.info "parentTestSuite: " + parentTestSuite.name
log.info "parentProject: " + parentProject.name

warmUpTC = parentTestSuite.getTestCaseByName("SmallDoc FourStreamWarmup TC")
warmUpLT = warmUpTC.getLoadTestByName("FourStreamSmall Warmup LT")
log.info("Running warmup LT: " + warmUpLT.name)
stoMap = new StringToObjectMap()
warmUpLTRunner = warmUpLT.run(stoMap, false)
log.info warmUpLTRunner.name
while (!warmUpLTRunner.hasStopped()) {
java.io.Thread.sleep(1000)
}
log.info("Done with warmup")[/font:1tyzvnjv]

3 Replies

  • selkind's avatar
    selkind
    Occasional Contributor
    After spending another couple or so hours browsing this forum, I caught a hint on a similar problem with a solution for running a test case, different from the others I'd seen.  Based on that, I was able to figure out another way to do this that works, but I have one question about that.

    First, here's the load test setup script that successfully runs a warmup load from another test case, which creates a new WsdlLoadTestRunner object via a constructor, then calls start() on that:

        import com.eviware.soapui.support.types.*
        import com.eviware.soapui.impl.wsdl.teststeps.*
        import com.eviware.soapui.impl.wsdl.loadtest.*

        setup_Testcase = loadTestRunner.loadTest.testCase.testSuite.testCases["SmallDoc   FourStreamWarmup TC"]
        WsdlLoadTest setup_LoadTest = setup_Testcase.loadTests["FourStreamSmall 30 sec Warmup LT"]
        WsdlLoadTestRunner runner = new WsdlLoadTestRunner(setup_LoadTest)
        log.info("Running warmup LT: " + setup_LoadTest.name)
        runner.start(true)
        runner.waitUntilFinished()

        log.info("Done with warmup")[/font:15dsj7ew]

    Here's the leadup to the question.  I first used runner.start(false)[/font:15dsj7ew], followed immediately by the log.info statement, figuring that the script would block until the started load test completed.  In fact what happened was as far as I could tell the called load test never ran, I never see the result of the log.info, and the load test containing this setup script started immediately at the point - i.e., apparently the setup script terminated at the point I called runner.start(false)[/font:15dsj7ew].

    I then change to the async invocation of the child load test with runner.waitUntilFinished()[/font:15dsj7ew] after it as shown above, and now it all works.

    The question is - why don't I see the child load test run and this script block if I use runner.start(false)[/font:15dsj7ew]?  I assume this is the designed behavior, I'd just like to understand it.
  • selkind's avatar
    selkind
    Occasional Contributor
    I'm having another issue with this.  I'd like to see the statistics start at zero every time I invoke runner.start().  However, the statistics accumulate from the time I start up soapUI, and every time I invoke this load test, with this setup script, the called load test's statistics resume where they left off the last time they ran.

    Can anyone give me a hint as to how I'd get the statistics to reset before each load test invocation?
  • grzehoo's avatar
    grzehoo
    New Contributor
    Hi,

    1)
    SmallDoc   FourStreamWarmup TC
    - is it Your request name in test steps?

    2)
    FourStreamSmall 30 sec Warmup LT
    - is it Your load test name?