Wednesday, December 19, 2012

jmeter: preparing data or recycling data with JDBC PreProcessor or JDBC PostProcessor

I was doing testing on some records, and to be able to run the test again, the status of the record must be set to specific value

To be able to do that, I thought of doing this by trigger on the DB, but unfortunately, I was working on the client DB and I didn’t have access to create triggers

So I thought of doing that from jmeter, and it worked perfectly

First I added JDBC Connection Configuration as in the image below

2012-12-19_17-35-56

Configured this as below

Variable Name: conn

(Variable name should be any name, that will be used later)

Database URL: jdbc:db2://127.0.0.1:50000/QAT_MOI_DB1T;

(Database URL is the JDBC URL for the database)

JDBC Driver class: com.ibm.db2.jcc.DB2Driver

(Make sure to place the drivers in the lib directory inside jmeter directory. you will need to restart your jmeter to for them to work correctly, in my case I was working with DB2 database, so I copied the files db2jcc.jar and db2jcc_license_cisuz.jar to the lib directory)

Username: user

Password: password

2012-12-19_17-37-27

Then I added JDBC PostProcessor at the first request in the script

2012-12-19_17-39-47

Configured it,

Variable Name: conn

(variable name is same as above in the configuration element)

Query Type: update statement

Query: update records set status=1 where id=${id};

I was able to insert parameters in the query same way I do in the requests

By this way I was able to reset the data before every cycle

You can also add JDBC PostProcessor at the last request, to do some other post processing

No comments:

Post a Comment