Jmeter (Thirty-nine) - From entry to advanced level - Jmeter configuration file - Breaking down Jmeter and asking the question - Part 1 (detailed tutorial)

1 Introduction

Why Brother Hong wants to explain Jmeter's configuration file? It's because some children or friends encountered some problems that require modifying the configuration file during the test. They are not very clear or understand it. Even if they are modified, it is still vague. What's more, some people think that it is a sacred place and cannot be violated lightly. They dare not touch it and do not modify it. They are afraid that if they modify it wrongly, Jmeter will not be able to run. After listening to Brother Hong's bold modification, you will not have to reinstall a new Jmeter. Or if you have a good habit of making backups, make bold modifications after backing up before modification. If you make a mistake, you can just use the backup file to restore it.

2. Configuration file

Enter: properties in the search box under the %JMETER_HOME%\bin (or $JMETER_HOME/bin) directory and you  will find that there are multiple configuration files, as shown in the following figure:

If you want to learn automated testing, I recommend a set of videos to you. This video can be said to be the number one automated testing tutorial on the entire network played by Bilibili. The number of people online at the same time has reached 1,000, and there are also notes that can be collected and communicated with various channels. Master technical communication: 798478386    

[Updated] A complete collection of the most detailed practical tutorials on Python interface automation testing taught by Bilibili (the latest practical version)_bilibili_bilibili [Updated] A complete collection of the most detailed practical tutorials on Python interface automated testing taught by Bilibili (practical version) The latest version) has a total of 200 videos, including: 1. Why interface automation should be done for interface automation, 2. Overall view of request for interface automation, 3. Interface practice for interface automation, etc. For more exciting videos from UP master, please follow the UP account . icon-default.png?t=N7T8https://www.bilibili.com/video/BV17p4y1B77x/?spm_id_from=333.337

Next, we will explain and explain them one by one in order of importance. The most important one is jmeter.properties. It is the Jmeter core configuration item file. The settings of some of its commonly used configuration items are summarized and explained below. 

2.Official recommendations

Copy and paste the property values ​​that need to be modified into user.properties in the same directory. Here is a brief mention. The user.properties file will be introduced later.

Benefit: When Jmeter is upgraded, modifications can be avoided from needing to be reapplied

3.jmeter.properties file

Since this file is too large, Brother Hong has translated part of it here. If you are interested, you can read it all to see what it does.

3.1 File license description

3.1.1 Paragraph 1 – License Description

(1) Original text

################################################################################
# Apache JMeter Property file
################################################################################

## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
(2)译文
# 示例user.properties文件
#
## Apache软件基金会(ASF)下一个或多个许可
## 贡献者许可协议。请参阅
## 此作品用于获取关于版权所有权的附加信息。
## ASF根据Apache 2.0 版本许可证协议将此文件授权给您。
## (“许可证”);除非符合以下条件,否则不能使用此文件
## 许可证。您可以在
## 
## http://www.apache.org/licenses/LICENSE-2.0
## 
## 除非适用法律要求或书面同意,软件
## 根据在“AS IS”BASIS上分发的许可证基础上发布的,
## 无任何明示或暗示的保证或条件。
## 有关管理权限的特定语

3.2 File modification instructions

3.2.1 Paragraph 2 - used to describe the jmeter.properties file

(1) Original text

################################################################################
#
# THIS FILE SHOULD NOT BE MODIFIED
#
# This avoids having to re-apply the modifications when upgrading JMeter
# Instead only user.properties should be modified:
# 1/ copy the property you want to modify to user.properties from jmeter.properties
# 2/ Change its value there
#
################################################################################

# JMeter properties are described in the file
# http://jmeter.apache.org/usermanual/properties_reference.html
# A local copy can be found in
# printable_docs/usermanual/properties_reference.html

#Preferred GUI language. Comment out to use the JVM default locale's language.
#language=en


