mqtt-jmeter

https://github.com/emqtt/mqtt-jmeter

mqtt-jmeter

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. The plugin is developed and maintained by XMeter. XMeter is a professional performance testing service provider.

Install instruction

The plugin is a standard JMeter plugin. You can download the latest version of mqtt-jmeter from here, 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.

We recommend to use JMeter 3.0 or above.

Build from source code

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.

How to use

The plugin includes 3 samplers:

  • 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.

  • Pub sampler, which can be used for publish message to MQTT server.

  • Sub sampler, which can be used for sub message from MQTT server.

If MQTT JMeter plugin is installed successfully, then open JMeter and below 3 MQTT samplers can be found under 'Sampler'.

Connection sampler

MQTT connection

This section includes basic connection settings.

  • 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:// etc) before server name or IP address!

  • Port number: The port that opens by MQTT server, the default value is 1883 for TCP protocol, and normally 8883 for SSL protocol.

  • Timeout(s): The connection timeout seconds while connecting to MQTT server. The default is 10 seconds.

MQTT Protocol

The sampler supports for 2 protocols, TCP and SSL. For the SSL protocol, it includes normal SSL and dual SSL authentication.

If 'Dual SSL authentication' is checked, please follow 'Certification files for SSL/TLS connections' at end of this doc configure client SSL configuration.

User authentication

User can configure MQTT server with user name & password authentication, refer to EMQ user name and password authentication guide.

  • User name: If MQTT server configured with user name, then specify user name here.

  • Password: If MQTT server configured with password, then specify password here.

Connection options

  • ClientId: The client id, the plugin will add generated uuid after the prefix to identify the client if keep 'Add random client id suffix' selected. Default value is 'conn_'. If 'Add random client id suffix' is not selected, then the text of 'ClientId' will be passed as 'clientId' of current connection.

  • 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.

  • Connection keep time(s): The value is for setting the connection elapsed time after successfully established MQTT connection. The default value is 1800 seconds, which means that the connection will be alive within 30 minutes.

  • 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.

  • 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.

Pub sampler

For MQTT connection, User authentication and Connection options section settings, please refer to Connection sampler for more detailed information.

Pub options

  • QoS level: The available QoS value, 0 is AT_MOST_ONCE, 1 is AT_LEAST_ONCE and 2 is EXACTLY_ONCE.

  • Topic name: The topic name that the message will send to.

  • 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.

Payloads

Message type: 3 types of message can be used.

  • String: The normal string that sent to MQTT server. It can also be a JMeter variable.

  • Hex string: The hex string that sent to MQTT server. The chars input must be [0-9] or [A-F] or [a-f]. The hex string will be converted to binary and send to server. It can also be a JMeter variable.

  • Random string with fixed length: Refer to below screenshot. If the option is selected, then it requires user to input 'Length'. The length means the auto generated string length. Default is 1024, which means generated a 1kb size of random string.

Sub sampler

For MQTT connection, User authentication and Connection options section settings, please refer to Connection sampler for more detailed information.

Sub options

  • QoS level: The available QoS value, 0 is AT_MOST_ONCE, 1 is AT_LEAST_ONCE and 2 is EXACTLY_ONCE.

  • Topic name: The topic name that subscriber will subscribe to.

  • 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.

message_latency = timestamp_in_sub_when_receive_msg - timestamp_in_payload (timestamp in pub machine when sending out message)

Please notice, if the machine publish message is not the same as subscriber, then the calculated message latency time is not accurate.
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.
  • 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).

  • 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.

Certification files for SSL/TLS connections

After deploying emqtt server, you get the following OOTB (out of the box) SSL/TLS certification files under ${EMQTTD_HOME}/etc/certs directory:

  1. cacert.pem : the self-signed CA certification

  2. cert.pem : certification for emqtt server

  3. client-cert.pem : certfication for emqtt client in order to connect to server via SSL/TLS connection. In this jmeter plugin case, the client implies jmeter "virtual user"

  4. client-key.pem key.pem : key files to protect client and server certification respectively

[Note:] The above server and client certifications are both issued by the self-signed CA. If you would like to use official certifications for your EMQTT deployment, please check out relevant document to configure it.

We will use the OOTB test certfications (as an example) to show you how to prepare the required certification files for this EMQTT JMeter plugin.

export PATH=$PATH:<YOUR_JDK_HOM>/bin

keytool -import -alias cacert -keystore emqtt.jks -file cacert.pem -storepass <YOUR_PASSWORD> -trustcacerts -noprompt
keytool -import -alias client -keystore emqtt.jks -file client-cert.pem -storepass <YOUR_PASSWORD>
keytool -import -alias server -keystore emqtt.jks -file cert.pem -storepass <YOUR_PASSWORD> openssl pkcs12 -export -inkey client-key.pem -in client-cert.pem -out client.p12 -password pass:<YOUR_PASSWORD>

Specify key store, client certfication and corresponding pass phrases in plugin sampler:

本文转自:  清明-心若淡定   https://www.cnblogs.com/saryli/p/6927861.html

