12 years ago
How to retrieve number of (JMS) messages sent in groovy?
Hello,
I am trying to build a groovy script that runs a specific testcase (only containing the sending of a JMS messages) for a number of times, but with a variable number of threads.
The only thing I do not find how to do is how to display the number of JMS messages sent after every testcase run.
This is my code sofar:
Whatever value I try to put in "myCounter" (see 3 examples I tried in the code), I always end up with 0,1 or null.
Any ideas ?
Thanks very much for any help or tips.
Kind regards,
Jan Van Achte
I am trying to build a groovy script that runs a specific testcase (only containing the sending of a JMS messages) for a number of times, but with a variable number of threads.
The only thing I do not find how to do is how to display the number of JMS messages sent after every testcase run.
This is my code sofar:
def myTestMap = [ "1:":2,"2:":2, "3:":4 ]
myTestCaseName = "Unclear"
myLoadTestLimitSeconds = 60
def myRunner
int myCounter
def myTestCase = testRunner.testCase.testSuite.project.testSuites["MySuite"].testCases[myTestCaseName]
def myLoadTest = myTestCase.getLoadTestByName("Run")
myLoadTest.setTestLimit(myLoadTestLimitSeconds)
for(myTestCaseParameters in myTestMap) {
myId = myTestCaseParameters.key
myThreadCount = myTestCaseParameters.value
myTestCase.setPropertyValue( "MessageCorrelationID_prefix", myId )
myLoadTest.setThreadCount(myThreadCount)
log.info "$myId started"
myRunner = myLoadTest.run()
myRunner.waitUntilFinished()
//myCounter = testRunner.runContext.TotalRunCount
//myCounter = myRunner.runContext.TotalRunCount
//myCounter = context.RunCount
log.info "$myId finished, number of messages sent $myCounter, time taken for TestCase was: $myRunner.timeTaken ms"
}
Whatever value I try to put in "myCounter" (see 3 examples I tried in the code), I always end up with 0,1 or null.
Any ideas ?
Thanks very much for any help or tips.
Kind regards,
Jan Van Achte