Welcome to our BLOG.
Get the latest scoop or just follow and discuss our latest studies.
Jan
27

Jmeter components

In order to have a functional testing tool which will provide us the possibility to cover the test cases for a variety of technologies, we have extended Jmeter. Below you can find some extensions created by our company:

The source code of Apache Jmeter components are available on github

Samplers

REST sampler

As there is a trend on creating Web Services based on REST as it is easier to build and consume than using SOAP-services.

When using REST, HTTP is used for calls between machines. REST uses HTTP for  CRUD operations, where CRUD stands for create/read/update/delete.

With projects which include REST-based Web services we needed the possibility to send a request with a xml payload, most of the existing testing tools do not support this, that is why we have created a rest sampler plug-in where you can define the following:

  • Method: GET, POST, PUT, DELETE
  • Base url
  • Port
  • Resource
  • Headers: if there are any headers which should be part of the request
  • Body: xml payload to be sent

                           

OAuth sampler

OAuth is an authentication protocol which provides the possibility to users to hand out tokens instead of credentials to their data hosted by a given service provider. The token grants  access for specific resources for a defined period of time.

OAuth sampler is an extended Rest sampler which in addition includes the properties needed for this authorization:

  • Consumer Key
  • Consumer Secret

These two properties together authenticate the Consumer to the Service Provider.

                       

                              

HDFS operations

HDFS (Hadoop Distributed File System) is Hadoop’s primary storage system, as users, during testing, need to possibility to copy a file from local directory or a location on the server to the hdfs directory, we have created this sampler.


You need to define the following:

  • Input file destination: local directory of the input file
  • Output directory on HDFS: location on hdfs to which you want to copy the file.

 Response shows the name of the file and the location to which it has been copied, if the file already exists it will show the message that the file already exists.

HBase samplers

To retrieve data from HBase tables, we have created:

  • HBase connection
  • HBase Scan Sampler
  • HBase RowKey Sampler

HBase connection a config element and is used to define the connection to the HBase which will be shared among the samplers in the test plan. The Connection name is the name which will be referenced in the HBase samplers, and zk host is the zookeeper host.

             

 


HBase rowkey sampler is used to retrieve a specific record by specifying the rowkey of the hbase table. You need to specify the Connection name (name which is specified in the Hbase connection config element), Table: hbase table name, Rowkey. rowkey of the specific record. The possibility exists to check the checkbox to retrieve  the most recent record, as a record might be updated and you are interested in the latest data, have this parameter turned on.

           

   


HBase scan sampler provides the possibility to retrieve one/multiple records from hbase table with specifying a filter.
Same values should be specified as in the hbase rowkey sampler, with additionally the following:
  • Start rowkey: this is optional
  • End rowkey: this is optional
  • Filter should be in the format: {column_family}:{qualifier}{= | != | < | > | <= | >=}{value}
  • Limit: limit the number of returned records

With this sampler you have the same possibility to create a variable for each row, in this way the returned values will be stored in the same matter as with a jdbc request, while by default, an xml response will be returned. If you are using the default option you can extract the values and store them by using an xpath extractor post processor. Also, you can retrieve only the latest record by checking the checkbox Retrieve most recent record.

             

Hadoop jobtracker counters  sampler

Hadoop jobtracker counters sampler can be used for multiple purposes:

  • Retrieve job counter by providing a job id: counters on job level are returned e.g. read records, processed records
  • Retrieve job counter by providing a job id and group name
  • Retrieve the job statistics by providing a job id: job statistics are returned e.g. progress of the job, url
  • Retrieve counters on job task level by providing a job id: for each task counters for the job are returned, same as option 1 but provides the counters for all tasks
  • Retrieve job task level statistics by providing a job id: for each task statistics are retuned, same as option 3 but on task level.
The following values should be specified when using this sampler, depending on the needs, which of the possibilities have you checked from the above
  • list:mapred.job.tracker: jobtracker url
  • job name/id: specifiy the job name or id, depending on if you are retrieving job counters by providing a job name or a job id.
  • group of counters name: specify the group name, this value should be specified if you are using the option (retrieve job counters by providing the job id and group name of the hadoop job).
The response is in xml format.

JMS send and receive sampler

If you are using JMS (Java Message Service) to send and receive messages between two or more clients, we have created a sampler which enables you to send and receive messages. It is incorporated into the Java request sampler, to use this sampler choose from the classname dropdown list: com.atlantbh.jmeter.plugins.jmstools.JMSUtil.

To send or receive a message the following needs to specified:

  • connection URL
  • binding url
  • direction
  • message (if we are sending a message)
Connection and Binding URL correspond to Apache QPID server and queue respectively used for either sending or receiving a message. In the message fileld, we define a message we would like to send.

A definition of whether we are a sender or a receipient is defined in direction using either SEND or RECEIVE.

In the header properties, we can add additional; separated properties that we would like to add to our message that we send. Header properties reference on the other hand is the a property where a received message is stored.

Message selector is used as a filter for received messages (ex: variable=’value’). In the QPID case, it is used as a filter on the receipient queue.

Receive timeout is the amount of time a receiver waits for a message to be received. In the case of QPID, it means a time for a message to arrive to a  specific queue. Tomeout is defined in ms. If not  provided, default value is 3000ms or 30 sec.

JSON to XML Converter

If you wish to convert a json text into xml, use the sampler JSON to XML Converter, preferable in combination with the XML Format Post Processor which is in more details specified below.

To use this sampler enter your JSON text at JSON Input, the response will be the text transformed into XML.

Post processor

XML Format Post Processor

Jmeter response for xml is not formatted, the xml format post processor provides you the possibility to have your responses formatted.
This post processor should be added at the begin of your test, which will format all your xml’s returned in your test.

Unformatted xml:

 

 

 

 

Formatted xml (when using xml format post processor)

 

 

 

In the examples above following webservice has been used: Translation Engine from WebserviceX.NET

Notes

For all samplers we propose to externalize the values into the user defined variables, especially if they are reused or executed on different environments and updates to the values are expected.
Therefore if you have to specify e.g. the namenode (hdfs://atlantbh.com:8280) we would propose to specify it in the sampler as e.g. ${NAMENODE} and to specify this property in user defined variables.

All values used in screenshots are dummy data.

How to create one of these plugins

For more details on how to create a plugin please visit following pages:

http://jmeter.apache.org/extending/jmeter_tutorial.pdf

http://www.jajakarta.org/jmeter/1.7/en/extending/index.html

http://www.jajakarta.org/jmeter/1.7/en/extending/JMeter%20Extension%20Scenario.html

Conclusion

With expectations to deliver a high quality software fast, we have extended successfully jmeter to meet our automated testing goals. Choosing an open source software has proven to be a good choice.

Please feel free to use our jmeter extensions.