Skip to main content

Posts

Showing posts with the label jmeter

JMeter: getting a value from the randomly selected variable

Assuming we have a CSV Data Source with multiple rows and 10 values in every row. We are parsing and storing the values into a set of variables, named var1,var2,var3,var4,var5,var6,var7,var8,var9,var10 . Now we can use these variables in any step using ${varN} reference. But what if we want to select a variable from this list randomly? So that one iteration would use var3 , and another iteration would use var7 , selected randomly. I have used the following solution: Create additional user defined variable varTmp using "User Defined Variables" config element. Create "Random Variable" config element with variable name rnd , minimum value 1 and maximum value 10. Then use BeanShell PostProcessor that will store the value from randomly selected variable (var1-var10) into varTmp . We need to define two fields in the config element:  Parameters:  ${__V(var${rnd})} Script: vars.put("varTmp", bsh.args[0]); Now we can use ${varTmp} as a reference to the

Maven pom.xml configuration file to execute Jmeter tests and generate HTML reports

Example of a Maven pom.xml file for execution of Jmeter tests that will automatically generate HTML reports and historical trends with pretty graphs with the help of a Chronos plugin. - Install Maven and make sure it works - Create some testmyapp.jmx Jmeter script and put it into ${basedir}/tests/ directory - Unpack the latest version of Jmeter into jmeter.home directory - And finally you execute the following commands ( -Dbuild.number parameter can be your build number and you can set it dynamically in your continuous integration system, this is just for convenience and even greater coolness of the script): Enjoy amazing HTML reports generated by Chronos!

Simple fix for a common issue with Jmeter Server startup on Amazon EC2 instances

In some cases jmeter-server process cannot start because it cannot bind itself to a correct IP address, throwing "Server Failed To Start: Java.rmi.RemoteException: Cannot Start ..." exception. This issue often happens on Amazon EC2 instances. But there is a simple and straightforward solution. You just need to modify your jmeter-server shell script:

JMeter handling dynamic ViewState parameter in Seam framework

Testing applications built with Seam Java framework is possible with JMeter like any other web applications, though there are some nuances to take into account. One of them is ViewState parameter. This parameter is dynamic and it means that we cannot just leave it hardcoded in our JMeter script because it will be broken the next time you try to execute it. Why this happens? Let's dig a little deeper. Black-box testing doesn't require us to know how Seam framework works, right? Okay, in this case we only need to know how it affects our tests. As testers we need to make sure that ViewState parameter in the POST request has the same value as returned by a previous GET request. For example you have two subsequent requests: GET http://x.x.x.x:8080/some_page.seam POST http://x.x.x.x:8080/some_page.seam The first request opens a page and the second one performs an action on the page (for instance - expands some tab, tree, etc). If you analyze the response data with a list

Server-side authorization in JMeter

How to handle server-side authorization with JMeter? Well, this is probably one of the most popular questions amid the novices implementing JMeter tests. It is very straightforward to pass credentials in the POST request if this type of authorization is implemented on application side. But what if we have authorization configured on Apache web server? It is showing us a pop-up demanding user and password every time we try to access the application. However it is very easy to handle, you just need to use JMeter HTTP Authorization Manager . You can do this in two steps: Add authorization manager to your thread group: Add -> Config Element -> HTTP Authorization Manager. Set application URL, username and password fields.

How to measure the peak number of parallel users with JMeter

How to measure the peak (maximum) number of parallel users supported by your web application? It seems to be a trivial task for JMeter, however it is not so simple. The main problem is that JMeter doesn't have a built-in feature to identify how Response Time changes with amount of parallel threads. But what if we need to measure this metric in scope of performance testing? There is a nice Response Times vs Threads plugin for JMeter. However this plugin works only with the version of JMeter starting from 2.4 and it is hard to integrate it with Continuous Integration servers. And what if we have the bunch of scripts already implemented for the older 2.3.4 version or just looking for alternative solution that is easier to integrate with our Continuous Integration server? Chronos plugin for Maven would be a good match. Integration of Maven and Chronos with JMeter had been already described in this post This what I suggest to change in your JMeter script: In "Thread group&q

Jmeter and Maven Chronos plugin

There are several different approaches to integrate JMeter and Maven. We needed to use one of them to integrate our JMeter test automation suite with our continuous integration server. There are two plugins available: JMeter Maven Plugin Chronos Maven Plugin I decided to use Chronos Maven plugin. It requires explicit installation of JMeter. I've successfully configured pom.xml for running our test automation suite and reporting of the test results. You need to perform the following steps: 1. Install Apache Maven 2. Create pom.xml file and put it in a directory of your choice 3. Set your local JMeter installation directory path in jmeter.home in pom.xml file 4. Set the path to your JMeter script in pom.xml 5. Set assertions in pom.xml file if required (I didn't need this, so they are not present in the example below) 6. Create a JMeter project and copy it to test subdirectory of the directory where you stored pom.xml file. Your directory structure should