Using JMeter v5.1.1, I am setting a dynamic file path and name to be used with Simple Data Writer. I've tried this every way I can think of to no avail. Things I've tried:
JSR223 PreProcessor (scoped to same thread group) which stores dynamic path/name in variables, and use variable in Simple Data Writer
Execute thread groups consecutively. Use StartUp Thread with JSR223 Sampler which stores dynamic path/name in properties, and use __P function in Simple Data Writer to retrieve path/name. This method will pull the property values from the previous run if I do not remove the properties at the end of the test.
Execute thread groups consecutively. Use StartUp Thread with JSR223 Sampler which stores dynamic path/name in properties. Run JSR223 PreProcessor which stores global properties as variables in thread group, and use variables in Simple Data Writer to retrieve path/name. I've also tried the __V function with this approach. This method will pull the property values from the previous run if I do not remove the properties at the end of the test.
I can see in the JSR223 scripts that the path/name are being set correctly using log.info. I can also see them set when using a debug sampler, but for some reason the Simple Data Writer does not seem to be picking them up. If I set the variables before running, it works fine. This seems like an order of operations problem, or asynchronous/multi-thread issue, but am not sure how to proceed. Any guidance would be much appreciated.
Here's a sample to reproduce the behavior:
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.1.1 r1855137">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Data Writer Issue" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">true</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<SetupThreadGroup guiclass="SetupThreadGroupGui" testclass="SetupThreadGroup" testname="setUp Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</SetupThreadGroup>
<hashTree>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="Set Path to Store Results" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="parameters"></stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="script">import org.apache.jmeter.services.FileServer;
// Get the separator for current OS
String separator = File.separator;
// Use {{current directory}}/csv for path
String path = FileServer.getFileServer().getBaseDir() + separator + "csv" + separator;
// Create directory if doesn't already exist
(new File(path)).mkdirs();
log.info(path);
// Save path to property
props.put("data-file-path", path);</stringProp>
</JSR223Sampler>
<hashTree/>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="Set FileName to Store Results" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="parameters"></stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="script">import org.apache.jmeter.services.FileServer;
import java.time.*;
import java.time.format.*;
// Get current date/time formatted as yyyyMMddHHmm
String formattedDateTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yMMddHHmm"));
// Get name of currently-running script
String scriptName = FileServer.getFileServer().getScriptName();
// Save fileName as scriptName (minus file extension) with timestamp at end
String fileName = scriptName.take(scriptName.lastIndexOf('.')) + "_" + formattedDateTime + ".csv";
log.info(fileName);
// Set filename as property
props.put("data-file-name", fileName);</stringProp>
</JSR223Sampler>
<hashTree/>
</hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Sample GET Requests" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">2</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
<boolProp name="ThreadGroup.delayedStart">true</boolProp>
</ThreadGroup>
<hashTree>
<DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
<boolProp name="displayJMeterProperties">true</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>
<hashTree/>
<ResultCollector guiclass="SimpleDataWriter" testclass="ResultCollector" testname="Save Results to CSV File" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>false</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename">${__P(data-file-path)}${__P(data-file-name)}</stringProp>
</ResultCollector>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Get ToDo" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">jsonplaceholder.typicode.com</stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">/todos/1</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="TestPlan.comments">"groupNames": ["${__P(GroupNames_${__Random(1,${__property(GroupNames_matchNr)})})}"]</stringProp>
</HTTPSamplerProxy>
<hashTree/>
</hashTree>
<PostThreadGroup guiclass="PostThreadGroupGui" testclass="PostThreadGroup" testname="tearDown Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</PostThreadGroup>
<hashTree>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="Clear Dynamic Properties" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="parameters"></stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="script">props.remove("data-file-path");
props.remove("data-file-name");</stringProp>
</JSR223Sampler>
<hashTree/>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>
You can debug this issue using step-by-step Debugger. Also you can use inbuilt JMeter function to complete your requirement if you can. Because inbuilt JMeter function works well in listener's path.
I don't think you can use __P() function in the Simple Data Writer's filename field, in fact you can, but it will return default value of 1 so when you run your test file with the name of 11 is being generated in the folder where you run your tests from and this is where your results go.
In general you should not be using Listeners for anything but tests development and/or debugging because they don't add any value and just consuming valuable system resources. Neither you should run your test in GUI mode
Assuming above points I would recommend reconsidering your approach and use -l command-line argument to specify the .jtl results file location. If you want to add timestamp for this - go for operating system date and time commands, for example:
Windows:
jmeter -n -t test.jmx -l csv/%date:~10,4%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%.csv
Unix and derivatives:
jmeter -n -t test.jmx -l csv/`date +%Y%m%d%H%M`.csv
Related
I need to simulate the below via JMeter:
1. Launch Putty.
2. Enter the IP Address.
3. Login
4. Execute a command. This command needs to be iterated over a csv file.
Unsure of point number 4. especially the iterating part.
Please help.
Regards,
Ajith
Execute a command - take a look at OS Process Sampler
This command needs to be iterated over a csv file - take a look at CSV Data Set Config
If you CSV file looks like:
command1
command2
command3
The following CSV Data Set Config setup:
will read the command from the file and save it to ${command} JMeter Variable, the variable will be updated for next iteration of next thread (virtual user)
You can use beanshell sampler to run commands from your native terminal. Beanshell is just java. You can write all your java code to open a terminal to run your commands. To read data from csv you can use jemetr CSV Data set config.
Sample test.csv file:
a,b,c
x,y,z
p,q,r
Sample beanshell commands to show how you can read data from csv to parametrize your commands: ${a} and vars.get("b") both will work.
log.info("${a} - - - - "+vars.get("b"));
Demo jmx file:
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.0 r1840935">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">10</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="BeanShell Sampler" enabled="true">
<stringProp name="BeanShellSampler.query">log.info("${a} - - - - "+vars.get("b"));
log.info("qqqqqqqqqqqqqqqqqqq");</stringProp>
<stringProp name="BeanShellSampler.filename"></stringProp>
<stringProp name="BeanShellSampler.parameters"></stringProp>
<boolProp name="BeanShellSampler.resetInterpreter">false</boolProp>
</BeanShellSampler>
<hashTree/>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
<CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
<stringProp name="delimiter">,</stringProp>
<stringProp name="fileEncoding">UTF-8</stringProp>
<stringProp name="filename">C:/Users/sushilgupta/Downloads/test.csv</stringProp>
<boolProp name="ignoreFirstLine">false</boolProp>
<boolProp name="quotedData">false</boolProp>
<boolProp name="recycle">true</boolProp>
<stringProp name="shareMode">shareMode.all</stringProp>
<boolProp name="stopThread">false</boolProp>
<stringProp name="variableNames">a,b,c</stringProp>
</CSVDataSet>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>
You can also use selenium autoit to run your commands as manual simulation with selenium web driver plugin.
I have 2 thread groups. After first thread group is executed, the second thread group will send an email with SMTP sampler along with attachment of the result file generated from the first thread group. I am receiving the email, but it is blank.
-Test Plan (Execute thread group one by one)
-Thread Group1
-Multiple http requests
-View Results Tree (generate result file)
-Thread Group 2
-SMTP Sampler to send the email with result file (multipart)
I have tried with teardown thread group again the same result. I am running in GUI mode and want result of first thread group to be sent via email after thread group 1 execution is completed.
Jmeter version 5.1.1
Running on windows 7.
TestPlan Snapshot:-
TestPlan
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.1.1 r1855137">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Smoke Test Suite Prod" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">true</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Smoke Test Suite Prod" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="Browse" enabled="true"/>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Browse Page1" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">www.google.com</stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.protocol">http</stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path"></stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">true</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Browse Page 2" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">www.yahoo.com</stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.protocol">http</stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path"></stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>true</encoding>
<assertions>false</assertions>
<subresults>false</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<fileName>true</fileName>
<hostname>true</hostname>
<threadCounts>true</threadCounts>
<sampleCount>true</sampleCount>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename">Smoke_Test_Results.csv</stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<TestAction guiclass="TestActionGui" testclass="TestAction" testname="Pause Action" enabled="true">
<intProp name="ActionProcessor.action">1</intProp>
<intProp name="ActionProcessor.target">0</intProp>
<stringProp name="ActionProcessor.duration">5000</stringProp>
</TestAction>
<hashTree/>
<SmtpSampler guiclass="SmtpSamplerGui" testclass="SmtpSampler" testname="Email Sampler" enabled="true">
<stringProp name="SMTPSampler.server"></stringProp>
<stringProp name="SMTPSampler.serverPort"></stringProp>
<stringProp name="SMTPSampler.mailFrom"></stringProp>
<stringProp name="SMTPSampler.replyTo"></stringProp>
<stringProp name="SMTPSampler.receiverTo"></stringProp>
<stringProp name="SMTPSampler.receiverCC"></stringProp>
<stringProp name="SMTPSampler.receiverBCC"></stringProp>
<stringProp name="SMTPSampler.subject">Smoke Test Report</stringProp>
<stringProp name="SMTPSampler.suppressSubject">false</stringProp>
<stringProp name="SMTPSampler.include_timestamp">false</stringProp>
<stringProp name="SMTPSampler.message">Hi All,
Please find the attached Test Report with Thread Group.
</stringProp>
<stringProp name="SMTPSampler.plainBody">false</stringProp>
<stringProp name="SMTPSampler.attachFile">XXXXXPathXXX\apache-jmeter-5.1.1\bin\Smoke_Test_Results.csv</stringProp>
<stringProp name="SMTPSampler.useSSL">false</stringProp>
<stringProp name="SMTPSampler.useStartTLS">false</stringProp>
<stringProp name="SMTPSampler.trustAllCerts">false</stringProp>
<stringProp name="SMTPSampler.enforceStartTLS">false</stringProp>
<stringProp name="SMTPSampler.useLocalTrustStore">false</stringProp>
<stringProp name="SMTPSampler.trustStoreToUse"></stringProp>
<stringProp name="SMTPSampler.tlsProtocols"></stringProp>
<boolProp name="SMTPSampler.use_eml">false</boolProp>
<stringProp name="SMTPSampler.emlMessageToSend"></stringProp>
<stringProp name="SMTPSampler.useAuth">false</stringProp>
<stringProp name="SMTPSampler.password"></stringProp>
<stringProp name="SMTPSampler.username"></stringProp>
<stringProp name="SMTPSampler.messageSizeStatistics">false</stringProp>
<stringProp name="SMTPSampler.enableDebug">true</stringProp>
<collectionProp name="SMTPSampler.headerFields"/>
</SmtpSampler>
<hashTree/>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
<PostThreadGroup guiclass="PostThreadGroupGui" testclass="PostThreadGroup" testname="tearDown Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration">6</stringProp>
<stringProp name="ThreadGroup.delay">5</stringProp>
</PostThreadGroup>
<hashTree>
<TestAction guiclass="TestActionGui" testclass="TestAction" testname="Pause Action" enabled="true">
<intProp name="ActionProcessor.action">1</intProp>
<intProp name="ActionProcessor.target">0</intProp>
<stringProp name="ActionProcessor.duration">5000</stringProp>
</TestAction>
<hashTree/>
<SmtpSampler guiclass="SmtpSamplerGui" testclass="SmtpSampler" testname="Email Sampler" enabled="true">
<stringProp name="SMTPSampler.server"></stringProp>
<stringProp name="SMTPSampler.serverPort"></stringProp>
<stringProp name="SMTPSampler.mailFrom"></stringProp>
<stringProp name="SMTPSampler.replyTo"></stringProp>
<stringProp name="SMTPSampler.receiverTo"></stringProp>
<stringProp name="SMTPSampler.receiverCC"></stringProp>
<stringProp name="SMTPSampler.receiverBCC"></stringProp>
<stringProp name="SMTPSampler.subject">Smoke Test Report</stringProp>
<stringProp name="SMTPSampler.suppressSubject">false</stringProp>
<stringProp name="SMTPSampler.include_timestamp">false</stringProp>
<stringProp name="SMTPSampler.message">Hi All,
Please find the attached Test Report with tearDown.
Thanks & Regards,
</stringProp>
<stringProp name="SMTPSampler.plainBody">false</stringProp>
<stringProp name="SMTPSampler.attachFile">XXXXXPathXXX\apache-jmeter-5.1.1\bin\Smoke_Test_Results.csv</stringProp>
<stringProp name="SMTPSampler.useSSL">false</stringProp>
<stringProp name="SMTPSampler.useStartTLS">false</stringProp>
<stringProp name="SMTPSampler.trustAllCerts">false</stringProp>
<stringProp name="SMTPSampler.enforceStartTLS">false</stringProp>
<stringProp name="SMTPSampler.useLocalTrustStore">false</stringProp>
<stringProp name="SMTPSampler.trustStoreToUse"></stringProp>
<stringProp name="SMTPSampler.tlsProtocols"></stringProp>
<boolProp name="SMTPSampler.use_eml">false</boolProp>
<stringProp name="SMTPSampler.emlMessageToSend"></stringProp>
<stringProp name="SMTPSampler.useAuth">false</stringProp>
<stringProp name="SMTPSampler.password"></stringProp>
<stringProp name="SMTPSampler.username"></stringProp>
<stringProp name="SMTPSampler.messageSizeStatistics">false</stringProp>
<stringProp name="SMTPSampler.enableDebug">true</stringProp>
<collectionProp name="SMTPSampler.headerFields"/>
</SmtpSampler>
<hashTree/>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
Don't use Listeners during your JMeter load test execution, they should only be used for tests development and/or debugging. Listeners don't add any value, but only consume resources.
In particular your case View Results Tree listener opens the result file in such a way that it cannot be used by other programs, including JMeter itself.
The solution would be:
Remove all the listeners from your test plan
Add the next line to user.properties file:
jmeter.save.saveservice.autoflush=true
Run your test in command-line non-GUI mode like:
jmeter -n -t your_test.jmx -l Smoke_Test_Results.csv
That's it, upon test completion you should get the email with the results.
Make sure the scope of JMeter Elements are properly aligned.
Create 2 Thread Groups in Test Plan and select Run Thread Group Consecutively in Test Plan
First Thread Group will execute the Sampler and create the output/result file from View Result Tree. Save it to disk
Second Thread Group will execute SMTP Sampler with attachment.
Note : Attachment name can also be parameterized.
Practical example shown below:
Is it possible to use input variables in the JSON Path Extractor expression?
I tried expression $.[${someInputVariable}].name, but it didn't work.
Data format:
[
{name=a},
{name=b},
{name=c}
]
If for example ${inputVariable} is set to 1, I would like the expression to return "b".
All the examples I found so far have hardcoded search values such as $.[1].name or $..[?(#.name == 'Smith')]
First you JSON is wrong, it should be:
[{"name":"a"}, {"name":"b"},{"name":"c"}]
To extract what you want just use the __eval function:
${__eval($.[${someInputVariable}].name)}
I have taken a look at JSONPostProcessor source code:
https://github.com/apache/jmeter/blob/740dd7420af6ef576af5e6ce2646ede360748691/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
You cannot put variables inside the json path expression as those aren't going to be evaluated. By the way, if you need some help, you can read this article about JMeter json path extractor. It gives way more examples and alternatives to json path extractor.
The answer https://stackoverflow.com/a/43273205/10269029 is completely wrong: variables inside the json path expression are evaluated and can be used at least from JMeter 3.1 (I didn't check earlier versions).
It is even not necessary to add ${__eval()}. Your example doesn't work because you used wrong expression. Correct one should be $[${someInputVariable}].name. There is no dot between $ and [. The JSON was also wrong.
Here is an example jmx with your data that fills the ${NAME-VARIABLE} based on a value of the ${someInputVariable}. To check how it works just save it as jmx, run in JMeter and check variable values on the "Response data" tab of the "Debug PostProcessor" leaf in the "View Results Tree" element. :
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="3.1" jmeter="3.1 r1770033">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="someInputVariable" elementType="Argument">
<stringProp name="Argument.name">someInputVariable</stringProp>
<stringProp name="Argument.value">2</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="JSONToBeParsed" elementType="Argument">
<stringProp name="Argument.name">JSONToBeParsed</stringProp>
<stringProp name="Argument.value">[{"name":"a"},{"name":"b"},{"name":"c"}]</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</Arguments>
<hashTree/>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<longProp name="ThreadGroup.start_time">1535106337000</longProp>
<longProp name="ThreadGroup.end_time">1535106337000</longProp>
</ThreadGroup>
<hashTree>
<DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
<boolProp name="displayJMeterProperties">false</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>
<hashTree>
<JSONPostProcessor guiclass="JSONPostProcessorGui" testclass="JSONPostProcessor" testname="JSON Extractor with constant" enabled="true">
<stringProp name="JSONPostProcessor.referenceNames">NAME-CONSTANT</stringProp>
<stringProp name="JSONPostProcessor.jsonPathExprs">$[1].name</stringProp>
<stringProp name="JSONPostProcessor.match_numbers"></stringProp>
<stringProp name="Sample.scope">variable</stringProp>
<stringProp name="Scope.variable">JSONToBeParsed</stringProp>
</JSONPostProcessor>
<hashTree/>
<JSONPostProcessor guiclass="JSONPostProcessorGui" testclass="JSONPostProcessor" testname="JSON Extractor with variable" enabled="true">
<stringProp name="JSONPostProcessor.referenceNames">NAME-VARIABLE</stringProp>
<stringProp name="JSONPostProcessor.jsonPathExprs">$[${someInputVariable}].name</stringProp>
<stringProp name="JSONPostProcessor.match_numbers"></stringProp>
<stringProp name="Sample.scope">variable</stringProp>
<stringProp name="Scope.variable">JSONToBeParsed</stringProp>
</JSONPostProcessor>
<hashTree/>
<DebugPostProcessor guiclass="TestBeanGUI" testclass="DebugPostProcessor" testname="Debug PostProcessor" enabled="true">
<boolProp name="displayJMeterProperties">false</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySamplerProperties">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugPostProcessor>
<hashTree/>
</hashTree>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
<WorkBench guiclass="WorkBenchGui" testclass="WorkBench" testname="WorkBench" enabled="true">
<boolProp name="WorkBench.save">true</boolProp>
</WorkBench>
<hashTree/>
</hashTree>
</jmeterTestPlan>
I have a recorded script for my web application load testing. In one of the HTTP requests, i need to check Response message for "Completed" status text. If Status is not "Completed" then i need to run a loop 5 times to check if status is "Completed".
I know about assertion where i can check for "Completed" status but not sure how to make HTTP request wait and check in loop for 5 times before it moves to next HTTP request.
Any help would be appreciated. Thanks!
You can use Loop Controller + If Controller to achieve your requirement.
The test plan should be almost as given below.
Lets assume we have a variable completed.status = false
If condition should be "${completed.status}"=="false" to make a first call by default to get the status.
The Beanshell assertion should change the completed.status = true whenever the condition is met.
If the condition is not met - Beanshell should create another variable for the timer vars.put("wait", "3000"). Use ${wait} for the timer to wait for 3 seconds to make another call. So that timer does not delay if the status is 'completed' in the first call itself!!
Please find the attached sample test plan implementing the above logic.
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.8" jmeter="2.13 r1665067">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments">This test plan demonstrates simple usage of Dummy Sampler</stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
<stringProp name="TestPlan.comments">Thread group is set to generate 50 samples</stringProp>
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<intProp name="LoopController.loops">-1</intProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<longProp name="ThreadGroup.start_time">1300542586000</longProp>
<longProp name="ThreadGroup.end_time">1300542586000</longProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<LoopController guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">true</boolProp>
<intProp name="LoopController.loops">-1</intProp>
</LoopController>
<hashTree>
<IfController guiclass="IfControllerPanel" testclass="IfController" testname="If Controller" enabled="true">
<stringProp name="IfController.condition">"${Status}"!="20"</stringProp>
<boolProp name="IfController.evaluateAll">false</boolProp>
</IfController>
<hashTree>
<kg.apc.jmeter.samplers.DummySampler guiclass="kg.apc.jmeter.samplers.DummySamplerGui" testclass="kg.apc.jmeter.samplers.DummySampler" testname="jp#gc - Dummy Sampler" enabled="true">
<stringProp name="TestPlan.comments">Dummy Sampler set to use random Response Code
For now, Response data used as sent and received data</stringProp>
<boolProp name="SUCCESFULL">true</boolProp>
<stringProp name="RESPONSE_CODE">${__Random(1,5)}0</stringProp>
<stringProp name="RESPONSE_MESSAGE">OK</stringProp>
<stringProp name="RESPONSE_DATA">Dummy Sampler used to simulate requests and responses
without actual network activity. This helps debugging tests.
Random number:${__Random(1,1000)}
</stringProp>
<stringProp name="RESPONSE_TIME">${__Random(10,1000)}</stringProp>
<boolProp name="WAITING">true</boolProp>
<stringProp name="REQUEST_DATA">Dummy Sampler used to simulate requests and responses
without actual network activity. This helps debugging tests.</stringProp>
<stringProp name="LATENCY">${__Random(1,100)}</stringProp>
<stringProp name="CONNECT"></stringProp>
</kg.apc.jmeter.samplers.DummySampler>
<hashTree>
<BeanShellAssertion guiclass="BeanShellAssertionGui" testclass="BeanShellAssertion" testname="BeanShell Assertion" enabled="true">
<stringProp name="BeanShellAssertion.query">String S= SampleResult.getResponseCode();
if (S.equals("20"))
{
//log.info("RESPONSE"+S);
vars.put("Status","20");
}
</stringProp>
<stringProp name="BeanShellAssertion.filename"></stringProp>
<stringProp name="BeanShellAssertion.parameters"></stringProp>
<boolProp name="BeanShellAssertion.resetInterpreter">false</boolProp>
</BeanShellAssertion>
<hashTree/>
</hashTree>
<DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
<boolProp name="displayJMeterProperties">false</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>
<hashTree/>
</hashTree>
</hashTree>
<Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="Status" elementType="Argument">
<stringProp name="Argument.name">Status</stringProp>
<stringProp name="Argument.value">0</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</Arguments>
<hashTree/>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>true</xml>
<fieldNames>false</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<threadCounts>true</threadCounts>
</value>
</objProp>
<stringProp name="TestPlan.comments">Run the test and see various results of Dummy Sampler
Response Assertion marks some of results as failed</stringProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>
I need to get a glance of pages that are bottlenecks on a certain website. I was trying to find a cloud load testing tool that would start from homepage and descend 1 level into all links, but I couldn't find such tool.
Basically, what I need is to insert URL, and the script then tests with like 10 or 20 users every page that is linked from the page I inserted. That would provide me with a basic view of load times for most pages on the website.
Anyone familiar with such a tool?
Closest thing I could find was jcrawl, but it requires installing jakarta ant, server configuration and what not, and I think what I need is pretty basic and shouldn't require several hours to be put into scripting and configuration.
Thanks
You could achieve this using JMeter (JMeter is arguably the best free and open source load testing tool available). You could make one request and use a regular expression extractor to parse the response, pulling out any href values, and then have a loop which cycles through each url found.
Below is a JMeter testplan that does exactly what you want. Just copy this xml into a text file and save it as something.jmx. Open it in JMeter and change the demo hostname to YOUR OWN SITE (don't spam others, it's bad form). CTRL-R to run.
For more users (threads) or iterations (loops) just click on the Thread Group Name and change the values to what you need.
Very vague advice: Don't use more than, say, 300 threads on a single PC.
If you want to run this on 'the cloud' then rent an Amazon AWS machine, install jmeter, copy this jmx file onto it, and run it from the command line using:
$ cd /to/where/jmeter/is/apache-blah/bin/
$ ./jmeter -n -t /path/to/my/testplan.jmx -l /where/to/put/results.jtl
Demo Crawl Testplan:
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.3">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="crawl" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="HTTP Cookie Manager" enabled="true">
<collectionProp name="CookieManager.cookies"/>
<boolProp name="CookieManager.clearEachIteration">false</boolProp>
</CookieManager>
<hashTree/>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group Name" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">startnextloop</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<longProp name="ThreadGroup.start_time">1346172541000</longProp>
<longProp name="ThreadGroup.end_time">1346172541000</longProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="homepage" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">www.bbc.co.uk</stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">/</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="TestPlan.comments">enter YOUR SITE in the Server Name field</stringProp>
</HTTPSamplerProxy>
<hashTree>
<RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="urls" enabled="true">
<stringProp name="RegexExtractor.useHeaders">false</stringProp>
<stringProp name="RegexExtractor.refname">urls</stringProp>
<stringProp name="RegexExtractor.regex"><a href="http:\/\/www.bbc.co.uk([^"]+)"</stringProp>
<stringProp name="RegexExtractor.template">$1$</stringProp>
<stringProp name="RegexExtractor.default">NOTFOUND</stringProp>
<stringProp name="RegexExtractor.match_number">-1</stringProp>
</RegexExtractor>
<hashTree/>
<ConstantThroughputTimer guiclass="TestBeanGUI" testclass="ConstantThroughputTimer" testname="Constant Throughput Timer" enabled="true">
<doubleProp>
<name>throughput</name>
<value>6.0</value>
<savedValue>0.0</savedValue>
</doubleProp>
<stringProp name="calcMode">this thread only</stringProp>
<stringProp name="TestPlan.comments">Each thread makes 6 requests every minute (if it completes in time)</stringProp>
</ConstantThroughputTimer>
<hashTree/>
</hashTree>
<ForeachController guiclass="ForeachControlPanel" testclass="ForeachController" testname="ForEach Controller" enabled="true">
<stringProp name="ForeachController.inputVal">urls</stringProp>
<stringProp name="ForeachController.returnVal">url</stringProp>
<boolProp name="ForeachController.useSeparator">true</boolProp>
</ForeachController>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="foundUrl" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">www.bbc.co.uk</stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${url}</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="TestPlan.comments">enter YOUR SITE in the Server Name field</stringProp>
</HTTPSamplerProxy>
<hashTree>
<GaussianRandomTimer guiclass="GaussianRandomTimerGui" testclass="GaussianRandomTimer" testname="Gaussian Random Timer" enabled="true">
<stringProp name="ConstantTimer.delay">300</stringProp>
<stringProp name="RandomTimer.range">500.0</stringProp>
</GaussianRandomTimer>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<hostname>true</hostname>
<threadCounts>true</threadCounts>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
<ResultCollector guiclass="StatVisualizer" testclass="ResultCollector" testname="Aggregate Report" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<hostname>true</hostname>
<threadCounts>true</threadCounts>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>