This is a guest post by Guy Salton, Sr. Professional Services Engineer forCA 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 withBlazeMeter.
Guy will bepresenting
more on this topic atJenkins World in August,
register with the code |
Getting started with Taurus
Install Taurus.
Create the following Taurus configuration in YAML. Learn more about YAML in Taurus fromthis tutorial.
## execution: - concurrency: 100hold-for: 10mramp-up: 120sscenario: Thread Groupscenarios:Thread Group:requests: - label: blazedemomethod: GETurl: 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.).Open a terminal and run:
bzt <file_name>.yml
View the test results:
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
Integrate Taurus With Pipeline
To run Taurus through Pipeline, you can also go straight to Jenkins after creating your Taurus script.
Open Jenkins → New Item → Fill in an item name → Click on ‘Pipeline’
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’) { } }
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 theJenkinsfile
.Save the Pipeline
Click on ‘Build Now’ to run the Pipeline
Click on the new Build that is running now (build #6 in this example).
Click on ‘Console Output’ to see the test results:
In the Console Output you can see the test results and also the link to the report in BlazeMeter.
That’s it! Jenkins Pipeline is now running open-source load testing tools via Taurus.
Come tomy 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.