As I am training myself to Apache JMeter, beside testing on my Oracle environment (which include Oracle Internet Directory, Oracle Directory Service Manager, Oracle Identity and Access Management, a Database and a web application protected by SAML), I was looking for a tool to test more feature of it.

I found a website called httpbin. You can find plenty of tools to do online testing, but this one can even be self-hosted within a docker image.

In this blog, I will explain how to setup httpbin and then use one of this many features to crawl a website to, for example, looking for dead links.

httpbin

Starting httpbin is easy as running this command (and it is not the only advantage of it):

docker run -p 80:80 kennethreitz/httpbin

After pulling the image, the server runs and makes the main web page available:

It has following features:

  • HTTP Methods: Testing different HTTP verbs
  • Auth: Auth methods
  • Status codes: Generates responses with given status code
  • Request inspection: Inspect the request data
  • Response inspection: Inspect the response data like caching and headers
  • Response formats: Returns responses in different data formats
  • Dynamic data: Generates random and dynamic data
  • Cookies: Creates, reads and deletes Cookies
  • Images: Returns different image formats
  • Redirects: Returns different redirect responses
  • Anything: Returns anything that is passed to request

When you click on a feature, it will display a list of accessible URLs. You can even try it out directly from within the browser.

For example, the most basic one (GET):

It as no parameter and it will return headers sent by the browser or curl command.

This is a bit simple to use JMeter for, so let’s try another feature.

GET Links

The other feature from httpbin I wanted to try is links:

It will return is a page full of links from 0 to n-1. For example with n equal 20:

JMeter

Let’s create a new JMeter Test Plan with the items required to have something to start with:

  • A thread group
  • HTTP Request
  • Recording Controller
  • Results Tree

You can see that the path is hard coded, which means that you will need to change it if you want to test with additional links. I can add a User Parameters preprocessor and declare a variable named number_of_links. Path will then be changed to links/${number_of_links}/${number_of_links}.

Under this initial HTTP request, I will add Regular Expression Extractor to find all links from the resulting page. It will be set like this:

All matches (match No. = -1) will be stored in links variable. It will match what is between href=' and '>.

Next step is too loop on the list of links that were found, so let’s add a ForEach controller:

Input variable will be the one generated by Regular Expression Extractor and output will be used in further HTTP requests within the loop.

Talking about HTTP request, here is how it will look like:

In this one, I am using link variable in Path parameter as well as the name. This will help to recognize request more easily in the Results Tree.

Before running the test plan, here is the tree view of the full plan:

l

Once I start the test plan, Results tree will be populated:

Conclusion

JMeter is not only a load test tool. With its programming capabilities (ie. logic controller), it can do much more.

And you, what are you doing with JMeter?