Skip to content

Commit 0edf972

Browse files
committed
merge code from sep_conn to master
2 parents 34fef1b + af09e2f commit 0edf972

29 files changed

+1088
-790
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.settings/
44
target/
55
.metadata/
6+
.DS_Store
445 KB
Binary file not shown.

README.md

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,89 @@
1-
# Release
2-
The version 1.0 is released at 18th, Dec, 2017. Now the plugin supports share MQTT connection in the same threadgroup. Also, this version fixed some of bugs reported in the community.
1+
# mqtt-jmeter Overview
2+
MQTT JMeter Plugin extends your JMeter's capability to test against MQTT protocol, just as easy as ordinary HTTP protocal.
33

4-
# mqtt-jmeter
5-
MQTT JMeter Plugin, it's used for testing MQTT protocol. The plugin was used for EMQ's performance benchmark test, and here is [report link](https://github.com/emqtt/emq-xmeter-cn).
6-
The plugin is developed and maintained by [XMeter](https://www.xmeter.net). XMeter is a professional performance testing service provider.
4+
It has been used to benchmark EMQ server performance, and here is the [report link](https://github.com/emqtt/emq-xmeter-cn).
5+
6+
This plugin is developed and maintained by [XMeter](https://www.xmeter.net). XMeter is a professional performance testing service provider.
77

88
# Install instruction
9-
The plugin is a standard JMeter plugin. You can download the latest version of mqtt-jmeter from [here](https://github.com/emqtt/mqtt-jmeter/releases), and then copy the downloaded JAR files into $JMETER_HOME/lib/ext folder. After restart the JMeter, then you can see the 3 samplers provided by this plugin.
9+
The plugin is a standard JMeter plugin. You can download the latest version of mqtt-jmeter from [here](https://github.com/emqtt/mqtt-jmeter/releases), and then copy the downloaded JAR files into $JMETER_HOME/lib/ext folder. After restarting the JMeter, you can see "MQTT samplers" provided by this plugin.
1010

11-
We recommend to use JMeter 3.0 or above.
11+
To use this plugin, we recommend you to install JMeter 3.2 or above.
1212

1313
## Build from source code
1414

1515
If you'd like to build binary by yourself, please clone the project and run 'mvn install'. Maven will download some JMeter dependency binary files, so the build elapsed time will up to your network status.
1616

1717
# How to use
18-
The plugin includes 3 samplers:
18+
The plugin includes 4 samplers:
1919

20-
- Connection sampler, which can be used for connection mock. For example, in a large scale system, there could have lots of backend connections with no data transimission except some hearbeat signal. The sampler can be used in this case.
20+
- Connect sampler: Initiate MQTT server connection on behalf of a device. In addition to normal connection setup, this sampler can be used to simulate massive "background" connections(no data transimission but regular hearbeat signals) to the designated MQTT server or cluster system.
2121

22-
- Pub sampler, which can be used for publish message to MQTT server.
22+
- Pub sampler: publish various messages to the target MQTT server.
2323

24-
- Sub sampler, which can be used for sub message from MQTT server.
24+
- Sub sampler: subscribe message(s) from target MQTT server.
2525

26-
If MQTT JMeter plugin is installed successfully, then open JMeter and below 3 MQTT samplers can be found under 'Sampler'.
26+
- DisConnect sampler: Reset the connection to target MQTT server.
2727

28-
![mqtt_jmeter_plugin](screenshots/mqtt_jmeter_plugin.png)
28+
If MQTT JMeter plugin is successfully installed, you can find these MQTT samplers under JMeter 'Sampler' context menu.
2929

30+
![mqtt_jmeter_plugin](screenshots/mqtt_jmeter_plugin.png)
3031

31-
## Connection sampler
3232

33+
## Connect Sampler
3334
![conn_sampler](screenshots/conn_sampler.png)
3435

3536
### MQTT connection
3637

3738
This section includes basic connection settings.
3839

39-
- **Server name or IP**: The server install with MQTT server, it can be either IP address or server name. The default value is 127.0.0.1. **DO NOT** add protocol (e.g. tcp:// or ssl://) before server name or IP address!
40+
- **Server name or IP**: The MQTT target to be tested. It can be either IP address or server name. The default value is 127.0.0.1. **DO NOT** add protocol (e.g. tcp:// or ssl://) before server name or IP address!
4041

41-
- **Port number**: The port that opens by MQTT server, the default value is 1883 for TCP protocol, and normally 8883 for SSL protocol.
42+
- **Port number**: The port opened by MQTT server. Typically 1883 is for TCP protocol, and 8883 for SSL protocol.
4243

43-
- **MQTT version**: The MQTT version, default is 3.1, and another option is 3.1.1. Sometimes the version is probably required for establish connection to [Azure IoTHub](https://github.com/emqtt/mqtt-jmeter/issues/21).
44+
- **MQTT version**: The MQTT version, default is 3.1, and another option is 3.1.1. Sometimes we found version 3.1.1 is required to establish connection to [Azure IoTHub](https://github.com/emqtt/mqtt-jmeter/issues/21).
4445

4546
- **Timeout(s)**: The connection timeout seconds while connecting to MQTT server. The default is 10 seconds.
4647

4748
### MQTT Protocol
4849

49-
The sampler supports for 2 protocols, TCP and SSL. For the SSL protocol, it includes normal SSL and dual SSL authentication.
50+
The sampler supports 2 protocols, TCP and SSL. For SSL protocol, it includes normal SSL and dual SSL authentication.
5051

51-
If **'Dual SSL authentication'** is checked, please follow 'Certification files for SSL/TLS connections' at end of this doc to set the client SSL configuration.
52+
If **'Dual SSL authentication'** is checked, please follow 'Certification files for SSL/TLS connections' at end of this doc to set the client SSL configuration properly.
5253

5354
![protocol_setting](screenshots/protocol_setting.png)
5455

5556
### User authentication
5657

5758
User can configure MQTT server with user name & password authentication, refer to [EMQ user name and password authentication guide](http://emqtt.com/docs/v2/guide.html#id3).
5859

59-
- **User name**: If MQTT server configured with user name, then specify user name here.
60+
- **User name**: If MQTT server is configured with user name, then specify user name here.
6061

61-
- **Password**: If MQTT server configured with password, then specify password here.
62+
- **Password**: If MQTT server is configured with password, then specify password here.
6263

6364
### Connection options
6465

65-
- **ClientId**: Identification of the client. (Default value is 'conn_'.) If 'Add random client id suffix' is selected, JMeter plugin will append generated uuid as suffix to represent the client, otherwise, the text of 'ClientId' will be passed as 'clientId' of current connection.
66+
- **ClientId**: Identification of the client, i.e. virtual user or JMeter thread. Default value is 'conn_'. If 'Add random client id suffix' is selected, JMeter plugin will append generated uuid as suffix to represent the client, otherwise, the text of 'ClientId' will be passed as 'clientId' of current connection.
6667

6768
- **Keep alive(s)**: Ping packet send interval in seconds. Default value is 300, which means each connection sends a ping packet to MQTT server every 5 minutes.
6869

69-
- **Connection keep time(s)**: The value is to set the connection elapsed time after successfully establishing MQTT connection. The default value is 1800 seconds, which means that the connection will be alive within 30 minutes.
70-
7170
- **Connect attampt max**: The maximum number of reconnect attempts before an error is reported back to the client on the first attempt by the client to connect to a server. Set to -1 to use unlimited attempts. Defaults to 0.
7271

7372
- **Reconnect attampt max**: The maximum number of reconnect attempts before an error is reported back to the client after a server connection had previously been established. Set to -1 to use unlimited attempts. Defaults to 0.
7473

75-
## Pub sampler
76-
![pub_sampler](screenshots/pub_sampler.png)
77-
78-
For **MQTT connection**, **User authentication**, **Connection options** and **MQTT version** section settings, please refer to *Connection sampler* for more detailed information.
79-
80-
- **Share conn in thread**: This option allows all of pub and sub samplers in the same threadgroup shares the same connection, this can simulate the situation of one device can be either pub or sub. For example, one IoT device can either send message to server, or receive the control message from server. Please notice, only those samplers in the same threadgroup check this option, then the connection will be shared. Also, the connection settings of first pub/sub sampler in the threadgroup will be used for shared connections, rests of connection settings in other samplers will be ignored if the option is checked. Please take a look at following 3 examples.
81-
82-
```
83-
ThreadGroupSample1
84-
PubSampler1 (shared connection), the connection settings will be used for the shared connection.
85-
SubSampler1 (shared connection), use shared connection of PubSampler1, the connection setting of this sampler will be ignored.
86-
87-
88-
ThreadGroupSample2
89-
PubSampler1 (shared connection), the connection settings will be used for the shared connection.
90-
SubSampler1 (not shared connection), another connection will be created with configuration in this sampler.
9174

75+
## Pub Sampler
76+
![pub_sampler](screenshots/pub_sampler.png)
9277

93-
ThreadGroupSample3
94-
PubSampler1 (not shared connection), one connection will be created for the connection setting in this sampler.
95-
SubSampler1 (shared connection), the connection settings will be used for the shared connection.
96-
SubSampler2 (shared connection), use shared connection of SubSampler1, so the connection setting of this sampler will be ignored.
97-
98-
```
78+
Pub sampler reuses previously established connection (by Connect sampler) to publish a message. If connection is not ready at this moment, pub sampler will just fail immediately.
9979

10080
### Pub options
10181

10282
- **QoS level**: The available QoS value, 0 is AT_MOST_ONCE, 1 is AT_LEAST_ONCE and 2 is EXACTLY_ONCE.
10383

104-
- **Topic name**: The topic name that the message will send to.
84+
- **Topic name**: Name of the topic that the message will be sent to.
10585

106-
- **Add timestamp in payload**: Add timestamp in the payload or not. If the checkbox is enabled, then timestamp of running pub sampler will be added ahead of payload. Mostly it can be used together with **Sub sampler** to calculate message latency time.
86+
- **Add timestamp in payload**: Add timestamp in the payload or not. If the checkbox is enabled, then timestamp of running pub sampler will be added before real payload. Mostly it's used together with **Sub sampler** to calculate message latency time.
10787

10888
### Payloads
10989

@@ -117,18 +97,17 @@ ThreadGroupSample3
11797

11898
![payload_setting](screenshots/payload_setting.png)
11999

120-
## Sub sampler
121-
![sub_sampler](screenshots/sub_sampler.png)
122100

123-
For **MQTT connection**, **User authentication**, **Connection options** and **MQTT version** section settings, please refer to *Connection sampler* for more detailed information.
101+
## Sub Sampler
102+
![sub_sampler](screenshots/sub_sampler.png)
124103

125-
For **Share conn in thread**, please refer to the Pub sampler.
104+
Sub sampler reuses previously established connection (by Connect sampler) to subscribe message(s). If connection is not ready at this moment, sub sampler will just fail immediately.
126105

127106
### Sub options
128107

129108
- **QoS level**: The available QoS value, 0 is AT_MOST_ONCE, 1 is AT_LEAST_ONCE and 2 is EXACTLY_ONCE.
130109

131-
- **Topic name**: The topic name that subscriber will subscribe to. If want to subscribe multiple topics, please use comma to separate the different topics.
110+
- **Topic name(s)**: A list of topic names (comma-separated) that will be subscribed to.
132111

133112
- **Payload includes timestamp**: If the checkbox is enabled, then it means the payload includes timestamp. It can be used to calcuate the message latency time.
134113

@@ -138,9 +117,29 @@ message_latency = timestamp_in_sub_when_receive_msg - timestamp_in_payload (time
138117
Please notice, if the machine publish message is not the same as subscriber, then the calculated message latency time is not accurate.
139118
It's because the time is almost not the same in different machines. So the latency time calculated by sub sampler could be only be a reference.
140119
```
141-
- **Sample on**: It controls how to sample. The default value is '**elapsed with specified time(ms)**', which means a sub sampler will be occurred every ms specified in next text field (default is 1000ms). During the 1000 ms, multiple messages could be received, and result in report is the summarized data during 1000 ms. If the value is set to 2000, then means summarized report during 2000 ms. Another option is '**received number of message**', which means a sub sampler will be occurred when received number of message that specified in next text field (default is 1).
120+
- **Sample on**: It controls how to sample. The default value is '**elapsed with specified time(ms)**', which means a sub sampler will occur every specified milli-seconds (default is 1000ms). During the 1000 ms, multiple messages could be received, and result in report is the summarized data during 1000 ms. If the value is set to 2000, then means summarized report during 2000 ms. Another option is '**number of received messages**', which means a sub sampler will occur after receiving these specified number of messages (default is 1).
121+
122+
- **Debug response**: If checked, the received message will be print in response. It's recommended to enable this option when you debug your script.
123+
124+
125+
## DisConnect Sampler
126+
![disconn_sampler](screenshots/disconn_sampler.png)
142127

143-
- **Debug response**: If it's checked, then the received message will be print in response. It's recommend to enable it when you're debugging script.
128+
This sampler is very simple, it just clear the previous created connection. Therefore, next time you run Connect sampler, it will initiate a new MQTT server connection for you. As you can imagine, Disconnect sample will fail immediately if no connection is detected at this moment.
129+
130+
131+
## Example JMeter Scripts
132+
As a reference, you can check out some example scripts in SampleScripts folder.
133+
1) background_connection.jmx:
134+
Simulate massive background MQTT connections to server. You can optionally subscribe to a topic when connecting. (Please modify "xmeter_runtime_vars" UDV to fit your needs.)
135+
136+
2) pubsub_unidirection.jmx:
137+
Demonstrate how sub sampler can get messages from corresponding pub sampler, with two JMeter user groups and delay between opertions.
138+
139+
3) pubsub_bidirection.jmx:
140+
Demonstrate how a set of Devices and Mobiles exchange messages in both directions.
141+
142+
![example_scripts](screenshots/example_scripts.png "example script structure")
144143

145144
## Certification files for SSL/TLS connections
146145
After deploying emqtt server, you get the following OOTB (out of the box) SSL/TLS certification files under ${EMQTTD_HOME}/etc/certs directory:
@@ -170,3 +169,4 @@ openssl pkcs12 -export -inkey client-key.pem -in client-cert.pem -out client.p12
170169
#### Specify key store, client certfication and corresponding pass phrases in plugin sampler:
171170

172171
![ssl_conn](screenshots/ssl_conn.png)
172+

0 commit comments

Comments
 (0)