In a related post, we discussed how to parameterize your JMeter tests from a CSV
source file. In this article we will take things a step further, and show you how to introduce variability into your requests by pulling from your CSV
source file to have random data in your JMeter performance tests.
Random CSV Data Set Config Plugin
Building upon the functionality of the CSV Data Set Config plugin that ships with JMeter, there is an additional Random CSV Data Set Config plugin that is available to install from the Plugin Manager. You can access the Plugin Manager from main “Options” menu directly within the JMeter GUI:
To find the plugin you may search for “Random CSV” under the “Available Plugins” tab, which should present options to install the Random CSV Data Set component. You may have to restart JMeter after this is installed:
Using a CSV Data Source for Random Data in JMeter Performance Tests
For the purposes of this example we have prepared a basic CSV
data file. This is to be used for a hypothetical case of automatically filling out a website feedback form which requires first and last name, an email address, a phone number, and a brief comment. The structure of our data file is as follows:
The options for setting up the Random CSV Data Set Config element are similar to those of the ordinary CSV Data Set Config component. One important difference that is pertinent to our example is setting the “Random order” checkbox. This will change the reading behavior from sequential, to returning random rows from within the *.CSV
file. Here is an example of how we will configure this element:
A useful feature of this component is the built-in ability to test reading of CSV
data into local variables before running our test. This is useful in eliminating the trial-and-error practice of setting up a test otherwise. In addition to this we can also test the randomization of results read from the CSV
file. Repeatedly clicking on the “Test CSV Reading” button will load a different, randomly selected row into the results area as shown below:
Once you have added the Random CSV Data Set Config element to your test plan, your samplers will be able to access your CSV
data fields using the standard ${...}
variable convention as explained in our previous post.
Combine Randomization with Split Feature
You can further increase the variability of your load tests by combining CSV
parameter randomization as described above with the “Split” functionality when attaching your data source file. This will equally divide your CSV
file amongst your load generator servers, randomly selecting a subset of your data for each request. To utilize this feature, simply check the “Split” option when uploading your *.CSV
file:
Did you know that RedLine13 offers a full-feature free trial? Sign up now and start testing today!