Forum Discussion

SDutta's avatar
SDutta
Occasional Contributor
11 years ago

Groovy code to return different numbers

Hi,

I amusing Soap UI Pro 4.5.0 with Load Ui 2.6.6 for quite some time now and I am stuck with one Load testing scenario which I have to design in SOAP UI Pro First...

I need to write a groovy script which will return me numbers that I have to use on the Soap Request. Please No that I will use this SOAP UI Project in Load UI to load test.. And the numbers that should return for each request has to be unique, that is one number has to be used exactly once per request when I am executing the load test

Please Note, I have already used and tried with the DataSource and Datagen test steps.. But they didnt work out for ME... For datagen and datasource setup I have followed the following discussion thread : -- viewtopic.php?f=5&t=3019&start=15. However the same are not working as for Datagen, I had to create a list with 28 million records (Numbers) and with Datasource I tried with Data connection as well as JDBC but fetching the data is taking tooo long time and is not the objective of my load test

Please do tell me what to do now? Please help me with the groovy code as I am new to the Groovy.
  • SDutta's avatar
    SDutta
    Occasional Contributor
    Hi,

    To the above question. I was able to write the groovy Code..

    PFB the same ...
    def var1 = testRunner.testCase.getPropertyValue( "MSISDN" )
    var1 = Long.parseLong(var1) + 1
    temp = var1.toString()

    However, the problem still exists while I am triggering the load test. PFA the project as well..

    I am also attaching the Message viewer snapshots (Error1 and Error2)... Please see that for 2 rather more requests same subscriber number is getting used...

    I tried with both the modes of Datagen.. Step and Read and keeping the shared checkbox checked always but got the same result

    As well as I also tried with DataSource Test step, with shared configuration.. However, My results was same.. Help help me in this...

    I want to have one msisdn (number) passed to the request during load test which will not be used again...
  • SDutta's avatar
    SDutta
    Occasional Contributor
    Sorry I was Not able to upload the Project file and Errors... The Upload attachment option seems to be not working.. I am always getting a error saying [glow=red:3c9va8nx]"The uploaded file is empty."[/glow:3c9va8nx]
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    You can add a test case level property and add set uuid and then perform a get data(point and click) to add the value on a different test step,
    You can generate a unique ID using in a groovy script TestStep,


    def uuid = UUID.randomUUID()
    testRunner.testCase.setPropertyValue( "uuid", uuid )


    Thanks,
    Jeshtha
  • SDutta's avatar
    SDutta
    Occasional Contributor
    SmartBear Support wrote:
    Hi,

    You can add a test case level property and add set uuid and then perform a get data(point and click) to add the value on a different test step,
    You can generate a unique ID using in a groovy script TestStep,


    def uuid = UUID.randomUUID()
    testRunner.testCase.setPropertyValue( "uuid", uuid )



    Hi Jeshtha,

    Thanks for your quick response. However, I am not looking forward to generating any uuid, but is concerned with generating 12 digit numbers (MSISDN) for ex : 966500000001.

    I have this range of numbers in the database from 966500000001 to 966520000001. (20 Million records to be exact). I need to load test by passing one msisdn to my test request. Only thing I cannot use a MSISDN (number) twice.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Sorry for the confusion, I checked the uploaded project,
    I assume that the Test case property number at first comes from Database then in Datagen you add one to the number, then property transfer for the request.

    I would suggest you to try this,
    Create a TestCase property MSISDN
    Instead of JDBCRequestTestStep, create a JDBC Datasource (create the property Number)
    Create a groovy script TestStep,
    //Get the value from Datasource

    def number = context.expand( '${DataSource#number}' )
    def var1 = Long.parseLong(number) + 1
    //set the TestCase property
    testRunner.testCase.setPropertyValue("MSISDN", var1)

    Create a DataSource loop (JDBC Datasource > groovy script TestStep)
    Request execute
    This should work. I tried this on a grid DataSource and this works.



    Thanks,
    Jeshtha
  • SDutta's avatar
    SDutta
    Occasional Contributor
    Thank you Jeshtha,

    I have tried this as well....

    However, Since the no of records(MSISDNs) in the database is 28M, creating a JDBC datasource is just freezing SOAP UI Pro.

    I even tried a couple of different strategies : ---
    PFB the forum links which talks about them ...

    1. viewtopic.php?t=3568

    2. viewtopic.php?t=13274

    But wont didnt work.. Please do have a look at it as well.. Please Note : All the numbers in Database are consecutive from 960000000001 to 962000000001