Preface
The Internet of Things is developing rapidly with an explosive growth momentum. As the scale of equipment continues to grow and business logic becomes more complex, before the IoT platform is officially launched, it is necessary to verify the availability and reliability of the platform when a large number of devices are connected to ensure the quality of the system. Therefore, the value and necessity of IoT performance testing have gradually become prominent.
On the one hand, performance testing provides a basis for evaluating the IoT system and verifies it from multiple dimensions of design indicators, scalability and reliability; on the other hand, performance testing also helps optimize the IoT system, helping to find system performance bottlenecks early , Provide tuning suggestions. In addition, performance testing can also assist in the formulation of capacity plans and provide a reference for future expansion plans.
However, the Internet of Things system features a large amount of access devices, diversified protocols, complex integration architecture, and frequent cross-departmental development and collaboration, which also make the Internet of Things performance test face many challenges. This series of articles will take the IoT platform based on EMQ X as an example to introduce how to use performance testing tools to verify and test platform-related quality indicators.
Selection of test tools-Introduction to JMeter
We chose JMeter as our testing tool.
JMeter is an open source software under the Apache Foundation. It mainly implements performance testing by simulating concurrent loads. It is currently the mainstream performance testing tool in the open source community. It has the following advantages:
- Built-in testing support for multiple protocols, such as TCP, HTTP/HTTPS, etc.
- Provide a flexible plug-in extension mechanism and support third-party extensions to other protocols. For a wide variety of protocols in the Internet of Things system, you only need to customize and develop the required protocol business logic according to the JMeter framework requirements, and then you can easily put it into the JMeter plug-in library, and use JMeter's existing functions to perform the performance test of the protocol.
- Have good community support.
JMeter installation
At present, the latest stable version of JMeter is 5.4.1. Since JMeter is based on Java, the 5.4.1 version of JMeter requires pre-installation of Java 8 and above support (available from the following address: https://www.oracle.com/ java/technologies/downloads ).
After installing Java, download JMeter from the official website: https://jmeter.apache.org/download_jmeter.cgi .
After the download is complete, decompress and enter the bin subdirectory of the decompressed directory. Depending on the operating system, run jmeter.bat (Windows system) or jmeter (Unix system). If all goes well, JMeter's script editing interface will be presented to you:
Next, we take HTTP as an example to see how to use JMeter to build and run a simple test case.
Add a virtual user group (Thread Group): Right-click the test plan> Add> Thread (User)> Thread Group
JMeter uses a single thread to simulate a user, the user group Thread Group refers to a group of users, as a virtual user group that simulates access to the system under test.
The "Thread Number" in "Thread Properties" can be used to configure the number of concurrent users of the virtual user group. The higher the value, the greater the amount of concurrency; the "Number of Cycles" can be used to configure how many tests each virtual user performs.
Add the tested HTTP page: right click on the thread group> Add> Sampler> HTTP request
In the sample test script, we only use the default HTTP request settings to initiate an HTTP request to the bing website. You can make relevant configurations according to the actual situation.
Add a result listener: right-click the thread group> Add> Listener> View the result tree
The listener is not necessary in the actual running performance test, but it can help to visually see the test result in the process of writing the script, which is convenient for debugging. In this sample script, we will use "View Results Tree" to help view the response information of the request.
Run the test.
After saving the test script, click the "Start" button in the operation bar to start running the test script. It is recommended that the number of threads and the number of loops in the thread group be set smaller (for example, within 10) to avoid being banned.
Above, we have completed a simple HTTP test script. You can draw inferences and try other protocol tests. In the next article, we will introduce the various test components of JMeter in more detail, and use them together to build more complex test scenarios.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。