In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Today, let's learn about an important tool of parameterization. We often use parameterization when writing scripts, and one of the most commonly used methods to achieve parameterization is to use CSV Data Set Config components, which is easy to use and powerful.
It is estimated that everyone will be able to use a simple method, or it will be easy to use it, but if it is a more complex configuration, it is estimated that a lot of people will be dizzy (I often fainted at the beginning). Let's take a look at it in detail today. How not to get dizzy! Ha ha
First of all, let's take a look at what it looks like. I believe we are all familiar with it.
The role of the component:
Read the value of the variable from the file, used for the parameterization of the variable, can set a variety of reading methods.
Instructions for each entry:
1. Name, comment: the name and annotation of the component, which can be customized
2. Config the CSV Data Source: configure the data source
1) name of the Filename:csv file
Note: the path of the file should be included here. In version 4.0, you can click the browse button on the right to select the file, which will automatically bring the absolute path of the file.
In addition, when the csv file is in the bin directory or script directory of jmeter, you only need to give the file name.
When using relative paths, jmeter first looks under the bin directory by default, and then looks under the script directory
2) File encoding:csv file encoding
The current operating system encoding format is used by default
If the file contains Chinese garbled codes, you can try utf-8, gbk, etc.
3) Variable Names (comma-delimited):
The names of the columns in the csv file (if there are multiple columns, separate the column names with English commas)
The name order should correspond to the content, and the variable name is referenced elsewhere, so it is required.
4) Delimiter (use "t" for tab): the delimiter in the csv file (replace the tab key with "t")
In general, the delimiter is a comma in English, which is fine by default.
5) whether Allow quoted data?: allows data content to be quoted.
6) Recycle on EOF?:
When it comes to whether the file is looped at the end of the file, True- continues to read from the first line of the file, and False- no longer loops
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- stops, False- does not stop.
Note: this setting is not valid when Recycle on EOF is set to True.
8) Sharing mode: sharing mode
All threads-all threads, all threads within the scope of this component share csv data, and each thread reads csv data in turn and does not repeat each other
Current thread group- current thread group. Within the scope of this component, threads in each thread group share csv data, read the data in turn, and do not repeat each other.
Current thread- the current thread, within the scope of this component, all threads in each loop have the same value
Let's focus on Allow quoted data and Sharing mode:
1. Whether Allow quoted data?: allows data with double quotation marks
This item actually controls whether the double quotes in the csv file are valid characters.
If the data is in double quotation marks and this setting is TRUE, the quotation marks in the data are automatically removed so that the data can be read normally, and even if the contents between the quotation marks contain delimiters, they are not separated as a whole.
If the data is in quotation marks and this is set to FALSE, an error is reported when reading the data
If you want to include double quotes in the middle of the double quotation mark field, you need to add two double quotation marks to represent a single double quotation mark. (Ah, what a mouthful! )
As shown in the following figure, when this is set to true, "2pjm 3"-> 2je 3; "4"5"-- > 4 "5"
2. Sharing mode: sharing mode
(1) All threads: for all threads in all thread groups, each thread has a different value, so take the next line in the csv file in turn.
If there is thread 1 to thread n (n > 1), thread 1 takes a value, and thread 2 takes a value, which is the next line in the csv file, that is, it is not the same line as thread 1. Whether it is a single thread group or multiple thread groups, each thread takes the next row in turn. It is important to note that when there are multiple requests in a thread group, the value of each request in a loop is the same for each thread.
The following examples are given:
A. set thread groups 1, 2, 3 to 1 concurrency and 1 cycle, respectively, and each thread group executes sequentially:
B. set thread groups 1, 2, 3 to 1 concurrency and 2 cycles, respectively, and each thread group executes sequentially:
C, set thread groups 1, 2 and 3 to 2 concurrency and 1 cycle, respectively, and each thread group is executed sequentially:
You can carefully compare the difference between the image above and the image above. At first glance, it seems to be the same, but it is actually different threads. How to distinguish between different threads?
You can use a function to determine:
${_ _ BeanShell (ctx.getThread (). GetThreadName (). ToString ())}
This function can output something like "thread group 1 1-2", which is preceded by the name of the current thread group-thread group 1, followed by thread group id, and then thread id. Now comparing the above two figures, we find that the thread id is different.
In general, in All Threads mode, concurrency and loop numbers both read different csv data, but multiple sampler in the same thread group always take the same value.
(2) Current thread group: current thread group
The value is as follows: in terms of thread group, the threads in each thread group will start at line 1 and take the value down in turn.
Examples are as follows:
A. set thread group 1 and 2 for 2 concurrency and 1 cycle:
(3) Current thread: current thread.
The value situation is that each thread takes the value from line 1 and goes down in turn, and all threads have the same value in the same loop.
Examples are as follows:
A. set thread group 1 and 2 for 2 concurrency and 1 cycle:
The above two pictures look the same? If you take a closer look, the values of the following test parameters are different.
Why is it different? I wanted to explain it seriously, but I still felt that I didn't speak clearly after organizing the language for a long time.
The logic of this piece is "can only be understood, but cannot be expressed in words". We must rely on our own experiments and slowly understand it.
Finally, I would like to give you a small assignment:
How to set the method of Sharing moder to realize that the parameters in multiple sampler can take the values in the same csv file without repetition in turn?
Jmeter video: https://edu.51cto.com/course/14305.html
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.