Skip to main content

MQTT Conformance/Interoperability Testing

The aim of this project is to create a means by which it is easy to test both MQTT servers and client libraries, to ensure

  • they conform to the MQTT 3.1.1 standard
  • and hence they can interoperate with each other, with the minimum of misunderstandings.

The test material is all written in Python version 3 (Python 2.x is not sufficient). The component of the test material are:

  • an MQTT conformance statements spreadsheet, extracted from the standard
  • a test broker, against which client tests can be run
  • a test client, for very basic testing of MQTT server 3.1.1 support
  • a model-based testing package, which will be used to generate the full tests, in due course

Source

https://github.com/eclipse/paho.mqtt.testing

Download

Use git to clone the repository

git clone https://github.com/eclipse/paho.mqtt.testing.git

Documentation

More detailed information is available here.

Getting Started

A test or "model" MQTT server is in the package mqtt/broker. You can run it with the command:

python3 startbroker.py
and if running successfully, you will see this:
INFO 20140203 220904 MQTT 3.1.1 Paho Test Broker
INFO 20140203 220904 Optional behaviour, publish on pubrel: True
INFO 20140203 220904 Optional behaviour, single publish on overlapping topics: True
INFO 20140203 220904 Optional behaviour, drop QoS 0 publications to disconnected clients: True
INFO 20140203 220904 Starting the MQTT server on port 1883

To test an MQTT Client Library, start the test broker, as described above. Run your test suite against this broker. Note the coverage achieved when you stop the broker. Try and get more coverage!

The client_test.py program, as described above, is a good basis for the sort of coverage that ought to be achieved. With client libraries that ensure the data that is sent to the server consists of well-formed MQTT packets, the tests are likely hit the good paths in the broker rather than the exceptions. So you don't need to worry if your exception coverage is low or non-existent.

To test an MQTT Server, run:

python3 client_test.py [hostname:port]
as a first test. If hostname:port are not specified, localhost:1883 is assumed.

Back to the top