Recently, I needed to do a set of performance tests. I used JMeter, a testing tool, to briefly record what I knew about it and how I installed it.
Introduction of JMeter
The full name is Apache JMeter
JMeter is a piece of software that enables load testing or performance oriented business (functional) testing of different protocols or technologies. It was originally developed by Stefano Mazzocchi JMeter of the Apache Software Foundation. It mainly tests the performance of Apache JServ (now known as the Apache Tomcat Project). Apache later redesigned JMeter with an enhanced graphical user interface and added functional testing capabilities.
The role of JMeter
Apache JMeter is a 100% pure JAVA desktop application designed to test software with client/server architectures (such as Web applications). JMeter can be used to test the performance of static and dynamic resources, such as static files,Java servlets,CGI Scripts,Java Objects, databases, FTP servers, and more. JMeter can be used to simulate large loads to test the robustness of a server, network, or object or to analyze overall performance under different loads.
At the same time, JMeter can help you regression test your application. Verify that your program returns the expected value by creating test scripts and assertions. For greater flexibility, JMeter allows you to call secondary development JARS to enrich your test scenarios; JMeter allows you to use regular expressions to create these assertions.
Usage range of JMeter
JMeter is a Java desktop application with a graphical interface that uses the Swing graphics API, so it can run on any environment/workstation accepting a Java virtual machine, for example: on Windows, Linux, MAC, etc.
Protocols supported by JMeter
- Web – Web 2.0 of Web1.0 for HTTP, HTTPS sites (Ajax, Flex and Flex-WS-AMF)
- Web Services: — SOAP/XML-RPC
- Database through the JDBC driver
- Directory: — LDAP
- Message-oriented services over JMS
- Service: —— POP3, IMAP, SMTP
- FTP service
The characteristics of the JMeter
Here are some features of JMeter:
- It’s free. Open source software.
- It has a simple, intuitive graphical user interface.
- JMeter load and performance tests many different server types: Web sites – – HTTP, HTTPS, SOAP, database via JDBC, LDAP, JMS, mail POP3
- It is a platform-independent tool. In Linux/UNIX, the JMeter shell script can be invoked by clicking. On Windows, it can call the launch jmeter.bat file.
- It has full Swing and lightweight component support (the pre-compiled JAR uses the package javax.Swing *).
- The JMeter test plan is stored in XML format. This means that you can use a text editor to generate a test plan.
- Its complete multithreading framework allows concurrent multithreading and synchronous sampling of different functions by individual thread groups.
- It is highly scalable.
- It can also be used to perform automated and functional tests of applications.
The installation of the JMeter
-
Enter the Official website of Apache JMeter and select Download Release, as shown in the figure below:
-
Select the package to download based on the operating system:
Notes:
- Note that the Java version requirement in the image title is Java8 and above.
- We usually choose the compression package under Binaries, unless you want to use the Source code for research, you can choose the Source package under Source.
-
Decompress the downloaded package to obtain the following file structure:
-
Open the bin directory and double-click apacheJmeter.jar to start JMeter:
-
You can also start with executables, which are highlighted in the figure above on different systems.
-
JMeter requires a Java environment to run, requiring JDK installation in advance.
-
The structure of the JMeter root directory
-
Backup directory
The script backup directory contains files ending in.jmx.
This directory does not exist after the actual installation and decompression. After using JMeter, JMeter automatically creates this directory and then backs up script files.
-
Bin directory
Directory of executable files
- Jmeter.bat: is the primary script for starting Jmeter.
- Jmeter-server.bar: is used to implement online load.
- Jmeter.properties: is the main configuration file for Jmeter. More than 80% of the configuration items are implemented through this file. (PS: After modifying the configuration file, you need to restart Jmeter for the modification to take effect.)
Jmeter.bat Displays the Jmeter main window.
The log file name used by Jmeter is defined in jmeter.properties, and logs can be viewed in jmeter.log by default.
-
Dosc directory
The files in the docs directory are Java docs for JMeter.
The usermanual subdirectory of printable_docs contains the JMeter usermanual documentation, where component_reference.html is the most commonly used core component help documentation. This directory stores the API documents of JMeter official documents, which are mainly used for secondary development.
-
Extras directory
The files in this directory provide support for the build tool Ant, which can be used for test automation, such as batch script execution, generating HTML reports, and recording test data while the test is running. Jmeter will automatically generate a.jtl file. Put the file in the extras directory and run “ant-dtest = file name report” to generate test statistics.
-
Lib directory
This directory contains two subdirectories: ext, which holds JMeter’s core JAR packages, and junit, which holds junit test scripts.
The packages that the user extension depends on should be placed directly in the lib directory, not in lib/ext.
Note: Package files in zip format are not recognized, so all required package files must end in.jar
-
Licenses Directory of JMeter software license files
-
Printable_docs directory
This directory stores JMeter official help documents.
Examples of common JMeter scripts can be found in the demos subdirectory of printable_docs.
-
LICENSE JMeter — LICENSE description
-
NOTICE JMeter — Simple information description
-
Readme.md — JMeter official basic introduction
Bin Directory description
Under the window
-
JMeter.bat
Start JMeter (default GUI mode)
-
jmeterw.cmd
Starting JMeter without Windows Shell console (default GUI mode)
-
JMeter-n.cmd
Delete a JMX file while running a non-GUI test
-
JMeter-n-r.cmd
Remove a JMX file while running a non-GUI remote test
-
JMeter-t.cmd
Remove a JMX file and load it in GUI mode
-
JMeter-server.bat
Start JMeter in server mode
-
mirror-server.cmd
Run the JMeter image server in non-GUI mode
-
shutdown.cm
Run the close client to gracefully stop the non-GUI instance
-
stoptest.cmd
Run the close client to stop non-GUI instances
On most Linux/UNIX systems
-
JMeter
Start JMeter (default GUI mode). Define some JVM Settings that may not be applicable to all JVMS.
-
JMeter-server
Start JMeter in server mode (call the JMeter script with the appropriate parameters)
-
JMeter.sh
Very basic JMeter scripts (you may need to adjust JVM options such as memory Settings).
-
mirror-server.sh
Run the JMeter image server in non-GUI mode
-
shutdown.sh
Run the close client to gracefully stop the non-GUI instance
-
stoptest.sh
Run the close client to stop non-GUI instances
The JMeter plug-in is installed
-
Go to the JMeter plug-in website and download the JMeter plug-in package
-
Unzip the plugin, find jmeterplugins-extras. jar, and place jmeterplugins-extras. jar in apache-jmeter-5.4.1 \lib\ext.