How to set jdbc connection configuration via system variables in Jmeter

2.5k views Asked by At

We have common testing machine due to the security reasons one tester should not see the other tester's jdbc configuration details in the sampler as there is a chance to misuse username and password and other details.

1.Is there any way to set system variables for different jdbc connection configurations for multiple databases such as MySQL,DB2 and Microsoft SQL. Ex : Application X uses Microsoft SQL where as application Y uses DB2 and application Z uses MySQL . Y and Z are integration layers. Variables for Database URL, JDBC Driver class,Username,Password.Please provide the example.

2.Tester need to run the #1 via command line before test starts how to do that?what are the command lines?.Please provide the example.

3.In JDBC request instead of hard coding the sql scripts how to send the SQL scripts path which may contain bunch of SQL scripts or single SQL script. .Please provide the example.

I have tried the below as showed in the screenshots, but always return results for the only sql query only, but when looked at the sampler request i see all the queries sent,but response is only for the 1st query.

enter image description here

enter image description here

enter image description here

4.For Distributed testing any special care required for the above..Please provide the example.

How can I achieve #1 ,#2 ,#3 and # 4.

enter image description here

enter image description here

enter image description here enter image description here

Below are the Latest Screenshots For #1 and # 2 below are the screenshots enter image description here

enter image description here

For #3 below are the screenshots

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Thanks, Raj

2

There are 2 answers

2
Ori Marko On

Each user can send different properties in command line (-JdbUser) or using property file.

Define each dynamic parameter as dbUser as a property ${dbUser} so each user will have different connection.

6
Dmitri T On
  1. You can access operating system Environment Variables using i.e. __groovy function like

    ${__groovy(System.getenv('DB2_PASSWORD'),)}
    
  2. Depending on your operating system, i.e:

    • for Windows family the command line would be something like: set DB2_PASSWORD=secret
    • for Unix family it would be: DB2_PASSWORD=secret && export DB2_PASSWORD
  3. The easiest way will be using Directory Listing Config Plugin

  4. As per Remote Testing User Manual Entry:

    If the test uses any data files, note that these are not sent across by the client so make sure that these are available in the appropriate directory on each server. If necessary you can define different values for properties by editing the user.properties or system.properties files on each server. These properties will be picked up when the server is started and may be used in the test plan to affect its behaviour (e.g. connecting to a different remote server). Alternatively use different content in any datafiles used by the test (e.g. if each server must use unique ids, divide these between the data files)

    JMeter slaves are absolutely independent so you will need to do the same environment variables setting, copy your JDBC Drivers and SQL scripts, make configuration changes if needed, etc. on each slave,