One of the most popular uses of Flood’s API is to integrate with CI/CD tools, and a good portion of those customers seem to choose Jenkins for orchestrating their pipeline. Recently, we published a blog post including some examples of this integration, since publishing this post, we have had a considerable number of inquiries asking for more specific use cases that we would like to incorporate and describe in this follow-up blog post.
Most of the questions we receive are in regards to how you can share test results with other business stakeholders. Some customers have found that the Shareable link option that Flood provides is a great solution to share results with other stakeholders. Other customers find that key metric information presented on the dashboard is not apparent enough and might be confused if the labeling and tagging of the requests or transactions are not specifically shown. Many have found it easier to download either CSV results or Archived results and process them from their end, in order to publish results internally. In this post, we will cover both of these alternative options for sharing your cloud load testing results easily with interested business stakeholders.
How to generate a “Shareable link”
A shareable link allows external users (without a Flood login) to view a single test dashboard that is used for monitoring the Flood itself. This link can be generated manually by clicking on the Settings button, then select the Create shareable link option and then clicking on the Enable Secret Link button. You should then be presented with a pop-up containing a link to share the Secret Flood URL link with your stakeholders.
However, many customers are interested in automating this manual task through the API, which can be done simply by following these steps:
GET the Bearer Token value
Most of the Flood API requests use the API Access Token authentication as described here, However, to generate the Shareable link URL we need to obtain the Bearer token value by using our Flood credentials.
curl -X POST https://api.flood.io/oauth/token -F 'grant_type=password' -F 'email@example.com' -F 'password=Test1234
PATCH request to the set-public API endpoint
In order to enable the Shareable link, we require the Flood UUID value (which is a unique identifier) of the Flood execution that we want to share. This value could be grabbed in the cascade, for example, if we launch the test and get the Flood UUID from the response, get the bearer token, enable the shareable link, notify stakeholders by email or slack and wait until the test is done to see the final results.
curl -X PATCH 'https://api.flood.io/api/v3/floods/Flood_UUID/set-public' -H 'Authorization: Bearer Bearer_Token'
If both requests retrieved valid responses, the Shareable link will be the result of joint of https://api.flood.io/ + Flood UUID (the first 8 chars) for a short link, as an example = https://api.flood.io/HdawHdha but also the full Flood UUID can be used as a reference https://api.flood.io/HdawHdhaV9NfkSAr6bne3w
How to download the CSV test result?
The CSV test result basically consists of all the data points aggregated by the Flood reporting engine every 15 seconds. These raw results are what drive the graph and table that are displayed in the test’s dashboard. This file can be downloaded manually by clicking on the Settings button, select the CSV Results option.
This file can be also pulled using the API, we only need the Flood UUID value.
curl -X GET 'https://api.flood.io/csv/Flood_UUID'
How to download archived results from S3
The archived result is a compressed file of the output logs that the tool generates. These files are available once the test is done and are copied from the node where the test was running to S3 storage. The files are usually available for one month before they are cleared to make room for newer results. In the case of large tests where several nodes are required, this task could become tedious if needing to download compressed files one by one. Nevertheless, this file can be downloaded manually by clicking on the Settings button, select the Archived Results option, then download the .tar.gz file from the link.
This file(s) can be also pulled using the API, which is a huge time saver if downloading files from multiple nodes or creating a report repeatedly from an excel template. For this, we need the first 8 chars of the Flood UUID and the first 8 chars of the Grid UUID and also getting the number of nodes that were used in one digit format in the test.
curl -X GET 'https://flood-archives.s3-accelerate.amazonaws.com/Short_Flood_UUID-Short_Grid_UUID-#Node.tar.gz'
-- Binary data --
How to schedule a test run through Jenkins and Flood?
There are several options with Jenkins to trigger a build; some clients have a pipeline already set and some others require a daily or nightly execution. In order to schedule a build, we recommend using the option Build periodically which allows triggering builds periodically, if you already have experience with the Crontab format it would be a piece of cake, but if you haven't we recommend to use this calculator to properly schedule the subsequent build to call Flood.
As it was mentioned previously the best approach to get everything in a row, would be to execute the steps in cascade, because some component like the Bearer token has an expiration and would be difficult to hard code, here an example in Unix command line format:
Launch the test and save the response
Test=`curl -u flood_live_token: -X POST https://api.flood.io/floods -F "flood[tool]=jmeter" -F "flood[threads]=20" -F "flood[rampup]=20" -F "flood[duration]=600" -F "flood[privacy]=public" -F "flood[project]=project" -F "flood[name]=Jenkins Test" -F "firstname.lastname@example.org" -F "email@example.com" -F "flood[grids][infrastructure]=demand" -F "flood[grids][instance_quantity]=1" -F "flood[grids][region]=us-east-1" -F "flood[grids][instance_type]=m5.xlarge" -F "flood[grids][stop_after]=600"`
Double check the response and get the UUID’s value
Flood_UUID=`echo $Test | jq -r '.uuid'`
Grid_UUID=`echo $Test | jq -r '._embedded.grids|..uuid'`
S_Flood_UUID=`echo $Flood_UUID | cut -c1-8`
S_Grid_UUID=`echo $Grid_UUID | cut -c1-8`
echo 'Flood_UUID='$Flood_UUID' Grid_UUID='$Grid_UUID' S_Flood_UUID='$S_Flood_UUID' S_Grid_UUID='$S_Grid_UUID;
Get the Bearer Token and save the response
Login=`curl -X POST https://api.flood.io/oauth/token -F 'grant_type=password' -F 'firstname.lastname@example.org' -F 'password=password'`
Double check the response and get the Bearer Token value
Token=`echo $Login | jq -r '.access_token'`
Patch the Shareable link and save the response
Patch=`curl -X PATCH 'https://api.flood.io/api/v3/floods/'$Flood_UUID'/set-public' -H 'Authorization: Bearer '$Token`
Double check the response
Get the CSV File
curl -X GET 'https://api.flood.io/csv/'$Flood_UUID
Get the Archived results
curl -X GET 'https://flood-archives.s3-accelerate.amazonaws.com/'$S_Flood_UUID'-'$S_Grid_UUID'-0.tar.gz'
Also as you might notice from the image above, the steps are linked in order to get the results easily from Flood API
A word about security
Using your Flood API token on a Jenkins environment allows potential third-party services or other users to launch any kind of load test using your account. If you think your API token or Flood Account has been compromised you should delete and re-generate the corresponding token from your account to prevent further unwanted use.
Putting it all together
Sharing results from Flood gives you the ability to process, report, notify, share and track your application’s performance over time with ease. Sign up for a free trial today to run a load test and see how easy it is to share performance insights with your team.
If you are running continuous load testing using Jenkins or another CI tool, we’d love to hear from you. Drop us a note and share any ideas that are working for you and feel free to ask our team any of your tough questions!