JMA12
10 years agoRegular Visitor
Use groovy to run sequentialy loadtests
I use soapUI 5.2.1.
I have TestSuite with 4 TestCases and each TestCase has N test steps.
For each TestCase I define one loadTest.
My goal it's to run loadtest on each test step to get some stats about the perf of the request.
To do that, I use groovy script (run 4 TestCases) :
import com.eviware.soapui.impl.wsdl.loadtest.strategy.*
import com.eviware.soapui.support.xml.*
import com.eviware.soapui.config.*
import com.eviware.soapui.model.settings.Settings;
import com.eviware.soapui.settings.HttpSettings;
import com.eviware.soapui.impl.wsdl.loadtest.*;
import java.util.Date;
//define constants
final int NB_THREADS = 20;
final int NB_TIME = 300;
def startDate = new Date();
final String PATH_RESULT = "result_"+startDate.format("yyyy-MM-dd-HH-mm")+".txt";
// create groovyUtils and XmlHolder for response of Request 1 request
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def testCases = context.testCase.testSuite.getTestCaseList();
//create burstStrategy
def xmlobjBuilder = new XmlObjectConfigurationBuilder();
def xmlobj = xmlobjBuilder.add("burstDuration", "10").add("burstDelay", "0").finish();
fos = new FileOutputStream( PATH_RESULT, false )
String conf = "THREADS : " + NB_THREADS + " TIME : " + NB_TIME + "\n";
fos.write(conf.getBytes());
for (def testCase : testCases){
if (testCase.getLabel().equals("PERF-SIGDOC-RUNNER")){
break;
}
def loadtest = testCase.getLoadTestByName("perf");
log.info(testCase.getLabel());
fos.write(testCase.getLabel().getBytes());
fos.write("\n".getBytes());
def testSteps = testCase.getTestStepList();
//disable all teststeps
for (def teststep : testSteps){
teststep.setDisabled(true);
}
//call loadtest
int i=0;
for (def teststep : testSteps){
teststep.setDisabled(false);
//set loadtest strategy
loadtest.setHistoryLimit(0);
loadtest.setLimitType(LoadTestLimitTypesConfig.TIME);
loadtest.setTestLimit(NB_TIME);
loadtest.setThreadCount(NB_THREADS);
Settings settings = loadtest.getSettings();
settings.setBoolean( HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN, false );
settings.setBoolean( HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN,false );
def burstloadStrat = new BurstLoadStrategy(xmlobj, loadtest);
loadtest.setLoadStrategy(burstloadStrat);
//run loadtest
WsdlLoadTestRunner loadTestRunner = new WsdlLoadTestRunner(loadtest);
loadTestRunner.start(true);
loadTestRunner.waitUntilFinished();
//write TPS
def statisticsModel = loadtest.getStatisticsModel();
def data = "\t"+statisticsModel.getValueAt(i, 1) +";" +statisticsModel.getValueAt(i, 7) +";" +statisticsModel.getValueAt(i, 10) + "\n"
log.info(data);
fos.write(data.getBytes());
teststep.setDisabled(true);
i++;
loadTestRunner.release();
}
loadtest.release();
}
fos.flush();
fos.close();With this script , I have a problem . After a moment , the performance fall to zero in terms of TPS stats.
After using the script, I raised the loadloat (without groovy) on TestSTEPS that have inconsistent values , and I get consistent values .
Does anyone has any idea about that ?