Jmeter4.0 Season 1 of Distributed Pressure Measurement Series

1) Introduction to Jmeter 4.0

Jmeter is an open source stress testing tool written in pure java. The open source software under Apache was originally designed for web testing. Due to its rapid development, it can now stress test many protocols such as: http, https, soap, ftp, database, LDAP Lightweight Directory Access Protocol, TCP, SOMP (Simple Mail Protocol), etc., since it is written in pure java, it can run under Apple, Windows or Linux, full-featured test IDE, allowing rapid establishment of test plans (from browser or Local application, official website address: http://jmeter.apache.org), Jmeter is a tool that must be mastered by intermediate and advanced developers or testers.

Comparison of commonly used test tools currently used:

1. Loadrunner: stable performance, large pressure test results and fine-grainedness, you can customize scripts for pressure testing, but it is too important and has many functions
2. apache ab (single-interface stress test is the most convenient): Simulate multi-threaded concurrent requests. The ab command has very low requirements on the computer that sends the load. It will neither occupy a lot of CPU nor memory, but it will give Target server causes huge load, simple DDOS attack, etc.
3. webbench: webbench first forks multiple sub-processes, and each sub-process cycles through the web access test. The child process tells the parent process the result of the access through the pipe, and the parent process makes the final statistical result.

1.png

2) Features

  • Provide GUI graphical interface and non-GUI interface for stress testing, develop and test stress testing scripts under windows, and then execute them directly on linux

  • Can provide a complete dynamic HTML pressure test report

  • Write in pure java, write once, test everywhere

  • The multi-threaded framework allows simultaneous sampling and stress testing through multiple threads, and simultaneous sampling of different functions through separate thread groups

  • Provides highly extensible functionality, custom plugins:

  • Provide functions can be used to provide dynamic input to tests or to provide data manipulation.

  • Easy continuous integration with third-party open source libraries for Maven, Graddle and Jenkins

3) Preparations

The java operating environment needs to be installed, and it is recommended to install the JDK environment. Although JRE is also available, the pressure test https requires the keytool tool in the JDK;
the new version of Jmeter4.0 requires JDK8 or above, JDK9 or JDK10; and configure the JDK environment ( I won't talk about configuring the JDK environment here)
Download the corresponding Jmeter4.0 version and unzip it (official website address: http://jmeter.apache.org/)
Windows system: http://mirrors.tuna.tsinghua.edu.cn/ apache//jmeter/binaries/apache-jmeter-4.0.zip
Mac or Linux: http://mirrors.tuna.tsinghua.edu.cn/apache//jmeter/binaries/apache-jmeter-4.0.tgz

4) jmeter4.0 decompression directory file explanation

2.png

bin: core executable, including configuration	
      jmeter.bat: windows startup file:	
      jmeter: mac or linux startup file:	
      jmeter-server: startup file used for mac or linux distributed stress testing	
      jmeter-server.bat: The startup file used for mac or Linux distributed stress testing	
      jmeter.properties: core configuration file	
      examples: stress test script file JMX and dynamic read csv parameter file example result—template: visual HTML	
      template: JMX template file			
docs: API documentation for Jmeter
extras: packages for plugin extensions
lib: core dependencies
ext: core package
junit: unit test package

5) Introduction to the core components of Jmeter

3.png

What is a test plan?

    就是压测的一个流程,比如压测什么接口,并发多少用户,协议等等,在测试计划下面配置线程组,采样器,监听器等组件

什么是线程组(Thread Group)?

线程组就是模拟多少用户并发访问你的应用,这个组里面共有多少用户,创建方法如上图现在“添加->threads->线程组“
    参数说明:
    线程数:虚拟用户数。一个虚拟用户占用一个进程或线程			
    准备时长(Ramp-Up Period(in seconds)):全部线程启动的时长,比如100个线程,20秒,则表示20秒内100个线程都要启动完成,每秒启动5个线程			    
    循环次数:每个线程发送的次数,假如值为5,100个线程,则会发送500次请求,可以勾选永远循环

4.png

什么是采样器(Sampler)?

真正干活的组件,采样器里面配置你要压测的接口,协议,参数等
可以创建各种采样器,如Http请求,FTP请求,JDBC压测数据库请求,JMS等,对应的采样器有不同的配置
以http请求采样器为例
	名称:采样器名称,一般是接口名称,方便后续进行区分,比如“login接口”
	注释:采样器的描述,方便别人理解,类似压测接口描述	
	web服务器配置
			协议:压测的协议,比如“http”或者"https"
			服务器名称或IP:压测目标机器的端口或者服务器IP地址,比如 www.xdclass.net		
			端口号:压测目标机器的端口号,比如 8080	
	HTTP请求配置
			方法:http的请求方法,常用的有GET,POST,PUT,DELETE,PATCH等		
			路径:压测的接口的URL,比如 /api/v1/users		
			Content encoding:是否进行内容编码
							
			自动重定向:http有302状态码返回的时候,重定向,但不会产生记录,不可以做关联请求,		
			比如比如第二个请求要用到第一个请求的数据,则选择自动重定向无法做关联		
			Follow the redirection: a record will be generated, which can be associated, this is checked by default		
			Use multipart/from-data for HTTP POST: When sending a POST request, use the Use multipart/from-data method to send, and it is not selected by default.		
			parameters: parameter configuration		
			Files Upload: file upload configuration

5.png

What is a result tree?

View the results of the stress test, you can see the url sent by the stress test, http parameters, the return result, the entire response returned, and then if there is an assertion or debugging, you can see whether the assertion passed, etc.
Add path: Thread Group -> Add -> Listener -> View Result Tree
If you do not add the number of results, click the start button of the stress test, we cannot know the specific response of the stress test, so you need to add the number of results.
First, it is convenient to debug the stress test script to see whether the request parameters and the path are normal
Switch to the results view page, click the pressure measurement button to enter the pressure measurement, and you can see the requested results while the pressure measurement is performed.

6.png

A little trick is added, that is, the GUI graphical interface language version is switched between Chinese and English:

1. Modify the console menu -> options -> choose language to select the corresponding language version.
2. Configuration file modification
		bin directory -> jmeter.properties			
		Default #language=en			
		Change to language=zh_CN

OK, the introduction to the first season of Jmeter4.0 stress test is here first,

The next chapter will share advanced knowledge of Jmeter, such as assertion usage, dynamic reading of CSV parameters, stress testing Mysql, Aliyun Linux environment non-GUI interface stress testing, distributed stress testing, etc.

Video tutorial reference : http://edu.51cto.com/course/13251.html


Guess you like

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