LoadRunner Wizard for MQTT Protocol

Apps_Guest
New Member.
1 0 1,080

oren.jpg

Blog authored by
Oren Gavriel
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.mqtt 1.png

       

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
    1. 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).
    2. 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.mqtt 2.png

     

If the connection succeeds, you will see a green check.
mqtt 3.png

 

If the connection fails, you will see a red X. 

mqtt 4.png

 

 

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.mqtt 5.png

       

In Subscriber mode, define the topic for the subscriber.mqtt 6.png

Step 3: “Last Will and Testament”

Use “Last Will and Testament” to notify other clients about an ungracefully disconnected client.mqtt 8.png

  • 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:

  1. h: client variable declarations
  2. c: create client and connect, subscribe calls
  3. c: publisher calls
  4. c: unsubscribe calls, client disconnects

Sample script:mqtt 9.png

 

 

mqtt 10.JPG

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.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.