Showing posts with label JMeter. Show all posts
Showing posts with label JMeter. Show all posts

Monday, November 22, 2010

JMeter : IOException: Exceeded maximum number of redirects: 5

Using the JMeter proxy server to record and playback some logins to a site and got this error.

Mr. Google to the rescue and the trick is to modify the jmeter.properties file in the JMeter bin directory.


# Maximum redirects to follow in a single sequence (default 5)
httpsampler.max_redirects=20


Modify the above line in that file to increase the maximum from the default of 5. In my case, I found 20 to be adequate.

You need some kind of upper limit because otherwise the trace could just get stuck in a loop.

Note that you have to restart JMeter after making this change.

Enjoy!

Wednesday, October 20, 2010

JMeter : Reading variables from a file

Done a lot of load testing with JMeter.

Quite often, I need to try load testing for lots of user logins. To do this you can't hard code the value in the form - you have to somehow read it from a file.

Enter JMeter's String From File

"The StringFromFile function can be used to read strings from a text file. This is useful for running tests that require lots of variable data. For example when testing a banking application, 100s or 1000s of different account numbers might be required."

For a field called userId, enter something like the following in the Value column:

${__StringFromFile(x:\Path to csv file.csv,userId,,)}


It would look something like this:




The csv file is a simple one column list of user Ids.

Enjoy!

Thursday, October 14, 2010

JMeter : Setting up a HTTP Proxy to capture traffic

You can build up a JMeter test plan yourself but it's much easier to set up a proxy and let JMeter do all the grunt work for you.

There are some JMeter proxy Step-by-step instructions here.

If your environment has a proxy you need to tell JMeter about it via the command line e.g.

jakarta-jmeter-2.4\bin>jmeter -H yourProxy.co.nz -P yourProxyPort

The basic idea is that you change your browser settings to point to the JMeter HTTP Proxy and then the JMeter proxy forwards the packets to the real proxy configured in the command line.

To setup the JMeter proxy after you have started up JMeter, right click:

WorkBench

Add / Non-Test Elements / HTTP Proxy Server



Choose a spare port (in this case 9090) and configure in the Port box.

Now you need to change your browser settings. Use

Tools / Internet Options / Connections / LAN Settings / Proxy Server

Set the proxy server to localhost (or 127.0.0.1) and the port number to 9090.

In JMeter, right click Test Plan / Add / Threads / Thread Group.

Doing this forces the proxy to capture the traffic inside of the plan.

Now click on HTTP Proxy Server and click Start at the bottom.

Now open your browser and browse to the URL you want to test.

In JMeter, you should see something like:



Note that it's a good idea to add a HTTP Cookie Manager as well as this enables cookies to pass between pages.

Enjoy!