Book Image

Master Apache JMeter - From Load Testing to DevOps

By : Antonio Gomes Rodrigues, Bruno Demion (Milamber), Philippe Mouawad
Book Image

Master Apache JMeter - From Load Testing to DevOps

By: Antonio Gomes Rodrigues, Bruno Demion (Milamber), Philippe Mouawad

Overview of this book

Load tests help identify the maximum number of requests a software system can handle. One popular open source tool for load testing is JMeter. By leveraging the features and capabilities of JMeter, you can perform extensive load testing and fix issues in your application before they become problematic. This book is written by JMeter developers and begins by discussing the whole process, including recording a script, setting it up, and launching it, enabling you to almost immediately start load testing. You'll learn the best practices that you must follow while designing test cases. You'll also explore the different protocols offered by JMeter through various real-world examples. Finally, you'll see how to integrate JMeter into the DevOps approach and create professional reports. You'll discover ways to use the eco-system of JMeter to integrate new protocols, enrich its monitoring, and leverage its power through the use of the cloud. By the end of this book, you'll know all that's needed to perform comprehensive load testing on your applications by using all the best practices and features of JMeter.
Table of Contents (14 chapters)

Finalizing a Script

We'll see in this section some nice tips to save time during scripting and to not end up with too-complex scripts due to a lack of knowledge of JMeter features.

Changing the Name of a Transaction According to a Parameter

In some cases, it is useful to be able to change the name of a transaction during runtime and not during scripting, such as when:

  • Comparing the performance of the same query with different parameters
  • Numerating the request to validate that none are lost
  • Changing the name according to the answer

As often, several solutions are available:

  • Use a value from a CSV file field using CSV Data Set Config.
  • Use a JMeter function such as __counter, __RandomDate, or __Random.
  • Use JSR223 Listener and the prev.setSampleLabel function; for example, to change the name to VerySlow for responses that take more than 400ms:

if (prev.getTime() > 400) {

    prev.setSampleLabel("VerySlow")

}

Sharing an Object between...