Quantcast
Channel: JMeter – TestAutomationGuru
Viewing all articles
Browse latest Browse all 42

JMeter – Sharing Performance Test Results in Slack

$
0
0

In this article, we are going to see how we can share our performance test results in Slack.

Image result for slack integrations

Slack comes with many Apps & APIs for easy integration with other applications. Check here for more information.

 

Slack – Jenkins CI App – Integration:

 

Slack:

  • Go to https://<team-domain>.slack.com/apps
  • Browse for ‘Jenkins’ app
  • Install Jekins CI App in your slack
  • Click on the ‘Add Configuration’

slack001a

  • Make a note of team domain and Token
  • Select the channel where we want to pose the results

slack002

 

Jenkins:

  • Go to Manage Jenkins -> Manage Plugins -> Available Tab
  • Install Slack Notification Plugin
  • Update Slack domain and token =>  Manage Jenkins -> Configure System -> Global Slack Notifier Settings

slack003

  • Click on the ‘Test Connection’ – You should see ‘success’ message in Jenkins and below message in slack channel.

slack004

 

Jenkins – Performance Test Job:

  • I create a Jenkins job for Performance Test (A step-by-step tutorial on this is here )

slack005

  • Update the post build actions as shown here – with the custom message you want

slack006

 

  • If you need to share the Grafana dashboard URL – then add the URL in the below format.

slack009

  • Once the Performance Test is complete, you will be notified in slack as shown here.

slack008

Sharing Results using Slack HTTP API:

The above Jenkins plugin is very easy to use. However it does not allow us to upload files / share images etc. Lets see How it can be done using Slack HTTP API.

  • First we add ‘Incoming WebHook’ in Slack

slack010

  • Slack generates a HTTP Post URL . Any message sent to the URL -following this format – will be visible in your slack channel.
  • This approach provides a lot of flexibility for us to customize the message.
  • We could use this approach to share performance test results – charts in the slack channel.
  • To share the image – HTTP POST request body data should be in the below format.

Note: Please ensure that link for your image is available in public. You might not be able to use this approach to share if images are within the private network. In this case, you need to upload them to a public site – like Dropbox – then use public URL of the site before sharing via Slack.

  • Assuming performance test result charts are available in a public site…. Install this HTTP Request Plugin in Jenkins.
  • Update the URL and Request Body as shown here

slack011

  • We could see the chart in slack as soon as the Jenkins job is executed

slack012

Slack – File Upload:

When your images are not available in public, Slack provides a file upload API to upload images & other files.

  • Go to this site – https://api.slack.com/methods/files.upload/test
  • Generate a token for your account
  • Upload a simple file in the preferred channel using the site.
  • Make sure you receive the image in your slack channel.
  • The easiest option is to invoke a CURL command in the below format to upload the file.

curl -F file=@BytesThroughputOverTime.png -F channels=#perf-test -F token=my-token https://slack.com/api/files.upload

  • We can also use java/groovy – Lets create a simple java util to upload the images

  • Once this is done, export this as a jar file – Invoke this as ANT target / place it in jenkins classpath – call this as part of post build actions.

slack013

 

Summary:

As part of Continuous Performance Testing process we run the performance test using Jenkins periodically. Only you, as a performance test engineer, mostly know the results. Other team member might not be aware of performance test results. Using JMeter command line tool, we can create beautiful charts and using Slack API we can share the results programmatically.

 

Happy Testing & Subscribe 🙂

 

Share This:


Viewing all articles
Browse latest Browse all 42

Trending Articles