deggial
13 years agoOccasional Contributor
turning groovy script into load test
Hello,
I have a test case consisting of three steps managed by the following script:
I want to turn it into load test for which csv file acts as a shared datasource, so each thread operates on sequent value for each iteration. For example: 50 threads take first 50 values on first iteration, on second iteration values from rows 51 to 100 are used. I intentionally omit case when some threads are slower and some are faster, but I hope you get the gist of what I am trying to accomplish.
As initial ideas I am thinking of:
- adding thread specific code to script (I assume here I should take a look at java thread library)
- restructuring test case so the native soap ui functionality takes care of that (I assume here I have to manage some sort of additional counter as property which would reset itself upon exhaustion of test data set)
Can you please comment on the viability of these two approaches?
I have a test case consisting of three steps managed by the following script:
import com.eviware.soapui.impl.wsdl.teststeps.*
def testDataSet = []
def fileName = "C:\\Users\\xxx\\Desktop\\testdata.csv"
new File(fileName).eachLine { line -> testDataSet.add( line.split(",") ) }
def myProps = new java.util.Properties();
myProps = testRunner.testCase.getTestStepByName("Properties");
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def testCase = testRunner.testCase;
def testStep = testCase.getTestStepByName("myWSRequest");
testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
while (true) {
for ( i in testDataSet ) {
myProps.setPropertyValue("parameter1",i[0]);
myProps.setPropertyValue("parameter2",i[1]);
myProps.setPropertyValue("parameter3",i[2]);
testStep.getTestRequest().setUsername(myProps.getPropertyValue("username"))
testStep.getTestRequest().setPassword(myProps.getPropertyValue("password"))
testStep.run(testRunner, testStepContext);
}
}
I want to turn it into load test for which csv file acts as a shared datasource, so each thread operates on sequent value for each iteration. For example: 50 threads take first 50 values on first iteration, on second iteration values from rows 51 to 100 are used. I intentionally omit case when some threads are slower and some are faster, but I hope you get the gist of what I am trying to accomplish.
As initial ideas I am thinking of:
- adding thread specific code to script (I assume here I should take a look at java thread library)
- restructuring test case so the native soap ui functionality takes care of that (I assume here I have to manage some sort of additional counter as property which would reset itself upon exhaustion of test data set)
Can you please comment on the viability of these two approaches?