Jmeter uses CSV Data Set Config parameterized data to execute multiple loops without repetition (to achieve multiple user lottery draws)

Use CSV Data Set Config in Jmeter to parameterize non-repetitive data and execute N times

 

Require:

Today, thousands of pieces of data are to be tested, and each piece of data needs to be executed multiple times (simulating multiple draws for multiple users)

1. There are 175 user IDs and no sorting rules;

2. 175 users are required to request, and each user executes 3 times;

(Due to the poor performance of your own notebook, you can only use a small number of examples, and you can increase the number of users and the number of cycles by yourself)

design:

We write 175 data in Notepad through CSV Data Set Config, and then call the text directly;

Then reference the value directly in the http request;

See the whole picture below:

 

one. prepare txt document

1. Parameter description

Write the data to be called in the txt document. If the data has only one column, write one column, that is: 1 parameter;

Two columns are two parameters, three columns are three parameters, and the parameters in the document must be separated by commas;

(Here is an example of one parameter. If the following description is unclear, you can leave a message at any time, and I will reply)

2.txt The file name is gld.txt; the values ​​in it are as follows:

two. Start jmeter.bat to enter the jmeter interface

1. Add a thread group

Right click on "Test Plan" - Add - Threads - Thread Group;

 

Note: If it is English jmeter, it can be changed through "Options" - select language - Chinese;

2. Add and configure CSV Data Set Config

(1) Add:

Right-click "Thread Group" - Add - Configuration Element - CSV Data Set Config;

(2) Configure CSV Data SetConfig parameter information

Filename: The specified document path and name; you can right-click on the document - properties, find the path of the document, and pay attention to write the document name and suffix;

File enconding: encoding format, if there is Chinese in the txt document, the line should be written in utf-8;

Variable Names: define parameters; there are several columns in the txt document to define several parameters; see parameters separated by English commas; write wxid directly, and call it directly with ${wxid} when other modules are used;

Recycle on EOF: Whether to read parameters cyclically at the end of the file;

Stop thread on EOF: whether to stop the thread when the end of the file is reached;

(3) If: If you want to read all the data in the document without repetition, then set it to:

Recycle on EOF:False;

Stop thread on EOF:True;

3. Add http request and configure

(1) Add: Right-click "Thread Group"-Add-Sample-HTTP Request;

(2) Configure http request

4. Modify the thread group configuration

Because we only wrote one http request, click to run will only run once. We want to execute all the lines in the txt document once, so we need to modify the number of threads; currently there are 175 lines in the txt, so we have the number of threads in the thread group. set to 175;

5. Monitor results: Add "View Results Tree" and "Aggregate Report"

View the result tree: you can see the success and failure of each request execution;

Aggregate report: You can see the total number of executions and failures, etc.;

 

6. Click Run to view the results

Click the green arrow to run and see the results

(1) In "View Result Tree", you can see that the parameter request is the value:

(2) In the "aggregation report", you can see whether all threads have completed execution

The above results only execute all the data in the txt document once. If we want to execute it multiple times, then we have to repeat the http request;

7. Repeat the HTTP request

(1) Add a loop controller:

Right-click http request - insert superior - logic controller - loop controller;

(2) Configure the number of cycles

8. Check the running result again:

A total of 175 data*3=525 records;

 

At this point, we have completed the multi-user lottery function;

Multiple users are multiple lines of data in a txt document. Multiple lottery draws are a single request loop 3 times. If you draw multiple times, you can modify the number of times.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325357259&siteId=291194637