Reply
Highlighted
Occasional Contributor
Posts: 11
Registered: ‎03-15-2017
Accepted Solution

Creating Load Test using Wsdl classes in java project. Having each thread to be different

Hi,

 

I am creating a Load Test using the com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest class in my Java project. When I run the loadTest it works, and the endpoint does what it is supposed to do to a member. The thing is I need each thread to be a different member. 

Here I go into my TestSuite, and then into my testCase. I set the propertyValue of the testCase. 

WsdlTestSuite testSuite = testProject.getTestSuiteByName("Reward");
WsdlTestCase testCase = testSuite.getTestCaseByName("TriggerActivityReward");
testCase.setPropertyValue("memberId", "182996");

 The testStep gets the data of the memberId from the testCase property "memberId". As such: 

"${#TestCase#memberId}"

 In the JSON of the POST rest endpoint.

 

Then I setUp my loadTest. 

loadTest = testCase.addNewLoadTest("firstLoadTest");
loadTest.setThreadCount(5);
loadTest.setLimitType(Enum.forInt(1));
loadTest.setTestLimit(1);

I need each thread to have a different memberId every run. How could I achieve this? I have gone through the documentation of the com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest class, and I haven't found much. I also so something like context.ThreadIndex by adding a setUp groovy script to the loadTest. I tried that but didn't work.

 

Any thoughts? Ideas?

 

Thanks!

Community Hero
Posts: 3,980
Registered: ‎05-17-2013

Re: Creating Load Test using Wsdl classes in java project. Having each thread to be different

[ Edited ]

Change from :
testCase.setPropertyValue("memberId", "182996");
To:
testCase.setPropertyValue("memberId", System.currentTimeMillis().toString());

Regards,
Rao.
Occasional Contributor
Posts: 11
Registered: ‎03-15-2017

Re: Creating Load Test using Wsdl classes in java project. Having each thread to be different

Thanks for your response Rao. The thing is I have an array lets say with 100 memberIDs, those are the memberIDs I need to use, they can't just be random numbers. Inside my JSON I also have a groupID which is the group that memberID is part of. I also have another array with the groupIDs I need to use.

 

Is there anyway to get every thread, and change the properties of the TestCase just before a thread ("user") is created for the Load Test?

 

Thanks!

Community Hero
Posts: 3,980
Registered: ‎05-17-2013

Re: Creating Load Test using Wsdl classes in java project. Having each thread to be different

[ Edited ]

Then you can define the list with valid values in a groovy script before json request step

​def list = [12343, 12345, 342432,3432,32131]

def index = new Random().nextInt(list.size())
context.testCase.setPropertyValue('memberId', "${list[index]​.toString()}​")

Regards,
Rao.
Occasional Contributor
Posts: 11
Registered: ‎03-15-2017

Re: Creating Load Test using Wsdl classes in java project. Having each thread to be different

Hi Rao, Thank you so much for your help! Is this script a setUp script for the LoadTest or a script for the TestStep?

 

Thank you again!

Andres

Community Hero
Posts: 3,980
Registered: ‎05-17-2013

Re: Creating Load Test using Wsdl classes in java project. Having each thread to be different

You can use it as step in the test case as mentioned earlier.
Regards,
Rao.
Register Now