# Additional locale(s) to add to the displayed list.
# The current default list is: en, fr, de, no, es, tr, ja, zh_CN, zh_TW, pl, pt_BR
# [see JMeterMenuBar#makeLanguageMenu()]
# The entries are a comma-separated list of language names
#locales.add=zu

(2) Translation

################################################################################
#
# 这个文件不应该被修改
#
# JMeter这就避免了在升级JMeter时必须重新应用配置而再次修改
# user.properties文件的修改代替这里文件的修改:
# 1/ 从jmeter.properties文件中复制要修改的属性到user.properties文件中修改
# 2/ 在user.properties文件中修改复制属性的值
#
################################################################################

# 这个文件中描述了JMeter的配置
# 文件访问地址:http://jmeter.apache.org/usermanual/properties_reference.html
# 这个文件的副本在本地也可以找到
# 本地文件的位置:printable_docs/usermanual/properties_reference.html

#首选GUI语言。注释掉以使用JVM默认语言环境的语言。
#language=en


# 要添加到显示列表的其他区域设置。
# 当前默认的列表: en, fr, de, no, es, tr, ja, zh_CN, zh_TW, pl, pt_BR
# [请参见JMeterMenuBar\35; MakeLanguageenu()]
# 这些条目是以逗号分隔的语言名称列表
#locales.add=zu

3.3 Description of XML parser

3.3.1 Paragraph 3 – used to describe XML parsers

(1) Original text

#---------------------------------------------------------------------------
# XML Parser
#---------------------------------------------------------------------------

# Path to a Properties file containing Namespace mapping in the form
# prefix=Namespace
# Example:
# ns=http://biz.aol.com/schema/2006-12-18
#xpath.namespace.config=


# XPath2 query cache for storing compiled XPath queries
#xpath2query.parser.cache.size=400

(2) Translation

#---------------------------------------------------------------------------
# XML 解析器
#---------------------------------------------------------------------------

# 包含格式为prefix = Namespace的名称空间映射的属性文件的路径。例子:
# prefix=Namespace
# Example:
# ns=http://biz.aol.com/schema/2006-12-18
#xpath.namespace.config=


# 查询缓存,用于存储编译的XPath查询,默认为400
#xpath2query.parser.cache.size=400

3.4 Description of SSL configuration

3.4.1 Paragraph 4 - used to describe SSL configuration

(1) Original text

#---------------------------------------------------------------------------
# SSL configuration
#---------------------------------------------------------------------------

## SSL System properties are now in system.properties

# JMeter no longer converts javax.xxx property entries in this file into System properties.
# These must now be defined in the system.properties file or on the command-line.
# The system.properties file gives more flexibility.

# By default, SSL session contexts are now created per-thread, rather than being shared.
# The original behaviour can be enabled by setting the JMeter property to true
#https.sessioncontext.shared=false

# Be aware that https default protocol may vary depending on the version of JVM
# See https://blogs.oracle.com/java-platform-group/entry/diagnosing_tls_ssl_and_https
# See https://bz.apache.org/bugzilla/show_bug.cgi?id=58236
# Default HTTPS protocol level:
#https.default.protocol=TLS
# This may need to be changed here (or in user.properties) to:
#https.default.protocol=SSLv3

# List of protocols to enable. You may have to select only a subset if you find issues with target server.
# This is needed when server does not support Socket version negotiation, this can lead to:
# javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
# java.net.SocketException: Connection reset
# see https://bz.apache.org/bugzilla/show_bug.cgi?id=54759
#https.socket.protocols=SSLv2Hello SSLv3 TLSv1

# Control if we allow reuse of cached SSL context between iterations
# set the value to 'false' to reset the SSL context each iteration
# Deprecated since 5.0
#https.use.cached.ssl.context=true

# 
# Reset HTTP State when starting a new Thread Group iteration which means:
# true means next iteration is associated to a new user
# false means next iteration is associated to same user
# true involves: 
# - Closing opened connection
# - resetting SSL State 
#httpclient.reset_state_on_thread_group_iteration=true

