Jenkins

Running JMeter Scripts By Taurus – Jenkins Pipeline

Jenkins Pipeline is an important Jenkins feature for creating and managing a project in Jenkins. This is opposed to the traditional way of creating a Jenkins project by using the Jenkins GUI. When running your open-source load test, Jenkins Pipeline enables resilience, execution control, advanced logic and Version Control management. This blog post will explain how to run any open-source load test with Jenkins Pipeline, through Taurus.

Note : To understand the pipeline more into details ,refer this blog. For Scripted pipeline refer this blog and Declarative pipeline refer this blog.

Taurus is an open source test automation framework that enables running and analyzing tests from 9 open source load and functional testing tools: JMeter, Selenium, Gatling, The Grinder, Locust, Tsung, Siege, Apache Bench, and PBench.

Prerequisite:

1.Install Taurus from here if it is not installed.

2.Install Jenkins from here.

3.For Jenkins Pipeline we need to install the Pipeline plugin.
Go to Manage Jenkins > Manage Plugins >Available section> search Pipeline.
If you are already installed Pipeline It will display in Installed section.

4.Install blue Ocean Plugin in Jenkins:

Blue Ocean is simple to install and will work on basically any Jenkins 2 instance (version 2.7 or later). Even better, it runs side-by-side with the existing Jenkins web UI – you can switch back and forth between them whenever you like. There’s really no risk. If you have a Jenkins instance and a good network connection, in 10 minutes you could be using Blue Ocean.

  1. Login to your Jenkins server
  2. Click Manage Jenkins in the sidebar then Manage Plugins
  3. Choose the Available tab and use the search bar to find Blue Ocean
  4. Click the checkbox in the Install column
  5. Click either Install without restart or Download now and install after restart

After you install Blue Ocean, you can start using it by clicking on **Open Blue Ocean** in the top navigation bar of the Jenkins web UI, or you can navigate directly to Blue Ocean by adding `/blue` to your Jenkins URL, for example `https://ci.jenkins.io/blue`.

Opening Blue Ocean

Now we are good to go 🙂

Integrate Taurus With Pipeline:

To run Taurus through Pipeline, you can also go straight to Jenkins after creating your Taurus script.

  1. Open Jenkins → New Item → Fill in an item name → Click on ‘Pipeline’
blazemeter speaker blog 2017 3
blazemeter speaker blog 2017 4

2.Now create a Pipeline script. You can include all parts of your CI/CD process in this script: Commit, Build, Unit Test, Performance Test, etc., by creating different stages.

This Pipeline has three stages: The first is called “build”. In this example it is empty, but you can add commands that will build your code. The second, called “Performance Tests”, creates a folder called “Taurus-Repo” and runs the Taurus script that we created. At the same time (note the “parallel” command), there is a “sleep” command for 60 seconds. Obviously it makes no sense to put those two commands together, this is just to show you the option of running 2 commands in parallel. The third stage called “Deploy” is also empty in this example. This is where you could deploy your new version.

node {
   stage('Build') {
      // Run the Taurus build
   }
   stage('Performance Tests') {
    parallel(
        BlazeMeterTest: {
            dir ('Taurus-Repo') {
                sh 'bzt file_name.yml -report'
            }
        },
        Analysis: {
            sleep 60
        })
   }

   stage(‘Deploy’) {
   }
}
blazemeter speaker blog 2017 5

Note that you can either add the Pipeline inline, or choose the “Pipeline script from SCM” option and add the URL to the script on GitHub (in this case you need to upload a Jenkinsfile to GitHub). With “Pipeline from SCM”, whenever you need to update the tests, you can just add new commits to the Jenkinsfile.

3.Save the Pipeline
4.Click on ‘Build Now’ to run the Pipeline

blazemeter speaker blog 2017 6

5. Click on the new Build that is running now (build #6 in this example).

blazemeter speaker blog 2017 7

6. Click on ‘Console Output’ to see the test results:

blazemeter speaker blog 2017 8

7. In the Console Output you can see the test results and also the link to the report in BlazeMeter.

blazemeter speaker blog 2017 9
blazemeter speaker blog 2017 10

That’s it! Jenkins Pipeline is now running open-source load testing tools via Taurus.

References:

https://jenkins.io/blog/2017/08/17/speaker-blog-blazemeter/

Categories: Jenkins, JMeter, Taurus

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s