Forum Discussion

cristian77's avatar
cristian77
Occasional Contributor
12 years ago

Step executed on init phase (only once and reused)

I have the following scenario:

Step 1) load from a file via groovy the content of a file in base64 format. (very big file)
Step 2) assign this base64 to a parameter
Step 3) execute the request with this parameter

If i execute a load test even 2GB is not enough cause 20 threads can easily consume that.

So is there a way to reuse the file that is loaded ,once among different threads in order not to load on each execution of the test case the big file ?

Thanks

2 Replies

  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    You could try putting the file contents into the run context. In the test case Setup script put this:

    // this gets the appropriate context depending if we are in a load test or not
    def ctx = context.LoadTestContext ?: context

    if (!ctx['myFileContents']) {
    // if the file has not already been loaded, do so
    ctx['myFileContents'] = new File('c:/test/test.txt').text
    }

    This loads the file when running the test case normally. Now in the load test Setup script put this:

    context['myFileContents'] = new File('c:/test/test.txt').text

    Then in your requests, refer to the file contents this way:

    ${=(context.LoadTestContext ?: context)['myFileContents']}

    Each thread will still have to construct the request with the full text but this avoids loading the file load on every execution and having multiple copies of a property with the same contents.
  • cristian77's avatar
    cristian77
    Occasional Contributor
    What if i try to use Global Properties ?

       
    kb600File = new File("c:\\loadui\\kb600.txt").getText();
    mb1File = new File("c:\\loadui\\mb1.txt").getText();
    mb2File = new File("c:\\loadui\\mb2.txt").getText();
    mb7File = new File("c:\\loadui\\mb7.txt").getText();
    com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.globalProperties.setPropertyValue('kb600',kb600File);
    com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.globalProperties.setPropertyValue('mb1',mb1File);
    com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.globalProperties.setPropertyValue('mb2',mb2File);
    com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.globalProperties.setPropertyValue('mb7',mb7File);