Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Mar 22, 2022. It is now read-only.
/gatling-mqttPublic archive

A Gatling stress test plugin for MQTT

License

NotificationsYou must be signed in to change notification settings

mnogu/gatling-mqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An unofficialGatling stress test pluginforMQTT.

Usage

Cloning this repository

$ git clone https://github.com/mnogu/gatling-mqtt.git$ cd gatling-mqtt

Creating a jar file

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.

Putting the jar file to lib directory

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

Creating a simulation file

$ 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)}

Running a stress test

After starting an MQTT broker, run a stress test:

$ bin/gatling.sh

License

Apache License, Version 2.0

About

A Gatling stress test plugin for MQTT

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp