Coder Social home page Coder Social logo

gatling-mqtt's Introduction

Gatling-MQTT

An unofficial Gatling stress test plugin for MQTT.

Usage

Cloning this repository

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

Creating a jar file

Install sbt 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 in build.sbt:

"io.gatling" % "gatling-core" % "2.2.3" % "provided",

and run sbt assembly.

Putting the jar file to lib directory

Put the jar file to lib 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 of mqtt-client for the description of these options. For example, the host option corresponds setHost() method in mqtt-client. That is, you can obtain an option name in this plugin by removing set from a method name in mqtt-client and then making the first character lowercase.

The following options also support Expression:

  • host
  • clientId
  • userName
  • password
  • willTopic
  • willMessage
  • version

Here is a sample simulation file:

import io.gatling.core.Predef._
import org.fusesource.mqtt.client.QoS
import scala.concurrent.duration._

import com.github.mnogu.gatling.mqtt.Predef._

class MqttSimulation extends Simulation {
  val mqttConf = mqtt
    // MQTT broker
    .host("tcp://localhost:1883")

  val scn = 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 of publish() support Expression:

  • topic
  • payload

Here is a bit complex sample simulation file:

import io.gatling.core.Predef._
import org.fusesource.mqtt.client.QoS
import scala.concurrent.duration._

import com.github.mnogu.gatling.mqtt.Predef._

class MqttSimulation extends Simulation {
  val mqttConf = mqtt
    .host("tcp://localhost:1883")
    // clientId: the values of "client" column in mqtt.csv
    //
    // See below for mqtt.csv.
    .clientId("${client}")

  val scn = 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

gatling-mqtt's People

Contributors

benvan avatar jeanadrien avatar mnogu avatar odisseus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gatling-mqtt's Issues

Multiple Publish Messages

Hi,

I would like to send multiple publish message with on connection. At the moment there is always a connect -> publish -> disconnect. I would like to do something like connect -> publish1 -> pause -> publish2 -> disconnect.
In order to do that, I need so save the connections somewhere. Is this possible, what could be a good way for that?

Thx for support!

Connecting to websocket

Hi

Any advise on what would it take (where are the traps if any) to be able to benchmark MQTT server over websocket ws://localhost:8083 (instead of tcp)
i see there is no support for connection upgrade to ws, any specific reason we don't have that?
thanks!

Gatling updated to 3.0.3

I had tried this against Gatling 3.0.3 and it is not working.

I had fixed issues of compilation.

Provide me the rights to generate new branch?

How to not close connection after each publish

Is there a way to keep the connections opened during the whole benchmark process or is it just not possible because of Gatling architecture? I think that closing the connexion after each request is a normal behavior for a web server but not really for a MQTT broker.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.