Vincenzo Marrazzo is a Test Automation Specialist. He has 10 years of experience in various context both with open-source technologies and commercial ones. His primary activities are automation testing and performance testing. Vincenzo currently works at Altran Italia.

Become a JMeter and Continuous Testing Pro

Start Learning
Slack

Test Your Website Performance NOW!

arrow Please enter a URL with http(s)
Oct 09 2017

How to Load Test a Shopping Scenario With Users Dropping Out

The Throughput Controller allows the user to control how often samplers are executed in a scenario. This is useful when you need to mix different test cases into the same load test, for example if you want to simulate a shopping scenario where users drop out before check out. 

 

The Apache JMeter™ Throughput Controller can be configured in two modes:

  • Percent Execution - Limits the iteration to be a certain % of the total iteration (so no absolute information on how many iterations are really performed)
  • Total Executions - Limits the iteration to a fixed number (similarly to “Loop Count” field into Thread Group)

 

This blog post will show how to create a JMeter scenario for two user profiles: some who complete the check-out procedure, and some who drop out before. The load will be split 70%-30%. On the internet there are various resources for practicing test automation, including sample e-commerce sites like http://www.demoblaze.com/index.html#.

 

Let’s get started.
 

1. Add a Thread Group to your Test Plan.

 

Add -> Threads -> Thread Group

 

Select the “Thread Group” node and:

  • Fill the “Number of Threads” field with 100
  • Fill the “Ramp-Up Period” field with 10
  • Check the “Forever” flag on the “Loop Count” row
  • Check the “Scheduler” flag
  • Fill the “Duration” field with 60

 

using the throughput controller in jmeter

 

During test execution, 100 threads will all start within 10 seconds. Each test will continue to iterate according to the below described scenario, for 60 seconds. Deliberating how many users to test? Read this blog post “8 Tips to Decide the Number of Concurrent Users for Your Test”.

 

2. Add two Throughput Controllers

 

Right Click on Thread Group -> Logic Controller -> Throughput Controller

 

load testing for black friday

 

Rename and configure Throughput Controller nodes. We will use the “Percent Execution” mode.

 

First node:

  • Name - Users complete check-out
  • Choose the “Percent Executions” option in the menu
  • Throughput field - 70.0

 

load testing changing number of users, jmeter

 

Second node:

  • Name - Users dropping out
  • Choose the “Percent Executions” option in the menu
  • Throughput field - 30.0

 

jmeter, users,checkout, open source

 

3. Now, add a Constant Throughput Timer as a child element to the main “Thread Group” node. This node defines how many iterations will be performed during the time unit. Consequently, these iterations are allocated according to the percentage base in the Throughput Controllers.

 

Right click on Thread Group -> Add -> Timer -> Constant Throughput Timer

 

jmeter, load testing users dropping out of the scenario

 

  • Fill the “Target throughput” field with “600”
  • In the “Calculate Throughput based on” menu select “all active threads in current thread group”

 

4. Now let’s add user actions to our Throughput Controllers. This is done through HTTP requests that simulate user actions:

 

In the “Users complete check-out” controller, the HTTP requests simulate:

  • User login
  • Adding an item to the shopping cart
  • Check-out and payment

 

In the “Users dropping out” controller, HTTP requests simulate:

  • User login
  • Adding an item to the shopping cart
  • The user abandoning the session without completing check-out

 

There are three ways to obtain these HTTP requests sample:

  • Create the test manually
  • Using the BlazeMeter Chrome Recorder extension. With this extension, which is completely free, you can:
    • Record a user session into your browser without JMeter
    • Download the jmx script locally
    • Cut/paste the necessary step into the final script/controller
  • Directly with JMeter using “HTTP(S) Test Script Recorder”. See more details at this link.

 

Whichever way you choose, the complete script should look similar to the picture below.

 

jmeter, load testing, throughput controller

 

5. A test scenario like a HTTP web application needs additional components to handle all configuration aspects. There are three kinds of “Config Element” to add to your test plan:

 

changing the number of users in a load test

 

6. Now, let’s assert the correctness of each iteration. There are many ways to assert that a sample returned an expected or unexpected response. Read more from this blog post “How to Use JMeter Assertions in Three Easy Steps.”

 

When deciding what and how to assert, take the following considerations into account:

 

  • When a user completes check-out:
    • Do the users receive a specific message in HTML?
    • Do the users receive a unique id in a specific format?
    • Do back-end services track DB order information?

 

  • When a user drops out before check-out:
    • Do the users receive any information in HTML?
    • Which information can be tracked in back-end services?

 

7. Now let’s run the test. Let’s add the Aggregate Report listener, so we can see how the Throughput Controllers divided up the users. Change the names and add the heading “1” into one of the controllers, to be able to track it (e.g  - 115 /WebTours/index.htm & 15 /WebTours/index.htm).

 

jmeter, changing users, load testing

 

After execution, the “Aggregate Report” will show each sample. Those with the heading “1” will consist of 30% of the samples, and those without will be 70%. Now, you can monitor different KPIs like error percentage, throughput, and so on.

 

load testing users black friday jmeter

 

That’s it! You now know how to use the Throughput Controller to adjust your test scenario. To learn more JMeter actions, take our free online courses at the JMeter academy.

 

Get ready for Black Friday 2017. Start load testing now and ensure your site or app can handle high traffic this Black Friday.

 

Click here to subscribe to our newsletter.

 

To try out BlazeMeter, request a demo, or put your URL or JMX file in the box below and your test will start in minutes.

     
arrow Please enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!