Apache JMeter (http://jmeter.apache.org/) added support for MongoDB since its 2.10 release. In this post I am referring to the latest JMeter release (2.13).
A preliminary JMeter setup is needed before starting your first test plan for MongoDB. It uses Groovy as scripting reference language, so Groovy needs to be set up for our favorite load testing tool. Follow these steps to complete the set up:
The Thread Group associated with the template comes with two JSR223 Samplers, one for insert and the other one for queries/counts:
In order to run load tests against a database please always use JSR223 Samplers and not MongoDB Script Samplers. These samplers invoke the db.eval() function in order to run the scripts. It has been deprecated (https://docs.mongodb.org/manual/reference/method/db.eval/) since MongoDB 3.0 (mostly for performance and security reasons) and any way it doesn't work with sharded collections. The JSR223 Samplers use the MongoDB Java driver through Groovy instead. The next figure shows the layout of a JSR223 Sampler:
You have to select the reference scripting language (Groovy) through the combobox highlighted in the figure. Then you can choose to edit your script in the Script text area or load the code from an external Groovy file. This second way a script will get compiled into bytecode reducing the overhead at execution time. The code in the example explains itself: please read the comment inside. Most part of the work preparing a MongoDB load test would be cloning the JSR223 script templates and setting the collection names and field names and values of your database.
The JSR223 samplers in the template come with associated Response Assertions:
There you can apply assertions to the responses using custom patterns:
The results of each run can be viewed in the View Result Tree and Aggregate Report listeners as usual for most part of the JMeter test plans.
A good practice for the results could be to use a specific View Result Tree listener for each JSR223 Sampler (rather than one for the Thread Group) and then add an Aggregate Graph Result listener to aggregate the result and some stats in a chart.
The execution of the MongoDB test plans created through JMeter can be also automated through Jenkins as explained in one of my old posts in this blog.
A preliminary JMeter setup is needed before starting your first test plan for MongoDB. It uses Groovy as scripting reference language, so Groovy needs to be set up for our favorite load testing tool. Follow these steps to complete the set up:
- Download Groovy from the official website (http://www.groovy-lang.org/download.html). In this post I am referring to the Groovy release 2.4.4, but using later versions is fine.
- Copy the groovy-all-2.4.4.jar to the $JMETER_HOME/lib folder.
- Restart JMeter if it was running while adding the Groovy JAR file.
The Thread Group associated with the template comes with two JSR223 Samplers, one for insert and the other one for queries/counts:
In order to run load tests against a database please always use JSR223 Samplers and not MongoDB Script Samplers. These samplers invoke the db.eval() function in order to run the scripts. It has been deprecated (https://docs.mongodb.org/manual/reference/method/db.eval/) since MongoDB 3.0 (mostly for performance and security reasons) and any way it doesn't work with sharded collections. The JSR223 Samplers use the MongoDB Java driver through Groovy instead. The next figure shows the layout of a JSR223 Sampler:
You have to select the reference scripting language (Groovy) through the combobox highlighted in the figure. Then you can choose to edit your script in the Script text area or load the code from an external Groovy file. This second way a script will get compiled into bytecode reducing the overhead at execution time. The code in the example explains itself: please read the comment inside. Most part of the work preparing a MongoDB load test would be cloning the JSR223 script templates and setting the collection names and field names and values of your database.
The JSR223 samplers in the template come with associated Response Assertions:
There you can apply assertions to the responses using custom patterns:
The results of each run can be viewed in the View Result Tree and Aggregate Report listeners as usual for most part of the JMeter test plans.
A good practice for the results could be to use a specific View Result Tree listener for each JSR223 Sampler (rather than one for the Thread Group) and then add an Aggregate Graph Result listener to aggregate the result and some stats in a chart.
The execution of the MongoDB test plans created through JMeter can be also automated through Jenkins as explained in one of my old posts in this blog.
ReplyDeleteThis information you provided in the blog that is really unique DevOps Training in Chennai | DevOps Training in anna nagar | DevOps Training in omr | DevOps Training in porur | DevOps Training in tambaram | DevOps Training in velachery
I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.
ReplyDeleteMongoDB Training in Bangalore
I got wonderful information from this blog. I enjoyed your blog... the way you presented is really awesome... Thanks for sharing with us...If someone wants to know about load testing services this is the right place for you.
ReplyDeleteyou have written an excellent blog.. keep sharing your knowledge...
ReplyDeleteJMeter Training in Chennai
JMeter Training Institute in Chennai
Awesome blog. Thanks for sharing such a worthy information....
ReplyDeleteAngularjs Training in Bangalore
Angularjs classes in pune
Angularjs Training in hyderabad
Angularjs Training in Gurgaon
Angularjs Training in delhi
Angular Training in Trivandrum
Angular Training in Kochi
Angularjs Training in Ahmedabad
Angularjs Training in Kolkata
Best AngularJS classes in Mumbai
Thank you for sharing this informative post. Betal Engineering Pvt Ltd provides Load Testing and Certification, Lifting Equipment Certification in India and across the globe.
ReplyDeleteLifting Equipment Certification in India
Nice article, its very informative content..thanks for sharing...Waiting for the next update.
ReplyDeleteswift developer training in chennai
swift developer course certification in chennai
Useful blog, keep sharing with us.
ReplyDeleteScope of JMeter
Why JMeter
Axure RP Pro / Team is a software for creating prototypes and specifications for websites and applications. It offers drag and drop placement, User easily Axure RP Pro
ReplyDeleteThe free version of Kaspersky Security Cloud allows you to store up to 15 passwords in its password manager; the paid version removes Kaspersky Total Security Activation Code
ReplyDelete