LoadRunner Supports COAP and MQTT for Testing IOT Applications

Apps_Guest
New Member.
0 0 3,487

Guest blog post by  
Phillip Odom, EndPointIOT

A need for performance testing continues to grow as the Internet of Things (IoT) becomes a larger mainstay in networks for businesses, homes, and ecology. Just as application servers and databases can be overloaded with incoming requests, so to can message brokers and their databases. There are many kinds of protocols for communicating with IoT message brokers, but two of the most common are Constrained Application Protocol (CoAP) and MQ Telemetry Transport (MQTT). Performance testing IoT is a relatively new option and we want to help you get started. 

This will provide you step-by-step instructions for getting started with CoAP scripting. 

Prerequisite: Install CoAP Protocol for LoadRunner, you can download it here.

  1. Launch Virtual User Generator (supported versions are 12.55 or newer).
  2. Click File and select "New Script and Solution."
  3. Select CoAP (Constrained Application Protocol)


    lr1.png

     

  4. Set the script name and location, then click Create. The script will automatically open to the Action section. Within the Action section, many functions are already built for you and are commented out with //, so they will not run during script replay.

  5. Uncomment lines 22, 27-33, and 35 by removing the //.
    • Line 22: lr_start_transaction("ConGet"); will begin measuring the time it takes to complete the contained actions.
    • Lines 27-33: coap_request("ConGetRequest",...LAST); will perform the GET request to the message broker. 
    • Line 35: lr_end_transaction("ConGet", LR_AUTO); will stop measuring time and log the duration it measured up to that point, as well as a status of Pass or Fail for the transaction.

      action c.png

       

  6. Set the URL on line 28 to your IoT message broker's IP or URL, and change the path from /large to /test (coap://testtheiot.com/test can be used if you do not have a message broker set up to test). 
  7. Save the script.
  8. Click Run.
    • You should see "Script Passed." 
    • If successful, this script can be used for a test scenario in LoadRunner Performance Center, or it can even be uploaded to StormRunner. 

This is the basic approach to utilizing the CoAP template for testing the CoAP protocol with LoadRunner. For more details on the various functions of the CoAP template see our previous blog post, COAP Protocol for Micro Focus LoadRunner 12.55 API Reference.

MQTT

Next, we’ll go over the basics of the MQTT template for LoadRunner. There is no prerequisite to using this script.

  1. Open the Virtual User Generator (12.55 or newer).
  2. Click File and select "New Script and Solution."
  3. Select MQTT Protocol.
  4. Set the script name, and location, then click Create
    • The script will automatically open to the Action section.
    • Within the Action section, many functions are already built for you and are commented out with // so they will not be run during script replay.
  5. In the Solution Explorer frame on the left, double-click the vuser_init action. 

    vuit.png

     

  6. On line 17, set the mqtt_connect client to your IoT broker’s IP or URL (tcp://testtheiot.com can be used if you do not have a message broker set up to test).vuser_int.png

     

  7. Uncomment line 20.

  8. Set the <topic> you wish to subscribe to (Ex. test123).

  9. Switch back to tab Action.c.mqtt act c.png

     

  10. Uncomment line 31: mqtt_publish.

  11. Set the <topic> to be the same as the one to which you're subscribing.

  12. Set the <payload> to any message you would like to send.

  13. In the Solution Explorer frame on the left, double-click the vuser_end action.mqtt ex.png

     

  14. Uncomment line 4.uncomment line 4.png

     

  15. Set the <topic> to the same in previous steps to unsubscribe.

  16. Save the script.

  17. Click Run.
    • You should see “Script Passed.”
    • If successful, this script can be used for a test scenario in LoadRunner, Performance Center, or it can even be uploaded to StormRunner.

This is the basic approach to utilizing the MQTT template for testing the MQTT protocol with LoadRunner. For more details on the various functions of the MQTT template, visit the Micro Focus documentation.

 

 

 



  1.  

     

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.