I am new to Jmeter and Performance testing, I need performance testing of uploading for some 10,000 products to ecommerce website and testing the performance of website, as uploading can be done using JDBC Insert command in Jmeter. So How do I proceed?
2 Answers
Jmeter has capabilities to test DB performance , but Jmeter required JDBC driver (not only Jmeter , every programming language required JDBC driver). Below are the Steps
- Download JDBC driver and Copy to Jmeter/lib dir
- Start Jmeter by running java -jar ApacheJMeter.jar and Add "Thread Group" to "Test Plan".
Right click on "Thread Group" and from "Add" mouse over the "Config Element" and Select "JDBC Connection Configuration" and Provide the requested values in connection configuration.
Variable Name: MyPool Maximum Number of Connections: 5 Pool Timeout: 10000 Idle cleanup interval: 60000 Auto Commit: True Maximum Connection Age: 5000 Validation query: Select 1 DatabaseURL: jdbc:sqlserver://hostName:port;DatabaseName=myDataBase; JDBC Driver Class: com.microsoft.sqlserver.jdbc.SQLServerDriver User Name: Sql Server userName Password: Sql Server password
Note : Variable Name is very important , this is reference name to your JDBC connection .
3.Right click on ThreadGroup and mouse over on "Add" and Mouse over on "Config Element" and Select "CSV Data Set Config". i. Pass "Filename" (/tmp/emp.txt) (where your test data file is) and ii. In "Variable Names" field pass column names employee_Name,employee_Salary and emplyee_address
In above case my table required employee_Name,employee_Salary and emplyee_address only.
- Right click on ThreadGroup and mouse over on "Add" and Mouse over on "Sampler" and Select "JDBC Request" .
i. Variable Name: MyPool
ii.From "JDBC Request" applet , select "Update Statement" from "Query Type"
iii.In Query area enter below query "insert into employee (employee_Name,employee_Salary,emplyee_address) values (?,?,?)".
iv.To pass parametrize values in "Parameter Section': ${employee_Name},${employee_Salary},${emplyee_address}
and enter respective data types in "Parameter Types" section"
Performance Testing needs to simulate real user activity as close as possible. If you need particularly to test the performance of uploading 10k products - it can be done via JDBC Request sampler. You can quickly get Test Plan skeleton using JMeter Templates feature, from JMeter's main menu:
File -> Templates -> JDBC Load Test -> Create
But if uploading 10k products is just a pre-requisite and your main performance testing starts after you pre-populated your e-commerce site with it - it is not a good idea to limit your testing to database only and it will be better to make your test as realistic as possible, i.e. :
- Consider correct virtual users distribution (i.e. X users browse, Y users search, Z users checking something out, etc.)
- Provide reasonable think times using Timers
- Mimic Cookies, Headers and Cache