Saturday, March 30, 2013

Database Load testing using Jmeter..!!


Elements used:
    1. JDBC connection Configuration
    2. JDBC request
    3. Graph result
    4. View result tree
    5. View result in table
Detailed Steps:
To configure JDBC with Jmeter, first download the JDBC driver from this Link and then paste the driver JAR file under Jmeter/lib folder. Java Runtime Environment (JRE) version 1.6 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
1. Thread Group: -
    a. No. of threads: - 10
    b. Ramp-Up period: - 0
    c. Loop Count: - 3
2. JDBC Connection Configuration
    a. Variable name: - jdbcconnect
    b. Connection Pool Configuration
        i. Max number of connections: - 0
        ii. Pool Timeout: - 10000
        iii. Idle Cleanup interval (ms): - 60000
        iv. Auto Commit: - True
        v. Transaction Isolation: - DEFAULT
    c. Connection Validation by Pool
        i. Keep-Alive: - True
        ii. Max Connection age (ms): - 5000
        iii. Validation Query: - Select 1
    d. Database Connection Configuration
        i. Database URL: - jdbc:sqlserver://192.168.0.209\sqlexpress;DatabaseName="(name of database)";
        ii. JDBC Driver class: - com.microsoft.sqlserver.jdbc.SQLServerDriver
        iii. Username: - " "
        iv. Password: - ***********
3. JDBC Request
    a. Variable name: - jdbcconnect
    b. Query type with table name.
4. Listener
    a. Table
    b. Tree

Introduction to Jmeter..!!


Apache JMeter is a 100% pure Java desktop application designed to load test client/server software (such as a web application ). JMeter can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types. You can also use Jmeter for regression testing by introducing assertions in test script.


Now let's perform a simple load test on web application...


Firstly, what we have to do is setup Jmeter environment on our system.

Jmeter is a Java application, so a JRE or SDK first needs to be installed with a JAVA_HOME environment variable.
Setting Path on Windows
Windows 7
1. Select Computer from the Start menu
2. Choose System Properties from the context menu
3. Click Advanced system settings > Advanced tab
4. Click on Environment Variables, under System Variables, find PATH, and click on it.
5. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
6. Reopen Command prompt window, and run your java code.
Windows XP
1. Start -> Control Panel -> System -> Advanced
2. Click on Environment Variables, under System Variables, find PATH, and click on it.
3. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
4. Close the window.
5. Reopen Command prompt window, and run your java code.
Windows Vista
1. Right click My Computer icon
2. Choose Properties from the context menu
3. Click Advanced tab (Advanced system settings link in Vista)
4. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
5. Reopen Command prompt window, and run your java code.


Jmeter can be downloaded from this link:


• Download Jmeter, and install by unzipping the .zip or .tgz file in any directory.
• Go to jakarta-jmeter Directory (Directory in which the .zip of .tgz file is unzipped)
• Type ./bin/JMeter on command prompt (for UNIX) or Run bin/jmeter.bat (for Windows)
• JMeter is ready to test application.
When you run JMeter.bat file in bin directory of jakarta-jmeter Directory, you will see the following JMeter Screen.
The user interface has two panes. The left pane displays the elements used in our testing. Initially, there are the Root and two sub-elements, Test Plan and Workbench.
Test Plan: A test plan describes a series of steps JMeter will execute when run. A complete test plan will consist of one or more Thread Groups, logic controllers, sample generating controllers, listeners, timers, assertions, and configuration elements.
Workbench: Workbench is place where we store test elements which are saved and used in later stages. It has two elements which are HTTP proxy server and HTTP mirror server. Http proxy server is used for recording purpose. To use it right click on workbench then select Add --> Non-Test Elements --> HTTP Proxy Server.
This is how we install and run JMeter in windows.