- Notifications
You must be signed in to change notification settings - Fork56
A Gatling stress test plugin for MQTT
License
mnogu/gatling-mqtt
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An unofficialGatling stress test pluginforMQTT.
$ git clone https://github.com/mnogu/gatling-mqtt.git$ cd gatling-mqtt
Installsbt 0.13 if you don't have.And create a jar file:
$ sbt assembly
If you want to change the version of Gatling used to create a jar file,change the following line inbuild.sbt
:
"io.gatling"%"gatling-core"%"2.2.3"%"provided",
and runsbt assembly
.
Put the jar file tolib
directory in Gatling:
$ cp target/scala-2.11/gatling-mqtt-assembly-*.jar /path/to/gatling-charts-highcharts-bundle-2.2.*/lib
$ cp gatling-mqtt/src/test/scala/com/github/mnogu/gatling/mqtt/test/MqttSimulation.scala /path/to/gatling-charts-highcharts-bundle-2.2.*/user-files/simulations$ cd /path/to/gatling-charts-highcharts-bundle-2.2.*$ vi user-files/simulations/MqttSimulation.scala
This plugin supports the following options:
- host
- clientId
- cleanSession
- keepAlive
- userName
- password
- willTopic
- willMessage
- willQos
- willRetain
- version
- connectAttemptsMax
- reconnectAttemptsMax
- reconnectDelay
- reconnectDelayMax
- reconnectBackOffMultiplier
- receiveBufferSize
- sendBufferSize
- trafficClass
- maxReadRate
- maxWriteRate
See the document ofmqtt-clientfor the description of these options.For example, thehost
option correspondssetHost()
method in mqtt-client.That is, you can obtain an option name in this pluginby removingset
from a method name in mqtt-clientand then making the first character lowercase.
The following options also supportExpression:
- host
- clientId
- userName
- password
- willTopic
- willMessage
- version
Here is a sample simulation file:
importio.gatling.core.Predef._importorg.fusesource.mqtt.client.QoSimportscala.concurrent.duration._importcom.github.mnogu.gatling.mqtt.Predef._classMqttSimulationextendsSimulation {valmqttConf= mqtt// MQTT broker .host("tcp://localhost:1883")valscn= scenario("MQTT Test") .exec(mqtt("request")// topic: "foo"// payload: "Hello"// QoS: AT_LEAST_ONCE// retain: false .publish("foo","Hello",QoS.AT_LEAST_ONCE, retain=false)) setUp( scn .inject(constantUsersPerSec(10) during(90 seconds))) .protocols(mqttConf)}
The following parameters ofpublish()
support Expression:
- topic
- payload
Here is a bit complex sample simulation file:
importio.gatling.core.Predef._importorg.fusesource.mqtt.client.QoSimportscala.concurrent.duration._importcom.github.mnogu.gatling.mqtt.Predef._classMqttSimulationextendsSimulation {valmqttConf= mqtt .host("tcp://localhost:1883")// clientId: the values of "client" column in mqtt.csv//// See below for mqtt.csv. .clientId("${client}")valscn= scenario("MQTT Test")// The content of mqtt.csv would be like this://// client,topic,payload// clientId1,topic1,payload1// clientId2,topic2,payload2// ... .feed(csv("mqtt.csv").circular) .exec(mqtt("request")// topic: the values of "topic" column in mqtt.csv// payload: the values of "payload" column in mqtt.csv// QoS: AT_LEAST_ONCE// retain: false .publish("${topic}","${payload}",QoS.AT_LEAST_ONCE, retain=false)) setUp( scn .inject(constantUsersPerSec(10) during(90 seconds))) .protocols(mqttConf)}
After starting an MQTT broker, run a stress test:
$ bin/gatling.sh
Apache License, Version 2.0
About
A Gatling stress test plugin for MQTT
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.