This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ThingsBoard Performance Tests — a Spring Boot application that stress-tests ThingsBoard IoT platform by simulating massive concurrent device message publishing over MQTT, HTTP, and LwM2M protocols.
Build (Maven, Java 17 required):
mvn clean package -DskipTestsRun locally (after build):
java -jar target/tb-ce-performance-tests.jarBuild Docker image:
cd docker
docker buildx build --no-cache --pull -t thingsboard/tb-ce-performance-test:latest .Run via Docker (most common usage):
docker run -it --rm --network host --pull always --log-driver none \
--env REST_URL=http://127.0.0.1:8080 \
--env MQTT_HOST=127.0.0.1 \
--env DEVICE_END_IDX=1000 \
--env MESSAGES_PER_SECOND=50 \
--env DURATION_IN_SECONDS=300 \
--env TEST_PAYLOAD_TYPE=SMART_METER \
thingsboard/tb-ce-performance-test:latestOr with an env file:
docker run -it --env-file .env --name tb-perf-test thingsboard/tb-ce-performance-test:latestAll configuration is driven by environment variables mapped in src/main/resources/tb-ce-performance-tests.yml. Key variables:
| Variable | Default | Description |
|---|---|---|
REST_URL |
http://localhost:8080 |
ThingsBoard REST API URL |
REST_USERNAME |
tenant@thingsboard.org |
TB login |
REST_PASSWORD |
tenant |
TB password |
MQTT_HOST |
localhost |
MQTT broker host |
MQTT_PORT |
1883 |
MQTT broker port (8883 for TLS) |
MQTT_SSL_ENABLED |
false |
Enable MQTT TLS |
DEVICE_API |
MQTT |
Device protocol: MQTT, HTTP, or LWM2M |
TEST_API |
device |
Test mode: device, gateway, or lwm2m |
DEVICE_START_IDX |
0 |
First device index |
DEVICE_END_IDX |
1000 |
Last device index |
DEVICE_CREATE_ON_START |
true |
Create devices before test |
DEVICE_DELETE_ON_COMPLETE |
false |
Delete devices after test |
MESSAGES_PER_SECOND |
1000 |
Target message throughput |
DURATION_IN_SECONDS |
300 |
Test duration |
TEST_PAYLOAD_TYPE |
SMART_METER |
Payload type: DEFAULT, SMART_TRACKER, SMART_METER, INDUSTRIAL_PLC |
TEST_PAYLOAD_DATAPOINTS |
60 |
Datapoints per message (INDUSTRIAL_PLC only) |
WARMUP_ENABLED |
true |
Run warmup phase before test |
UPDATE_ROOT_RULE_CHAIN |
false |
Replace TB root rule chain with a counter rule chain during test |
ALARMS_PER_SECOND |
1 |
Alarm messages per second |
PerformanceTestApplication— Spring Boot main class, loadstb-ce-performance-tests.ymlPerformanceTestRunner—ApplicationRunnerthat callsTestExecutor.runTest()then exits the JVM
TestExecutor (interface) → BaseTestExecutor (abstract) handles lifecycle:
- Create device profiles
- Create dashboards/customers (if configured)
initEntities()— create devices/gateways- Optionally update root rule chain
runApiTests()— execute the load test atMESSAGES_PER_SECONDrate forDURATION_IN_SECONDS- Cleanup entities and revert rule chain
Concrete executors:
DeviceBaseTestExecutor→MqttDeviceAPITest,HttpDeviceAPITest,Lwm2mDeviceAPITestGatewayBaseTestExecutor→MqttGatewayAPITest,GatewayAPITestLwM2MClientBaseTestExecutor→Lwm2mDeviceAPITest
MessageGenerator implementations in service/msg/:
SmartMeterTelemetryGenerator/SmartMeterAttributesGeneratorSmartTrackerTelemetryGenerator/SmartTrackerAttributesGeneratorIndustrialPLCTelemetryGenerator/IndustrialPLCAttributesGeneratorRandomTelemetryGenerator/RandomAttributesGenerator
Devices are named DW00000000 (prefix DW + zero-padded index), gateways use GW prefix.
DefaultRestClientService— manages thread pools (HTTP executor + log scheduler), wraps TB REST clientDefaultDashboardManager— creates dashboards from JSON files insrc/main/resources/DeviceProfileManagerImpl— creates TB device profiles from JSON files insrc/main/resources/device/profile/RuleChainManager— can swap/revert the TB root rule chain for clean measurement
The lwm2m/ package contains a full Leshan-based LwM2M client implementation supporting NoSec, PSK, RPK, and X.509 security modes. LwM2M object models are in src/main/resources/models/.
Supports sharding across instances via INSTANCE_IDX / USE_INSTANCE_IDX / DEVICE_COUNT to partition the device range among multiple pods.