# Start and end index to be used with keystores with many entries
# The default is to use entry 0, i.e. the first
#https.keyStoreStartIndex=0
#https.keyStoreEndIndex=0

(2) Translation


#---------------------------------------------------------------------------
# SSL 配置
#---------------------------------------------------------------------------

## SSL系统属性现在位于system.properties中

# JMeter不再转换javax。jmeter.properties中的xxx属性条目 进入系统属性
# 现在必须在system.properties文件或命令行中定义它们。
# 在 system.properties文件提供了更多的灵活性。

# By default, SSL session contexts are now created per-thread, rather than being shared.默认情况下,SSL会话上下文现在是按线程创建的,而不是共享的。
# 可以通过将此属性设置为true来启用原来行为。默认为:false
#https.sessioncontext.shared=false

# 请注意,https默认协议可能会根据JVM的版本而有所不同。
# See https://blogs.oracle.com/java-platform-group/entry/diagnosing_tls_ssl_and_https
# See https://bz.apache.org/bugzilla/show_bug.cgi?id=58236
# 默认HTTPS协议级别:
#https.default.protocol=TLS
# 这可能需要(或者在user.properties文件中) 更改为:
#https.default.protocol=SSLv3

# 要启用的协议列表。如果发现目标服务器有问题,则可能只需要选择一个子集。
# 如果服务器不支持Socket版本协商,则需要这样做,这可能导致以下错误:
# javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
# java.net.SocketException: Connection reset
# see https://bz.apache.org/bugzilla/show_bug.cgi?id=54759
#https.socket.protocols=SSLv2Hello SSLv3 TLSv1

# 控制是否允许在迭代之间重用缓存的SSL上下文。
# 将值设置为false可在每次迭代时重置SSL上下文。默认为:true
# Deprecated since 5.0
#https.use.cached.ssl.context=true

# 
# 开始新的线程组迭代时,重置HTTP状态。
# true表示下一次迭代与新用户相关联。
# false表示下一次迭代与同一用户相关联。
# true 涉及: 
# - 关闭打开的连接
# - 重置SSL状态
#httpclient.reset_state_on_thread_group_iteration=true

# 与具有许多条目的密钥库一起使用的起始索引和结束索引。
# 默认值是使用条目0,即第一个。
#https.keyStoreStartIndex=0
#https.keyStoreEndIndex=0

Below I will select some commonly used and important ones to share with children’s shoes or friends.

4.GUI language

4.1Windows system

4.1.1 Method 1

——Modify Options
and click Options-->Choose Language-->Chinese (Simplified) to configure it to Chinese Simplified. It should be noted that this method only takes effect for that time. The next time you open Jmeter, it will still be in English. If you want it to take effect permanently, please use the following two methods.

4.1.2 Method 2

——Modify jmeter.properties file

Open the bin directory under the jmeter decompressed file, find the jmeter.properties file and open it with an editor.
Insert a line of language=zh_CN under #language=en and save it after modification. Restart
Jmeter and the interface will display as simplified Chinese.

Notice:

功能:设置JMeter GUI界面的显示语言
说明:若没有设置,则使用JVM(Java虚拟机)设置的locale语言.
4.1.3 Method 3

——Modify jmeter.bat file

Use an editor to open the JMeter startup file jmeter.bat
and change set JMETER_LANGUAGE=-Duser.language="en" -Duser.region="EN" to set JMETER_LANGUAGE=-Duser.language="zh" -Duser.region="CN ", save the code
and restart the Jmeter interface to display in simplified Chinese.

4.2Linux system

In Linux, you can set the locale of the JVM:

[root@localhost ~]# locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
[root@localhost ~]# vi /etc/sysconfig/i18n
[root@localhost ~]# cat !$
cat /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
[root@localhost ~]#

注意:此配置项只能在jmeter.properties中设置才有效。

5.GUI icon magnification ratio setting

5.1JMeter GUI interface layout

