User3091
User3091

Reputation: 231

Add summary report results to database in JMETER

Is there any way I can add the summary report results which are generated at the end of the test in JMETER to the database ? I have created a table in in database. In this table I want to store the summary results. I am using Mysql database. How can I do this ?

Thankyou.

Upvotes: 2

Views: 6912

Answers (2)

Dmitri T
Dmitri T

Reputation: 168002

You can do it as follows:

  1. Download MySQL JDBC Driver and drop it to /lib folder of your JMeter installation
  2. Restart JMeter to pick the .jar up
  3. Add Summary Report listener to your Test Plan.
  4. Configure it to save results to some file, i.e. c:\jmeter\results.csv
  5. Add tearDown Thread Group to your Test Plan
  6. Add JDBC Connection Configuration and provide:

    • Variable Name Bound to Pool: anything meaningful, i.e. results
    • Database URL: i.e. jdbc:mysql://localhost:3306/YOUR_DATABASE_NAME_HERE
    • Database Driver Class: com.mysql.jdbc.Driver
    • Credentials
  7. Add JDBC Sampler and configure it as follows:

    • Variable Name: something which matches Variable Name in JDBC Connection Configuration, i.e. results
    • Query Type: Update Statement
    • Query: load data local infile 'c:\jmeter\results.csv' into table YOUR_TABLE_NAME_HERE fields terminated by ',' enclosed by '"' lines terminated by '\n';

This way you will be able to get results inserted automatically.

References:

Just in case if you don't know how to create a table for results with query like:

create table test (timeStamp varchar(255),elapsed varchar(255),label varchar(255),responseCode varchar(255),responseMessage varchar(255),threadName varchar(255),dataType varchar(255),success varchar(255),bytes varchar(255),grpThreads varchar(255),allThreads varchar(255),Latency varchar(255) );

See MySQL CREATE TABLE Syntax documentation for more information.

Upvotes: 8

vins
vins

Reputation: 15370

JMeter is open source. You can even create your own listener to store the results in the DB as and when a sampler is finished. Check this to get an idea.

If you want the results while running the test, I think BeanShell Listenercan help you here. basically you place the beanshell code to log the results in the DB.

If you want the results to be uploaded after the test, Summary Report listener can be configured to log the results in a CSV file. After the test - you can either upload manually to the MySQL DB, create custom script to upload programmatically.

Upvotes: 1

Related Questions