mqtt-jmeter的更多相关文章

  1. jmeter如何进行MQTT性能测试(测试前期准备二,MQTT插件及协议了解)

    jmeter插件下载地址及使用,已经有大佬总结好了 大佬的博客地址: https://blog.csdn.net/yellowanwu/article/details/50889677 添加线程组:添 ...

  2. 转:基于Jmeter的MQTT测试插件

    基于Jmeter的MQTT测试插件-上 1. Jmeter插件简介 Apache JMeter是Apache组织开发的基于Java的压力测试工具.下载 用于对软件做压力测试,它最初被设计用于Web应用 ...

  3. MQTT压力测试工具之JMeter插件教程

    基于Jmeter的MQTT测试插件-上 1. Jmeter插件简介 Apache JMeter是Apache组织开发的基于Java的压力测试工具.下载 用于对软件做压力测试,它最初被设计用于Web应用 ...

  4. jmeter如何进行MQTT性能测试(测试前期准备一,性能测试需求)

    接到一个有关MQTT的性能测试任务,把查找资料到解决问题的过程都记录.分享下 首先先科普下性能测试中相关术语的解释及 说到性能测试.负载测试.压力测试.并发测试,很多人都是混合使用,或者一会叫压力测试 ...

  5. 运用MQTT-JMeter插件测试MQTT服务器性能

    今天我们介绍XMeter团队带来的新版MQTT-JMeter插件,您可以更为方便地添加MQTT连接.发布.订阅取样器,构造组合的应用场景,例如背景连接.多发少收.少发多收,计算消息转发时延等.利用该插 ...

  6. MQTT消息队列压力测试

    环境准备: jmeter插件下载:mqttxmeter1.0.1jarwithdependencies.jar 把MQTT插件放在 %JMeter_Home%/lib/ext下.重启jmeter. M ...

  7. 海鑫智圣:物联网漫谈之MQTT协议

    什么是MQTT协议 MQTT(消息队列遥测传输协议)是IBM在1999年专门针对物联网等应用场景来制订的轻量级双向消息传输协议,它主要是为了解决物联网上使用到的设备的互相通信的问题,以及这些设备与后端 ...

  8. jmeter之线程组的使用

    线程组 在使用jmeter性能测试时,我们都得先添加个线程组,右键testplan-->添加-->Threads-->线程组.在线程组下执行. 问题:为了能够让jmeter在做性能测 ...

  9. 从Fiddler抓包到Jmeter接口测试(简单的思路)

    备注:本文为博主的同事总结的文章,未经博主允许不得转载. Fiddler下载和配置安装 从网上下载fiddler的安装包即可,直接默认,一直点击下一步,直至安装完成. 安装完成后直接打开Fiddler ...

随机推荐

  1. 启动和停止mysql的正确姿势

    1.如果是用脚本起的.那就用脚本停 2.最好用mysql_safe起,mysqladmin -uroot -p shutdown -S /tmp/mysql.sock停 mysqld_safe --d ...

  2. python自学第5天,集合,文件读写

    #!/usr/bin/env python #-*- coding:utf-8 -*- # Author:Hunter Yi s={1,1,1,2,3,4,5} print(s) #集合,去重 #关系 ...

  3. Java Editplus编译环境配置

    java jdk 安装win10 配置:此电脑--属性--高级系统设置--环境变量--系统变量-->新建--变量名--JAVA_HOME 变量值--浏览目录--jdk安装路径jdk...--&g ...

  4. certbot自动在ubuntu16.04的nginx上部署let's encrypt免费ssl证书

    终结CA收费时代,让互联网更安全 Install On Ubuntu systems, the Certbot team maintains a PPA. Once you add it to you ...

  5. 【Python】Excel操作-1

    #练习:创建Excel 如果要创建的Excel已经存在并打开,会报错 from openpyxl import Workbook wb=Workbook() #创建文件对象 ws=wb.active ...

  6. 对于java自定义的工具类的提炼 注意事项

    1.工具类的方法都用static修饰. 因为工具类一般不创建对象,直接类名.方法()使用 2.一些 定义的常亮需要 public static final 修饰. 3.一些与数据库的连接之类的设定 , ...

  7. [JetBrains注册] 利用教育邮箱注册JetBrains产品(pycharm、idea等)的方法

    我们在使用JetBrains的一些产品时,大多使用网上的一些key去注册或者pojie的,但是由于提供这些key的服务器并不能保证稳定可用,所以可能一段时间我们使用的ide又需要重新pojie. 这里 ...

  8. 【linux】ARM板子开启浮点和neon加速

    参考 1. ARM平台NEON指令的编译和优化; 2. 交叉编译器 arm-linux-gnueabi 和 arm-linux-gnueabihf 的区别; 3. https://blog.csdn. ...

  9. 单调栈的运用-bzoj1012(代码转载-http://hzwer.com/1130.html)

    Description 现在请求你维护一个数列,要求提供以下两种操作: . 查询操作.语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值.限制:L不超过当前数列的长度. . 插 ...

  10. 2017.7.11 fuse工作原理

    FUSE的工作原理如图所示.假设基于FUSE的用户态文件系统hello挂载在/tmp/fuse目录下.当应用层程序要访问/tmp/fuse下的文件时,通过glibc中的函数进行系统调用,处理这些系统调 ...