When JMeter is running in GUI mode, the window is mainly composed of three parts:
1. Ribbon:
upper menu bar, lower toolbar. The menu bar displays the function menu provided by JMeter, and the icons in the toolbar
are shortcuts to common functions.
2. View area
presents JMeter elements in a tree structure, where "Test Plane" is the root node of the tree, and each node is a JMeter element.
In this area, nodes can be added, deleted, or the position of nodes adjusted by dragging.
3. Content area
When a JMeter element node is selected in the view area, the content area will display the content of the element accordingly.
At this time, you can view, set and other operations on its content.

5.2GUI icon magnification ratio setting

jmeter.hidpi.mode=true #开启视网膜模式
jmeter.hidpi.scale.factor=1.2 #将图标放大1.2倍

 5.3 Ribbon toolbar icon size setting

#工具栏图标默认size: 22x22
#可用size: 22x22, 32x32, 48x48
jmeter.toolbar.icons.size=32x32

5.4 Setting the size of the directory tree icon in the view area
 

#目录树图标默认size: 19x19
#可用size: 19x19, 24x24, 32x32, 48x48
jmeter.tree.icons.size=24x24

5.5 Edit font settings in content area

#调整JMeter内容区的编辑字体
jsyntaxtextarea.font.family=consolas  #默认Hack,太难看,使用经典的consolas
jsyntaxtextarea.font.size=18  #这两个配置项必须同时设置才有效

5.6 Response data encoding settings

#响应数据编码默认为ISO-8859-1(即Latin-1)
sampleresult.default.encoding=UTF-8  #设置为UTF-8,避免出现乱码

6. Add JMeter element shortcut key settings

#配置添加JMeter元素时使用的快捷键,最多支持10个.
#在windows上可以使用 Ctrl+0  Ctrl+1 ... Ctrl+9
#在macOS上可以使用 Command+0 Command+1 ... Command+9
gui.quick_0=ThreadGroupGui     #新增线程组
gui.quick_1=HttpTestSampleGui  #新增HTTP取样器
gui.quick_2=RegexExtractorGui  #新增正则表达式提取器
gui.quick_3=AssertionGui       #新增响应断言
gui.quick_4=ConstantTimerGui   #新增常量定时器
gui.quick_5=TestActionGui      #新增测试活动
gui.quick_6=JSR223PostProcessor  #新增JSR223 后置处理程序
gui.quick_7=JSR223PreProcessor   #新增JSR223 预处理程序
gui.quick_8=DebugSampler         #新增调试取样器
gui.quick_9=ViewResultsFullVisualizer #新增察看结果树

7.HTTP Request Post Content-Type setting

# Should JMeter add to POST request content-type header if missing:
# Content-Type: application/x-www-form-urlencoded
# Was true before version 5.0
post_add_content_type_if_missing=true
说明:此配置项在JMeter5.0以前默认值为true,以后版本默认为false,故在5.0以后的版本中
发送POST请求,将参数放在"body data"中,且没有设置
Content-Type时,默认为Content-Type值为"text/plain",而不是"application/x-www-form-urlencoded".

8. Summary

1. When setting the GUI language, I found that the settings in Hongge's jmeter.properties file were commented out, and Hongge used the default locale language of win10. The default locale language was Chinese. However, after Hongge started jmeter, he found that the GUI language was still English. . After a series of research, it was found that it was because there were language settings in the jmeter.bat file.

Use an editor to open the JMeter startup file jmeter.bat
and change set JMETER_LANGUAGE=-Duser.language="en" -Duser.region="EN" to set JMETER_LANGUAGE=-Duser.language="zh" -Duser.region="CN ", save the code
and restart the Jmeter interface to display in simplified Chinese.

2. The languages ​​in jvm all obtain the system locale language
(1) Windows system

a. Enter the command: java -X

b. Enter the command: java -XshowSettings:locale

 

(2)Linux system

a. Enter the command: java -X

b. Enter the command: java -XshowSettings:locale

 

Guess you like

Origin blog.csdn.net/Faith_Lzt/article/details/132810952