ThingsBoard performance tests
Project that is able to stress test ThingsBoard server with a huge number of MQTT messages published simultaneously from different devices.
To run test against ThingsBoard first create plain text file to set up test configuration (in our example configuration file name is .env):
touch .envEdit this .env file:
nano .envand put next content into the text file (modify it according to your test goals):
REST_URL=http://IP_ADDRESS_OF_TB_INSTANCE:9090
# IP_ADDRESS_OF_TB_INSTANCE is your local IP address if you run ThingsBoard on your dev machine in docker
# Port should be modified as well if needed
[email protected]
REST_PASSWORD=tenant
MQTT_HOST=IP_ADDRESS_OF_TB_INSTANCE
# IP_ADDRESS_OF_TB_INSTANCE is your local IP address if you run ThingsBoard on your dev machine in docker
MQTT_PORT=1883
MQTT_SSL_ENABLED=false
MQTT_SSL_KEY_STORE=mqttclient.jks
MQTT_SSL_KEY_STORE_PASSWORD=
# custom topic,if empty, use the default topic same as MQTT_API, is v1/devices/me/telemetry or v1/devices/me/attributes
MQTT_PUBLISH_TOPIC=infinovaiot/mqtt
MQTT_QOS=1
# Test API to use - cassandra,js-executor,device or gateway. In case device data is send directly to devices, in case gateway - over MQTT gateway API
# In case js-executor, test performance of js-executor,TB_KAFKA_SERVERS is required.
# In case cassandra, test performance of cassandra
TEST_API=device
# Device API to use - MQTT or HTTP. HTTP applicable only in case TEST_API=device
DEVICE_API=MQTT
DEVICE_START_IDX=0
DEVICE_END_IDX=10
DEVICE_CREATE_ON_START=true
DEVICE_DELETE_ON_COMPLETE=true
GATEWAY_START_IDX=0
GATEWAY_END_IDX=3
GATEWAY_CREATE_ON_START=true
GATEWAY_DELETE_ON_COMPLETE=true
WARMUP_ENABLED=false
# Type of the payload to send: DEFAULT, SMART_TRACKER, SMART_METER, CUSTOM
# RANDOM - TODO: add description
# SMART_TRACKER - sample payload: {"latitude": 42.222222, "longitude": 73.333333, "speed": 55.5, "fuel": 92, "batteryLevel": 81}
# SMART_METER - sample payload: {"pulseCounter": 1234567, "leakage": false, "batteryLevel": 81}
# COUSTOM - custom payload format,sample payload: see TEST_CUSTOM_PAYLOAD
TEST_PAYLOAD_TYPE=SMART_TRACKER
# keyxx:type, where keyxx is the key name, type is the value type, the value is assigned internally.
TEST_CUSTOM_PAYLOAD=key1:int,key2:double,key3:float,key4:boolean,key5:string,key6:time
TEST_ENABLED=true
# true - send data to devices by device ids, false - select random devices from the list
TEST_SEQUENTIAL=true
MESSAGES_PER_SECOND=1000
DURATION_IN_SECONDS=10
# sample interval of the stastics,print the samples on test finishing.
SAMPLE_INTERVAL_IN_SECONDS=1
UPDATE_ROOT_RULE_CHAIN=false
REVERT_ROOT_RULE_CHAIN=false
RULE_CHAIN_NAME=root_rule_chain_ce.json
# kafka bootstrap servers
TB_KAFKA_SERVERS=localhost:9092
Where:
REST_URL- Rest URL of the TB instanceREST_USERNAME- Login of the userREST_PASSWORD- Password of the userMQTT_HOST- URL of the ThingsBoard MQTT brokerMQTT_PORT- Port of the ThingsBoard MQTT brokerDEVICE_API- Use MQTT or HTTP Device API for send messagesDEVICE_START_IDX- First index of the device that is going to be used in the test. Token of the device is going to be index of this device during testDEVICE_END_IDX- Last index of the device that is going to be used in the testDEVICE_CREATE_ON_START- Create devices before testDEVICE_DELETE_ON_COMPLETE- Delete devices after test, there were created on start of the testMESSAGES_PER_SECOND- Number of the messages to be published per second to ThingsBoardDURATION_IN_SECONDS- Number of seconds run of the testMQTT_SSL_ENABLED- Enable/disable ssl for MQTTMQTT_SSL_KEY_STORE- MQTT key store file locationMQTT_SSL_KEY_STORE_PASSWORD- MQTT key store file password
Once params are configured to run test simple type from the folder where configuration file is located:
docker run -it --env-file .env --name tb-perf-test thingsboard/tb-ce-performance-test:3.0.0