Subscribe to our RSS here.
JMeter Variables
Where are we?
On the last post we created the foundation for investigating the performance of the orderbook service of Mercado Bitcoin, a Brazilian cryptocurrency exchange.
You can download the JMeter suite here.
For this post we will start from a more developed suite.
In a summary we have:
-
Two Thread Groups: One for the cryptocurrency Litecoin (LTC) and one for Bitcoin (BTC);
-
For each Thread Group we will hit two endpoints:
- Orderbook: the list of asks and the list of bids
- Trades: A list of all completed trades, with information such as price, amount, and date.
You can download the updated suite here.
What is the problem?
If you exam closely the new suite we will see that many strings are duplicated in each HTTP Request and Thead Group:
- The Thread Group configuration values
- The server name and the HTTP protocol
- The cryptocurrency name
- The path (endpoint) we want to hit
As with any software, duplication is always a code smell: It leads to more effort to implement changes, increases the chance of error, and makes things harder to understand.
Let’s solve this using JMeter Variables!
Variables
JMeter allows creation of variables at the Test Plan level.
In the Test Plan tab we can see an area for the definition of variables
After the definition we can use the variables through the ${variable_name} notation.
On the Thread Groups:
And on the HTTP requests:
And on run-time, JMeter will translate the placeholder notation with the proper value:
There you have it! The basic configuration values are defined only once, making our suite easy to understand and change.
You can see all posts of this JMeter series here
Leave a comment