When testing the performance of an application, it can be beneficial to perform your tests under a typical load. This can be difficult if you are running your application in a development environment. One way to emulate an application running under load is through the use of a load generator script. This document presents an overview of load generator support offered by the IDE.
Instead of supplying its own load generator runtime, the IDE relies on integrating third party tools. NetBeans IDE supports the Apache JMeter Load Testing Tool (homepage) to replay load testing scripts. To use the JMeter tool in the IDE, you first need to download the required plugins from the Update Center.
This document assumes you have some basic knowledge of, or programming experience with, the following technologies:
For this tutorial you need to have the following software installed on your computer:
|Software or Resource||Version Required|
|NetBeans IDE||7.0, 7.1, 7.2, 7.3|
|Java Development Kit (JDK)||Version 6 or 7|
|JMeter Kit and Load Generator plugins||download from NetBeans Update Center|
|GlassFish application server||3.x|
You can easily add support for the JMeter load generator by downloading and installing the JMeter Kit and Load Generator plugins from the NetBeans Update Center.
To download the plugins, do the following:
After installing the plugins, the category Load Testing Scripts is added to the New File wizard.
Support for the JMeter plugins is closely integrated with the IDE's profiling tool. The JMeter plugins enable you to easily create and run JMeter load testing scripts from within the IDE.
To use a load generator script, you create a script for a specific project and modify the script according to the type of project load that would be placed on a server running the application. When you run the script, the script places a load on the server that emulates the behavior of the application under typical running conditions. You can then test the performance of the application and the test results you achieve would more closely approximate the performance of the application under typical conditions.
After you download and install the plugins, a new category is created in the New File wizard. You use the New File wizard to create a load script file in your project.
To create a new load test script, do the following:
When you create a new script, the IDE places the script under the Load Generator Scripts node in the Projects window. In the Files window, you can see that the IDE saves the script in the jmeter directory. If you already have a load testing script created outside of the IDE, you can create a jmeter directory and add the script to the directory to run the script from within the IDE.
The JMeter external editor enables you to modify the script according to the needs of your application. After you have created a load testing script or added a script to your project, you can invoke the external editor by right-clicking the script in the Projects window and choosing External Edit.
For more information about editing the JMeter testing scripts, see the JMeter User Manual.
The load testing script can be started in the following ways:
In the Services window, right-click the Load Generators node and choose JMeter > Start. This action will bring up a browse dialog where you can specify the script to run.
When profiling a web application you can specify a load testing script to be run in the Select Profiling Task window. The selected script will be started right before the browser window opens.
You can stop and restart a load testing script from either the Output window or the Services window.
A JMeter tab opens in the Output window after the script has been loaded. The window displays the current state of the load generator. In the left margin of the Output window there are controls to start, stop or restart the script.
The current status of the load generator is also displayed in the Services window. You can stop and restart a script by selecting a node under the JMeter node and choosing an item from the popup menu.
This basic overview shows how to use a JMeter load testing script from within the IDE. For information on developing a load testing script for your application, see the following resources: