JMeter WebDriver Subsample labels not appearing in results - jmeter

When using the WebDriver plugin for JMeter and using subsamples the labels that are set during the test do not appear in the results jtl file (and therefore the results tree/aggregate report etc.
WebDriver code (name = TestSampler):
WDS.sampleResult.subSampleStart('First SubSample')
...
WDS.sampleResult.subSampleEnd(true)
WDS.sampleResult.subSampleStart('Second SubSample')
...
WDS.sampleResult.subSampleEnd(true)
Desired outcome:
result.jtl file:
...
1603546255925,1000,First SubSample,,,ThreadGroup 1-1,text,true,,0,0,1,1,null,0,0,0
1603546257658,1000,Second SubSample,,,ThreadGroup 1-1,text,true,,0,0,1,1,null,0,0,0
Actual outcome:
result.jtl file:
...
1603546255925,1000,TestSampler-0,,,ThreadGroup 1-1,text,true,,0,0,1,1,null,0,0,0
1603546257658,1000,TestSampler-1,,,ThreadGroup 1-1,text,true,,0,0,1,1,null,0,0,0
note that the only difference is that the value passed to the ...subSampleStart(label) function appears in the result file instead of an indexed version of the sampler name.

Add the next line to user.properties file:
subresults.disable_renaming=true
Restart JMeter to pick the property up
Next time you will run your test you will see expected names
For GUI mode you can tick Functional Test Mode box on Test Plan level:
More information:
JMeter Bug 62550 - Modify SubResult Naming Policy
Apache JMeter Properties Customization Guide
Configuring JMeter

Related

JMeterLibException: 'Incorrect log file format'

JMeter 2.12
python 2.7.18
I'm getting JMeterLibException: 'Incorrect log file format' for the below code using robot framework
${logPath}= set variable C:/Tests/output1.log
run jmeter C:/Tests/apache-jmeter-5.4.1/bin/jmeter.bat C:/Tests/100users.jmx ${logPath}
${result} analyse jtl convert ${logPath}
log ${result}
FOR ${ELEMENT} IN #{result}
log dictionary ${ELEMENT}
It seems that your "JMeterLib" (whatever it is) expects some specific JMeter .jtl file format and JMeter 5.4.1 default settings are not compatible with it.
Unfortunately we cannot really help you without seeing this "JMeterLib" output or source code so I can only provide a generic piece of advice:
JMeter .jtl file output is controllable via special set of properties responsible for Results file configuration, once you determine what exact metrics does your "JMeterLib" expect you can amend JMeter's configuration accordingly in order to make it compatible with your 3rd-party software assumptions.
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide
You should use jtl file extension instead of log
${logPath}=set variableD:/Tests/output1.jtl

JMeter script to read values from JMeter properties file

Can you please help in reading values from below files using JMeter Script or Beanshell script.
jmeter.properties
user.properties
jmeter.bat
What do you mean by "reading"? JMeter loads the properties defined in jmeter.properties and user.properties during its startup and you can get any value using __P() function
If you need to do this programmatically - here is example Groovy code (can be used in any of JSR223 Test Elements)
def jmeter_properties = new Properties()
jmeter_properties.load(new FileInputStream(new File('jmeter.properties')))
jmeter_properties.each { property ->
log.info(property.getValue())
}
jmeter.bat is a wrapper Windows batch file, it doesn't contain any JMeter Properties definitions

Getting error while running merged jtl files

I am trying to generate the report in JMeter by merging .jtl files content getting below error -
File '/home/ajij/jmeter_tests_cli/merged.jtl' does not contain the field names header, ensure the jmeter.save.saveservice.* properties are the same as when the CSV file was created or the file may be read incorrectly when generating report
An error occurred: Error while processing samples: Consumer failed with message :Could not parse timeStamp <timeStamp> using format defined by property jmeter.save.saveservice.timestamp_format=ms on sample timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
Note -
If i run 2 independent jtl files then will get run successfully
Command to execute JTL file -
../Documents/apache-jmeter-5.2/bin/jmeter.sh -g merged.jtl -o ./folder
JTL File content -
https://drive.google.com/file/d/1j6kZ7mUj0IbT6hWS0KR3BsZVK4t6wQzj/view?usp=sharing
Quick Help will be appreciated !!!
As per JMeter's documentation:
The dashboard generator is a modular extension of JMeter. Its default behavior is to read and process samples from CSV files to generate HTML files containing graph views. It can generate the report at end of a load test or on demand.
As of current latest stable version JMeter 5.3 generating dashboards from .jtl files in XML format is not supported so either re-run your test with the following JMeter property defined:
jmeter.save.saveservice.output_format=csv
or review your way of "merging" the result files, if it supports CSV output format - go for it.
Did you try removing the XML tags? I haven't tested yet using the CSV you shared, but it might be enough removing the XML tags and merging "manually" the files, I'd merge the files by removing the second headers and the XML tags, remember JMeter process the requests by time so it will order the requests by timestamp

Unable to pass arguments to a .jmx files from build.gradle file through jmRun

i am facing multiple problems with my .jmx file.
I am working with bzm-concurrency thread group
1) it is not recognising the standard format of passing the user defined values
like: ${__P(SERVER_NAME,localhost)} instead of passing "localhost" to my script it is appending "${__P(SERVER_NAME,localhost)}" to my url.
After passing only the value i.e (localhost) it is working fine
2) Also, iam running my jmeter script from build.gradle file and iam unable to pass the url and other details from them
|SERVER_NAME|${__P(SERVER_NAME,localhost)}| --> this code is not working
|SERVER_NAME|localhost| --> this code is working fine
jmeter {
jmTestFiles = [file("src/main/Jmetrscript.jmx")]
jmSystemPropertiesFiles= [file(path of my properties file)] //to add additional system properties
jmUserProperties = ["SERVER_NAME ="+System.getProperty('SERVER_NAME','localhost'), "SERVER_PORT ="+System.getProperty('SERVER_PORT','9080') ]
enableExtendedReports = true //produce Graphical and CSV reports
}
when i run this using gradlew jmRun -DSERVER_NAME=localhost it is not passing the value.
As per JMeter Gradle Plugin - Advanced Usage
Supported JMeter commandline arguments (see full list here):
-p, --propfile {argument}, the jmeter property file to use
-q, --addprop {argument}, additional property file(s)
-t, --testfile {argument}, the jmeter test(.jmx) file to run
-J, --jmeterproperty {argument}={value}, Define additional JMeter properties
-D, --systemproperty {argument}={value}, Define additional System properties
-S, --systemPropertyFile {filename}, a property file to be added as System properties
-r, --runremote (non-GUI only), Start remote servers (as defined by the jmeter property remote_hosts)
-G, --globalproperty (argument)[=(value)], Define Global properties (sent to servers), e.g. -Gport=123, or -Gglobal.properties
So you should pass JMeter Properties via -J command-line argument like:
jmRun -JSERVER_NAME=localhost etc
References:
Overriding Properties Via The Command Line
Apache JMeter Properties Customization Guide

Jmeter: How to set jmeter.services.FileServe default value?

While executing the test through JMeter I found in Jmeter log:
2017/12/21 02:37:06 INFO - jmeter.services.FileServer: Default base='/u02/project/gold'
2017/12/21 02:37:06 INFO - jmeter.services.FileServer: Set new base='/home/project/gold/JMX'
I am executing the test from /u02/project/gold/apache-jmeter-3.1 but do not know from where JMeter set new base value which is another directory '/home/project/gold/JMX'? Please let me know how I can restrict jmeter to set new base value?
As per Apache JMeter version 3.3 FileServer class source code:
private static final String DEFAULT_BASE = System.getProperty("user.dir");// $NON-NLS-1$
So it should take user.dir (User working directory) Java System Property value as a default
If you need to override this to have another value you can set it by adding the next line to system.properties file (lives in "bin" folder of your JMeter installation)
user.dir=/some/custom/path
JMeter restart will be required to pick the property up.
Another option is setting the property value via -D command-line argument like:
jmeter -Duser.dir=/some/custom/path -n -t test.jmx -l result.jtl
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide
Overriding Properties Via The Command Line

Resources