Custom Plugins for Jmeter

1. Load Testing RMI server in Jmeter : (New RMI sampler)

2. Better Graphs in Jmeter : (Custom Listener)

3. Enhanced JDBC Sampler for Jmeter

4.Maven JMeter plugin and report generation

4. SMTP Sampler Plugin in Jmeter

5.Testing EJBs with JMeter

6.JMeter Aggregator Plugin

7. Record and playing back RMI calls (RMI Serevr) – Swing Sampler in Jmeter

8.JMeter-groovy-sampler – Runs Groovy Scripts in Jmeter

9. Automate JMeter tests in Maven

10. JMeter to Nagios

Advertisements

TCP Sampler- Jmeter

The TCP Sampler opens a TCP/IP connection to the specified server. It then sends the text, and waits for a response.

You can test any Server working over TCP/IP. But In this example I have tested this sampler with a TCP server made in C#. You can download the TCP server here.

http://alokranjan.freehostia.com/codes/TCP%20Server.zip

Steps:
1. Run the TCP server on your system and create a new Test case in Jmeter. The server looks like this before any client connections.

tcp1

2. Add a TCP sampler to the thread group. Fill the fields as follows-

Server name or IP: Localhost
Check reuse connection
Port number: 13000
Timeout: 200
Check Set Nodelay
Text to send: This is the text i hav sent to tcp server

Since there is no login request for the server we leave the username and password field blank.

tcp2

3. Add a listener (View Results tree) and run the test.

tcp3
The sampler result tab gives the response code and load time. The response data shows the data sent by the Server.
You can also check the server whether it has sent the data or not.

tcp4

Generate the test report in Jmeter

Prerequisites:

1. ‘Apache-ant’ is the Pre-requisite for generating the report from the jmx file. Apache Ant is a Java-based build tool.
2. Ant-jmeter.jar

Steps:

1. Create a new variable JAVA_HOME in the environment variable and set the path for the jdk.
2. You can find the Environment variable by right clicking on the computer Icon then properties-> Advance-> environment variable. Then click on the new and give the variable name as well as path also.
3. Likewise create another variable ANT_HOME and set the path for the Apache-ant.
4. Create another variable PATH and set the path for apache-ant up to bin folder as shown in the fig. bellow.
testreport1

5. Place the ant-jmeter.jar file in side ‘Extras’ folder. Which is located in the path jakarta-jmeter-2.3.2->extras
6. Navigate to the ‘build.xml’ folder of the jmeter which is located in the path jakarta-jmeter-2.3.2->extras->build.xml.
7. Set the classpathref = “d:/jakarta-jmeter-2.3.2/extras/ant-jmeter.jar “
8. Set jmeterhome=”D:/jakarta-jmeter-2.3.2″
9. Set style=”D:/jakarta-jmeter-2.3.2/jmeter-results-detail-report${style_version}.xsl” and save it.
10. Now copy your jmx file and the build.xml file put it in a folder where ever you want to generate the report.
11. Open your command prompt and navigate to the folder where your jmx and build file is located.
12. To run a test and create the output report:
Type the command “ant -Dtest=script”(for eg. I have my test.jms file and the command is ant-Dtest=test)
It will generate an Html file. This can be open in the browser as shown in the fig. bellow.
testreport2

13. To run a test only:
Type the command “ant -Dtest=script run”
14. To run report on existing test output
Type the command “ant -Dtest=script report”

FTP Sampler – Jmeter

This controller lets you send an FTP “retrieve file” or “upload file” request to an FTP server. If you are going to send multiple requests to the same FTP server, consider using a FTP Request Defaults Configuration Element so you do not have to enter the same information for each FTP Request Generative Controller. When downloading a file, it can be stored on disk (Local File) or in the Response Data, or both.

There are many anonymous ftp sites in the web. Just search in Google as “FTP sites” or “Anonymous FTP sites” and you will get a good list of ftp sites which you can connect to. But if you are unable to connect to one of them due to firewall you can set up your own FTP Server. Download free FTP server from www.goldenftpserver.com/golden-ftp-server.zip and install it with default settings in your system.

Share a file in your server (Open shares->Add).Also share a Folder (enable full control) in your server and name it as Add.

ftp11

Select a share and click info and it will show the access path to the file.

ftp2

You can connect to this file from another system of your network (if only firewall is disabled) through command prompt (ftp 172.26.3.206).Once it is connected you can check the connections to your server.

In this example we are testing a server hosted in the same system.

1. Open a new Test plan in Jmeter and under add a thread group under it. Add two FTP Request Samplers to it. The first sampler is used foe retrieving a file from FTP server and second is for uploading a file to it.

2 .Give server name as localhost (you can also mention the IP).Remote file is given as it is shown in the server and local file is the name under which it will be stored after it gets retrieved. Select get(RETR) option. Enter Login Configurations as required (here anonymous/ anonymous).

ftp3

Similarly for second sample configure the settings. Here Local file is the file to be uploaded in FTP server (give full path of this file).Remote file is how it will be uploaded into the server (here it will be uploaded in Add folder).Select put (STOR) option.

ftp4

Now run the test and view results in Results tree listener. If the test is successful the retrieved file is stored in bin folder.

ftp5

FAILURE MESSAGES:

Response code: 550

Response message: 550 Operation not complete

This means that the path where file is to be uploaded is not modifiable. (Should enable full control)

Runtime controller

It fixes the time limit for its children to be run. If you have specified 20 seconds then the samples will be generated for 20 seconds.

Create a new test Plan. Add a thread group to the test plan. Add a Runtime Controller to the Thread group and under the controller add four HTTP Request Element sampler. Name them as 1,2, 3, 4 and put Server name: www.google.co.in and Path:/

Give the Run time as 25 seconds in the controller. Run the script and observe in View listener tree.

runtime1

In view listener tree select the first sample and under sampler result tab note the sample start time.

runtime2

Similarly get the start time of the last sample. Their difference gives the Run time we have given.

In this example:-

First sample -Sample Start: 2009-02-05 12:05:06 IST
Last sample- Sample Start: 2009-02-05 12:05:31 IST
——————————————————————–
The difference comes=00:00:25

Random Order controller

It executes the samples under it randomly at most once.

Add a Random Order Controller to the thread group.Put 4 samples under it named 1, 2, 3, and 4 . Run and see the order of execution of samples are randomly generated each time.

random-controller

Include Controller

The include controller is designed to use an external jmx file. To use it, add samples to a simple controller, then save the simple controller as a jmx file. The file can then be used in a test plan.

Open a new file.Under workbench add a Simple controller, to that add an Http request element sampler. Fill the values as follows

Name: external
Server name: www.google.co.in
Path:/

Now select the simple controller and save it as (right click-> save selection as) external.jmx.

ic1

Now open a new test file and add an HTTP request under thread group .Name it as A. Add an Include controller to the thread group. And there give the filename as external.jmx with full path (include test plan).ic2

Now run the script and see that both A and External samples have been generated.ic3