I am trying to get the datatbase url, password and username from a csv file in the JDBC configuration. The post JDBC requests and query DB.
The main moto is not to touch the .jmx test plan and provide values externally.
How can I do this?
JDBC Connection Configuration is a configuration element therefore it is being executed before any JMeter Variables are initialised.
So the easiest option would be setting url and credentials using __P() function like:
Once done you will be able either to set the properties value in user.properties file (lives in "bin" folder of your JMeter installation) like:
url=jdbc:mysql://localhost:3306/dbname
username=root
password=secret
Or define them through -J command-line option:
jmeter -Jurl=jdbc:mysql://localhost:3306/dbname -Jusername=root -Jpassword=secret -n -t test.jmx -l result.jtl
More information:
Configuring JMeter
Overriding Properties Via The Command Line
Apache JMeter Properties Customization Guide
If you have to use the CSV file you can go for __CSVRead() function, in this case you can get first entry in the csv file as ${__CSVRead(test.csv,0)}, second as ${__CSVRead(test.csv,1)}, etc.
Related
I am making Db connections in my Jmeter script using "JDBC Connection Configuration"(Using both Oracle and MySQL DB), but the DB Password is Visible in the Jmeter Console and in Log File and this a serious security issue as far as my client is concerned
Is there any way to encrypt the password before if password get logged into the Jmeter console/Logfile ?
Don't keep sensitive information like passwords in the .jmx test scripts, if you need to supply a password for a JDBC Connection - use __P() function like:
${__P(password,)}
Once done you can set the password by passing it via -J command-line argument like:
jmeter -Jpassword=my-secret-password -n -t test.jmx -l result.jtl
In this case you will get only ${__P(password,)} in logs even if you have the most verbose level so it will be more or less secure.
More information: Apache JMeter Properties Customization Guide
I would like to pass jtl file name over command line arguments. commanline lookslike this:
jmeter -J JTL=%JTLFILE% -t Metasuche.jmx
In Script I am using ${__P(JTL)}. If i am starting jmeter like this:
jmeter -J JTL=%JTLFILE% -t Metasuche.jmx
and
jmeter -J JTL=%JTLFILE% -t Metasuche.jmx -n
It works as expected and jtl file is created in a file as passed in arguments. But if I am starts Jmeter with:
jmeter -J JTL=%JTLFILE% -t Metasuche.jmx and -n -r
then my JTL values are landing in a new File ${__P(JTL)} in current directory.
How should I tell jmeter to use command line arguments in local and remote executions?
If you want to pass the properties to the remove machines via command-line argument you should be using -G instead of -J
As per Overriding Properties Via The Command Line
-G[prop_name]=[value]
defines a JMeter property to be sent to all remote servers.
-G[propertyfile]
defines a file containing JMeter properties to be sent to all remote servers.
More information:
Full list of command-line options
How to Perform Distributed Testing in JMeter
When I am running a simple standalone JMeter script using command line as below
jmeter -n -t your_script.jmx
This generates a CSV file which contains all the data related to the execution.
However, when the same JMeter file executed for a distributed load testing with multiple JMeter Server IP addresses which will simulate the given number of users and runs on the target server, I am not able to get the jmeter.csvfile Generated(But the command runs successfully).
The command I have used for distributed execution is
jmeter -n -t script.jmx -R IP_address1, IP_address2,...
Now, I should get a consolidated jmeter.csv file from this execution. But, I am not getting one.
Same is the case with JMeter API DistributedRunner Class- We are not getting the consolidated jmeter.csv file and reports.
This command:
jmeter -n -t your_script.jmx
does not generate any CSV file, you need to add -l command-line argument and provide desired results file location like:
jmeter -n -t your_script.jmx -l jmeter.csv
The same applies for distributed testing:
jmeter -n -t script.jmx -R IP_address1, IP_address2 -l jmeter.csv
If you provide -l command-line argument but still not getting any results most probably your script execution fails on remote slaves somewhere somehow. Follow the below checklist in order to get to the bottom of the script failure:
Inspect jmeter.log file on master machine and jmeter-server.log on the remote slaves, if something goes wrong - most probably you will find the cause in log files
Make sure that JRE version is the same on master and the slaves
Make sure that JMeter version is the same on master and the slaves, it's recommended to use the latest JMeter version where possible
If the test relies on any of the JMeter Plugins - make to install them all onto all slave machines. The plugins can be installed using JMeter Plugins Manager
If your test is using CSV Data Set Config - you will need to copy the CSV file to all slaves manually
If your test needs any additional JMeter Properties you will need to supply the properties via -J or -D command-line arguments on all the machines or via -G command-line arugment on the master
We have a highly parameterized JMeter job, and we define all those parameters (things like number of users and length of simulation) in a Java properties file that we specify on the command line
jmeter -n -t myscript.jmx -p 500users.props
but when we tried to distribute this over several machines:
jmeter -n -t myscript.jmx -p 500users.props -Rmachine1,machine2,machine3
those machines did not see the value specified in the properties file. How do you configure your JMeter tests in a distributed scenario?
Evidently you need to use the -G flag to get things to other servers.
jmeter -n -t myscript.jmx -G500users.props -Rmachine1,machine2,machine3
I'm running JMeter through jenkins for performance testing using the command line options. I already write to one jtl file when I do the command, such as:
java -jar path to Jmeter -n -t jmx file -l log file
I would like to also put the results into another log file stored in another location, but I can't get it to work by putting another path after the -l command or putting in a second -l. Is there anyway to do this simply?
Thanks
Check these options. you should use the option '-j'. It works fine for me.
-n This specifies JMeter is to run in non-gui mode
-t [name of JMX file that contains the Test Plan].
-l [name of JTL file to log sample results to].
-j [name of JMeter run log file].
-r Run the test in the servers specified by the JMeter property "remote_hosts"
-R [list of remote servers] Run the test in the specified remote servers