Forum Discussion

pratoa's avatar
pratoa
Occasional Contributor
8 years ago
Solved

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!

  • 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()}​")

5 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

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

    • pratoa's avatar
      pratoa
      Occasional Contributor

      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!

      • nmrao's avatar
        nmrao
        Champion Level 3

        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()}​")