Blog authored by
VuGen R&D team
MQTT is one of the common protocols used in the IoT (Internet of Things) world. Using publish-subscribe operations for communication between clients and a server, MQTT’s small size, low power consumption, minimized data packets and ease of implementation make the protocol ideal for the “machine-to-machine” or “Internet of Things” world.
Micro Focus is pleased to let you know that the MQTT protocol has been added to our performance testing products: LoadRunner and Performance Center in version 12.55, and to StormRunner Load in version 2.8.
By using this protocol, a user can emulate MQTT clients (sensors, actuators, switches, etc.) and design and execute performance testing of MQTT-based IoT systems. General information about LoadRunner MQTT protocol can be found in our previous blog, "Test your MQTT protocol-based IoT system with LoadRunner."
As part of the Micro Focus LoadRunner usability agenda, and the drive to make the scripting capabilities as simple as possible, we have introduced a new wizard, available starting with LoadRunner version 12.63.
There are only 3 steps and you have MQTT script ready to go!
How it works:
- Open your MQTT script, or create a new one in VuGen.
- The Script Wizard automatically displays (default setting) when you create a new MQTT script.
- You can also open it by selecting Design Script on the VuGen toolbar.
Step 1: “Connection settings”
Fill out the following fields:
- Broker URL: Address of the broker server in the format: tcp://host:portor ssl://host:port
- Client ID: Unique Connection ID at the network. (If the field is left empty, a unique ID is automatically generated.)
- Authentication settings: Set the user name and password of a broker.
- SSL / TLS settings
- If secure communication over TLS (SSL) is required, define the path to the certificate file and private key, and the password for the key (leave the password field empty if the key is not encrypted).
- Select the relevant TLS version from the dropdown list. Default uses the version defined in the runtime settings. TLS version can be: 0, 1.1 , 1.2
- Test the broker URL by clicking, Check Connection.
If the connection succeeds, you will see a green check.
If the connection fails, you will see a red X.
Step 2: “Client Settings”
There are two modes: Publisher and Subscriber.
In Publisher mode, define settings for publishing messages:
- Topic to subscribe: Subscribes the client to messages that match the string/wildcard.
- Topic to publish: The broker publishes this message to all subscribers to this topic.
- Payload: Contains the data to transmit in byte format.
- Retain message: When checked, instructs the broker to store the last retained message in this topic together with its QoS. Only one message is stored per topic, so the last retained message always replaces any previously stored message. Useful for providing the latest status to new subscribers when they subscribe to a topic, so they do not need to wait for the next status update.
- Quality of Service (QoS)
- QoS = 0: One delivery at most. The message is delivered according to the capabilities of the underlying network. No response is sent by the receiver and no retry is performed by the sender. The receiver gets the message either once or not at all.
- QoS = 1: One delivery at least. This quality of service ensures that the message arrives at the receiver at least once, but there’s a probability of duplicating messages on the receiver’s side. If the publisher has not received the acknowledgment of delivery from the message broker, it sends the message again. After the duplicated message is received by the broker, the latter sends it again to all subscribers.
- QoS = 2: One delivery exactly. This is the highest quality of service. It is used when neither loss nor duplication of messages is acceptable.
- QoS = Default: means take value from Runtime Setting.
In Subscriber mode, define the topic for the subscriber.
Step 3: “Last Will and Testament”
Use “Last Will and Testament” to notify other clients about an ungracefully disconnected client.
- Once all fields are complete for the test, click Generate Code to create the script.
As part of the script generation, MQTT wizard will update four files:
- h: client variable declarations
- c: create client and connect, subscribe calls
- c: publisher calls
- c: unsubscribe calls, client disconnects
Note: You can use the wizard multiple times on a specific script. The generated code is appended to the existing code.
Now you are ready to run in VuGen 1 vuser and make any changes necessary before running this script as part of your performance test in LoadRunner\Performance Center\StormRunner Load.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.