Integrate IoTIFY with Jenkins
Integrate continuous performance testing with IOTIFY. Trigger nightly performance tests using IOTIFY APIs.
Continuous performance testing is a key requirement to build a scalable cloud platform. Every code commit - even if small - could have a detrimental impact on the performance of your IOT cloud software.
Therefore it is essential to do a nightly performance test on your build and find out which commit had the positive / negative impact on the performance.
Jenkins is one of the most widely used continuous build server in production. In this tutorial we will explain how to invoke IoTIFY Network simulator run through API within a Jenkins build step.
The first step is to create a template in IoTIFY using our web based UI. The template should have the endpoints configured to your staging deployment, or any other deployment which you want to test.
Make sure that the template works by manually running the simulation and validating the results.
Install Jenkins using this guide and create a simple build project with Jenkins. If you already have a Jenkins build server, you could skip this step.
In order to use IOTIFY API, you will first need to acquire an API token. Go to your settings page in IoTIFY and click on the API section on the left hand menu.
There you could allocate a new token as follows:
We will install HTTP Request Plugin with Jenkins which will make it easy to trigger a performance test once the build is finished. Once the plugin is successfully installed,
we will be able to now add a new build step named HTTP request into our project.
Ideally, the testing step should be added once the build is success, unit tests have been passed and software is deployed to pre-staging area.
Add a new build step to your pipeline which invokes HTTP request. Enter following values in the default fields
HTTP Mode: POST
In header section, add two custom headers as follows:
X-Auth: Your API Token as obtained in Step 2.
In the Body tab, enter following values
The parameter template specifies the name of the template which needs to be started.
That’s it. Now save the build step and trigger the build.
Next time your software build is started, the simulation will be automatically triggered.
Note that this step will only trigger the simulation but will not wait for it to finish and log the results. If you would like to also have results included into the build logs, lets follow the next step.
There are certain cases where you want to wait for the test results to be finished and add them into your build logs. To do that, we will use a bash script instead of HTTP Request plugin.
Note that this step is an alternative step and you would not need any of the above steps if you are following this approach.
Make sure you install jq in your jenkins environment.
Create a new build step with Bash script and enter following in the script
The script will launch the template and wait for it to finish before exiting with the results.