Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Jmeter implements parameterized users and manages Cookie

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

When it comes to performance testing, users often need to be parameterized. One of the components often used in jemter tool parameterization is the CSV data file setting.

First of all, it is recommended that you create a standard directory to save files directory to use data save parameters result save results script save script as follows

The advantage of setting up a directory is that the file path can use a relative path, so that you can cross-system (window, linux), cross-platform without modifying the path, first set a variable path in the user variable, the value is.. / data/,.. Represents the current directory to the previous directory

Then add a file in .csv format to the data directory. It is recommended to add a text file in txt format, and then change it to .csv format.

The variables are as follows

Add CSV component, thread right-click "add configuration component" CSV data file settings

The configuration is as follows:

Call parameter

  default systems need to log in to operate other interfaces, so you need to add a HTTP Cookie manager. The default Cookie manager is closed, and you need to modify the jmeter configuration file jmeter.properties. Under the jmeter\ bin\ path, find # CookieManager.save.cookies=false and change it to CookieManager.save.cookies=true. Save the configuration file and restart jmeter.

Click the test plan right click "add" configuration components "HTTP Cookie Manager"

The function of Cookie manager is to help you automatically manage the cookie obtained by system login. The scope of calling Cookie manager automatically when other interfaces need to be used: different threads cookie will not call each other. If the cookie manager is placed under the test plan, all interfaces under the thread can automatically call cookie. If placed under the transaction manager, only the interfaces under the manager will be called. Other interfaces at the same level as this thing will not be called to analyze the actual case 1. Cookie manager is added in this case. The actual request or error response result hint: status ": 400," error ":" Bad Request ", Missing cookie 'timeZone' for method parameter of type in.

The cookie manager used by the query request and the cookie parameter called by the manager

Since the cookie manager is not omnipotent, if you encounter an error, you should analyze it with the API request and query and debug it manually. The manual cookie is as follows:

The cookie value is as follows:

Sid=c4d29545-3409-4117-81bemura6562a6f8c2f; mip_curr_lang=zh-CN User_info=%7B%22id%22%3A%22u_10212853605%22%2C%22parentId%22%3A%22d_9743384365%22%2C%22name%22%3A%22%E8%B0%A2%E7%94%B0%22%2C%22fdLangType%22%3A%22zh-CN%22%2C%22fdPositionName%22%3A%22%E6%B5%8B%E8%AF%95%E5%B7%A5%E7%A8%8B%E5%B8%88%22%2C%22fdEmail%22%3A% 22tian2.xie% 40meicloud.com% 22% 2C% 22loginName% 22% 3A% 22xietian1% 22fdEnglishName% 22% 3A% 22% 22% 22% 2C% 22fdTimeZone% 22% 3A% 22Asia% 2FShanghai% 22% 2C% 22fdemploeNumber% 22% 3A% 22215183% 22C% 22fdDepartEngmentEnglishName% 22% 3A% 22A% 22Midea% 20Holding% 20GroupDepartmentMidea% 20GrouproomShenzhen% 20Midea% 20Cloud% 20Cloud% 20and% 20technologies% 20Technology% 20TDidea20Cloud20DepartMment20Technology% 20atDevense% 20form20earchand% 22Came2% Department2% 22Came2% 3A% 22% E7% be% 8e% E7% 9A% 84% E7% be% 8e% E7% 9A% 84% E9% 9B% 86% E5% 9B% A2% E6% B7% B1% E5% 9C% B3% E7% be% 8e% E4% BA% 91% E6% 99% BA% E6% 95% B0% E7% A7% 91% E6% 8A% 80% E6% 9C% 89% E9% 99% 90% E5% 85% AC% E5% 8F% B8% E7% be% 8% E4% BF%A1%E4%BA%91%E4%BA%8B%E4%B8%9A%E9%83%A8_%E7%BE%8E%E6%93%8E%E6%8A%80%E6%9C%AF%E5%B9%B3%E5%8F%B0_Devops%20%E5%B9%B3%E5%8F%B0%E4%BA%A7%E5%93%81%E7%A0%94%E5%8F%91%22%2C%22locale%22%3A%22zh_CN%22 % 2C%22fdHierarchyId%22%3A%22x526x1460494117x7509007994x7659897777x9732499571x9743384365x10212853605x%22%2C%22shiroid%22%3Anull%7D OAM_LANG_PREF=v1.0~cHJlZmVycmVkTGFuZ3VhZ2U9emh+ZGVmYXVsdExhbmd1YWdlTWFya2VyPWZhbHNl; oam_locale=zh; mip_lang=zh; mideatest_sso_token=eOXIT3uFt6jYti%2FYd3JLHcaL2nd0xvXmBE7enJMQJsWkLsvg9Uu4FA%3D%3D; MAS_TGC_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uA4yVizUSUo5RFobUz5v%2FWvp3zKkp%2FkfM%2FT%2FzrPTGUGkwduxXugMIM%2BNAyIXnY%2FokAg3sokv345cjMcgnGHY%3D; language=zh-CN; timeZone=8 combined with the response reported an error, the original cookie was lost; language=zh-CN TimeZone=8, which causes the request to fail. See red font because the automatic cookie manager will report an error, so you need to place the cookie manager under the login transaction manager, so that the cookie manager will not affect the cookie set by the query request, as follows

Because the ObSSOCookie variable is managed by the cookie manager, you can open debug sample to see the name of the variable in cookie, as follows

After debugging, you only need to add a Cookie variable with a value of ObSSOCookie=$ {COOKIE_ObSSOCookie}; language=zh-CN; timeZone= in the header under the query request.

After the modification is completed, debugging is carried out and the debugging is successful.

Analysis of the second response of the actual case suggests that "status": 400," error ":" Bad Request "," exception ":" org.springframework.web.bind.ServletRequestBindingException "," message ":" Missing cookie 'language' for method parameter of type String "

The cookie manager used to submit the request, and the cookie parameter called by the manager

Combined with the response error, the original cookie is missing: language=zh-CN, causing the request to fail. You can maintain this field in the HTTP Cookie manager, as follows:

Debugging result, submitted successfully

At this point, for each request under the domain name, the Cookie parameter will be added with language=zh-CN, as shown below:

Analysis of the actual case 3, 1 thread loop 3 times, first log in, and then submit the request, the system only succeeded in the first submission of data, the second and third submission failed

Reason analysis: due to the use of HTTP Cookie manager, but not checking to clear Cookies repeatedly each time, the second and third cycle of cookie is still the cookie value obtained in the first cycle. You only need to check it as follows:

After the modification is completed, debugging is carried out and the debugging is successful.

At this point, concurrent queries can be implemented regardless of multiple users or a single user.

    if the article is helpful to you, you can click on the follow function in the lower right corner. Welcome to forward and clap the brick. I will continue to launch articles related to the test and share the testing technology with you. Every original article is written attentively to put an end to plagiarism and copying. The official Wechat account is synchronized with the articles on this platform for easy reference.

QQ technology exchange group: please enter the verification information 51CTO to add the group.

Wechat QR code follow official account:

After following, reply to the resource download, and you can get the download address of all kinds of resources shared by yourself.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report