Jmeter-CSV parameterization

Test requirements

To test the statistical system, it is necessary to use Jmeter to inject a large amount of data into the statistical system to test the response of the statistical system under a large amount of data.
A large amount of data: A large number of requests A are sent to the server, thereby generating a large number of data records in the system
(1) Request A needs to be sent in large quantities-"Implementation: loop controller to achieve large amounts of sending
(2) Request A requires different request information-" Realization: Need to parameterize the parameter value in request A, think of reading the CSV file to parameterize
(3) How to request A to cycle once, read a row of parameter values ​​from the CSV

Test implementation

Test realization 1-single thread + loop controller

Insert picture description here

Operation result:-did not reach the expected result
. The parameter values ​​in the N requests sent are all the parameter values ​​in the same row in the CSV, and the request does not take the first row and then loops to take the second row...

Test implementation 2-multithreading

Insert picture description here
Running result:-the expected result is reached
. The parameter values ​​in the N requests sent are all CSVs. Thread 1 fetches the first row; Thread two fetches the second row, and then loops according to the number of threads.

How to control the file fetching method during CSV parameterization?

Insert picture description here
1. Filename
CSV: The name and address of the file. The old version should be copied or input manually, and the higher version should click the [Browse] button to select the file address
(1) Relative address: refers to the relative address of the data file (bat/txt/csv) The path of the currently executed .jmx script file
In the bin directory or script directory of jmeter, just give the file name;
./ represents the current directory
.../ represents the upper level directory
/ represents the root directory
(2) Absolute Address: Refers to the storage path of the data file (bat/txt/csv) 2. File
encoding
remains the same as the file editing format (if the file is edited as utf-8, fill in utf-8 here) (further confirmation points?)
3 .Variable Names (comma-delimited):
Variable names: variable 1, variable 2, variable 3. . . . Use English for variable names and separate the
CSV file: Column 1, Column 2, Column 3, Column 4...
Variable 1-" Take the value of Column 1; Variable 2-" Take the value of Column 2. . . .
Variable use:
www.baidu.com/search="variable 1, {variable 1},Variable amount of 1 , {variable}2 "....
4.Ignore First Line
if the first line in the file name of the parameter is not the parameter value, may be set to True, then the default start values taken from the second row
Delimiter (use "T" for tab)
Under normal circumstances, the delimiter is English comma, just keep the default. In
special cases, the delimiter is Tab, fill in /t here
5.Allow quoted data?: Do you agree with the file content to quote the
file content as
name ,pwd
"te,st1",11111
Allow quoted data=True, when the value is read, the quotation marks in the data will be automatically removed so that the data can be read normally, and even if the content between the quotation marks contains a separator, it is still regarded as a The whole is not separated; the
reading effect is: te,st1
Allow quoted data=False, then the reading data will report an error;
if you want the content to be able to read normally when there is "", "" as part of the content, you need to add Two double quotation marks (one of which "represents the meaning of escape)
Allow quoted data=True
name,pwd
""te,st1"",11111 The
reading effect is: "te,st1"
6. Recycle on EOF?:
To the file Whether the tail is looped, True—continue to read from the first line of the file, False—no longer loop;
The setting of this item and the next item is mutually exclusive, that is, true-false, or false-true;
7.Stop thread on EOF?:
Whether to stop the thread at the end of the file, True—stop, False—not stop;
Note: When When Recycle on EOF is set to True, this setting is invalid.
(1) There are 10 threads and 15 file lines.
Recycle on EOF=True, Stop thread on EOF=True
Recycle on EOF=True, Stop thread on EOF=Fasle. The
above has only been executed 10 times, ending with the number of threads
Recycle on EOF=False, Stop thread on EOF=True
Recycle on EOF=False, Stop thread on EOF=Fasle
has only been executed 10 times, ending with the number of threads
(2) There are 20 threads and 15 file lines
Recycle on EOF=True, Stop thread on EOF=True
Recycle on EOF=True, Stop thread on EOF=Fasle
is executed more than 20 times, and the file is fetched in a loop.
Recycle on EOF=False, Stop thread on EOF=True
has only been executed 15 times, ending with the number of files
Recycle on EOF=False, Stop thread on EOF=Fasle
The above has only been executed 20 times, ending with the number of threads
8.Sharing mode: Sharing mode
Insert picture description here
(1) All threads All threads
within the scope of this component share csv data, and each thread reads csv data in turn, without repeating each other;
In the All Threads mode, the concept of thread group is not distinguished. All threads (threads under all thread groups) will start from the first line and go down in sequence, but multiple samplers in the same thread group are always Take the same value.
Insert picture description here
Summary: Take thread as the loop unit.
Thread group 1_Thread 1 (take the first row)-"Thread group 2_ Thread 1 (take the second row)-"Thread group 1_ Thread 2 (take the third row)-"Thread group 2_ Thread 2 (take The fourth line)
(2) The current thread group
value is: taking the thread group as the unit, the threads in each thread group will start from the first line to get the value and then go down in order.
Thread group 1_Thread 1 (take the first row)-"Thread group 1_ Thread 2 (take the second row)-"Thread group 1_ Thread 1 (take the third row)-"Thread group 1_ Thread 2 (take Fourth line)
Thread group 2_Thread 1 (take the first line)-"Thread group 2_ Thread 2 (take the second line)-"Thread group 2_ Thread 1 (take the third line)-"Thread group 2_ Thread 2 (take the fourth line)
summary: take the thread group as the loop unit.
(3) Current thread
Current thread: current thread.
The value situation is: the current thread, all threads in the test plan take the first line.

Remaining question:
How to realize the parameterized value of the request under loop control?

Guess you like

Origin blog.csdn.net/weixin_43533308/article/details/103423877