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>
Related
I have a while controller in jmeter test plan within a thread group. I want to run Flow Control action when while loop is exited. But despite trying several different configs, Flow Control Action never runs. In one thread group Flow Control is used to repeatedly call API after every 10 minutes, in another thread group it is used to exit the jmeter test.
Flow Control Action is just below the while controller i.e. it is immediate sibling of while controller.
How to solve this problem?
Add a While Controller configured like:
Put the CSV Data Set Config inside the While Controller and set it up like:
Add the If Controller after the CSV Data Set Config and use the same condition as in the While Controller
${__jexl3("${variableFromCSV}" != "<EOF>",)}
Put your Sampler(s) under the If Controller
Add Flow Control Action sampler after the While Controller and configure it like:
That's it, when your CSV file ends the test will be stopped:
CSV file used in the exercise looks like:
line1
line2
line3
And the whole test plan:
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.5">
<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>
<intProp name="LoopController.loops">-1</intProp>
</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>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</ThreadGroup>
<hashTree>
<DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Sampler from Thread Group 1" enabled="true">
<boolProp name="displayJMeterProperties">false</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>
<hashTree>
<ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer" enabled="true">
<stringProp name="ConstantTimer.delay">100</stringProp>
</ConstantTimer>
<hashTree/>
</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>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</ThreadGroup>
<hashTree>
<WhileController guiclass="WhileControllerGui" testclass="WhileController" testname="While Controller" enabled="true">
<stringProp name="WhileController.condition">${__jexl3("${variableFromCSV}" != "<EOF>",)}</stringProp>
</WhileController>
<hashTree>
<CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
<stringProp name="delimiter">,</stringProp>
<stringProp name="fileEncoding"></stringProp>
<stringProp name="filename">test.csv</stringProp>
<boolProp name="ignoreFirstLine">false</boolProp>
<boolProp name="quotedData">false</boolProp>
<boolProp name="recycle">false</boolProp>
<stringProp name="shareMode">shareMode.all</stringProp>
<boolProp name="stopThread">false</boolProp>
<stringProp name="variableNames">variableFromCSV</stringProp>
</CSVDataSet>
<hashTree/>
<IfController guiclass="IfControllerPanel" testclass="IfController" testname="If Controller" enabled="true">
<stringProp name="IfController.condition">${__jexl3("${variableFromCSV}" != "<EOF>",)}</stringProp>
<boolProp name="IfController.evaluateAll">false</boolProp>
<boolProp name="IfController.useExpression">true</boolProp>
</IfController>
<hashTree>
<DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Sampler From Thread Group 2 - ${variableFromCSV}" enabled="true">
<boolProp name="displayJMeterProperties">false</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>
<hashTree>
<ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer" enabled="true">
<stringProp name="ConstantTimer.delay">500</stringProp>
</ConstantTimer>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
<DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Reached the end of the CSV file, ending the test" enabled="true">
<boolProp name="displayJMeterProperties">false</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>
<hashTree/>
<TestAction guiclass="TestActionGui" testclass="TestAction" testname="Flow Control Action" enabled="true">
<intProp name="ActionProcessor.action">0</intProp>
<intProp name="ActionProcessor.target">2</intProp>
<stringProp name="ActionProcessor.duration">0</stringProp>
</TestAction>
<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>
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
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:
I was trying to test JMS using Jmeter and was trying to run it in local, but keep getting the error:
Response message: javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.activemq.jndi.ActiveMQInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory]
I have already added the activemq-all.jar file in lib folder of jmeter, which should have resolved the issue, but it remains.
Please help me understand if I am missing something. Thanks.
Below is my jmx file content for the test plan:
<?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="JMS P2P Load Test" 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="JMSTestPlan-P2P" 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">2</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">0</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<JMSSampler guiclass="JMSSamplerGui" testclass="JMSSampler" testname="JMS Point-to-Point" enabled="true">
<stringProp name="JMSSampler.queueconnectionfactory">ConnectionFactory</stringProp>
<stringProp name="JMSSampler.SendQueue">Q.REQ</stringProp>
<stringProp name="JMSSampler.ReceiveQueue">Q.REQ</stringProp>
<intProp name="JMSSampler.communicationStyle">0</intProp>
<boolProp name="JMSSampler.isNonPersistent">false</boolProp>
<boolProp name="JMSSampler.useReqMsgIdAsCorrelId">true</boolProp>
<stringProp name="JMSSampler.timeout">2000</stringProp>
<stringProp name="JMSSampler.jmsNumberOfSamplesToAggregate"></stringProp>
<stringProp name="HTTPSamper.xml_data">Testing point to point</stringProp>
<stringProp name="JMSSampler.initialContextFactory">org.apache.activemq.jndi.ActiveMQInitialContextFactory</stringProp>
<stringProp name="JMSSampler.contextProviderUrl">tcp://localhost:61616</stringProp>
<elementProp name="JMSSampler.jndiProperties" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="queue.Q.REQ" elementType="Argument">
<stringProp name="Argument.name">queue.Q.REQ</stringProp>
<stringProp name="Argument.value">example.A</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<elementProp name="arguments" elementType="JMSProperties">
<collectionProp name="JMSProperties.properties"/>
</elementProp>
<boolProp name="JMSSampler.useResMsgIdAsCorrelId">true</boolProp>
</JMSSampler>
<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>
Your test plan looks good, most probably you forgot one little step: you need to restart JMeter in order to pick up the new .jars from its classpath
If you want quickly test a .jar without JMeter restart you can add on Test Plan level
You might also be interested in Building a JMS Testing Plan - Apache JMeter guide which covers JMeter official documentation on JMS testing gaps.
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>