This is a guest post by Guy Salton, Sr. Professional Services Engineer for CA BlazeMeter.

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.

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. Test results can be analyzed in Taurus. For advanced analyses or running tests in the cloud, Taurus integrates with BlazeMeter.

Guy will be presenting more on this topic at Jenkins World in August, register with the code JWFOSS for a 30% discount off your pass.

Getting started with Taurus

  1. Install Taurus.

  2. Create the following Taurus configuration in YAML. Learn more about YAML in Taurus from this tutorial.

    ## execution:
    - concurrency: 100
      hold-for: 10m
      ramp-up: 120s
      scenario: Thread Group
    scenarios:
      Thread Group:
        requests:
        - label: blazedemo
          method: GET
          url: http://blazedemo.com/

    This script runs 100 concurrent users, holds the load for 10 minutes, the ramp-up is 120 seconds and the thread group runs one GET request to blazedemo.com.

    You can specify an executor by adding executor: <executor_name> to the script. Otherwise, the default executor will be JMeter. In the background, Taurus will create an artifact directory with a jmx file (or a Scala file if you run Gatling, a Python file if you are running Selenium, etc.).

  3. Open a terminal and run: bzt <file_name>.yml

  4. View the test results:

Viewing test results from Taurus

If you want to conduct an in-depth analysis of your test results, run your tests on BlazeMeter. You will be able to monitor KPIs through advanced and colorful reports, evaluate system health over time, and run your tests from multiple geo-locations.

Run the following command from the terminal:

bzt <file_name>.yml -report
Viewing test results in Blazemeter

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.

Come to my free hands-on workshop “Learn to Release Faster by Load Testing With Jenkins” at Jenkins World 2017 on Tuesday August 29th from 1-5pm. You will learn how to test continuously with Jenkins, JMeter, BlazeMeter and Taurus, including how to run JMeter with Jenkins, run the BlazeMeter plugin for Jenkins and how to use open-source Taurus.

To learn more about BlazeMeter, click here.