JMeter via groovy script to connect MongoDB

Source: Internet
Author: User
Tags mongodb groovy script



First, the background:

 use JMeter to do interface testing, background is MongoDB, it is inevitable to connect access.



1, JMeter itself originally has MONGODB.JMX script sample, but now is not recommended to use.



2, can only think of another way, because do not understand Java, so decided to take JMeter JSR request, through groovy script way, access to MongoDB.



3, encountered the pit: link failure, prompting no permissions.



(Depressed for several days, check many times the script, the test script itself is very simple, tossing and turning those lines, feel no problem.) An accidental accident to find the reason. So for idiots, luck is too important.



Accidental accidental: A few days ago access to a shared address, others can access, I cannot access, the hint is probably the Group Policy is forbidden to access the shared folder, modified the settings to access success. Then I immediately associate with the database access problem, according to the original way, did not change what, the request came back data .... So the problem is not necessarily in the matter itself, it may be the influence of other places.



Second, record the next step



1, if you want to connect and operate the MongoDB database, must be driver, I looked for 3 from the Internet package:



Mongodb-driver-3.4.0-rc1



Mongo-java-driver-3.4.0-rc1



gmongo-1.5



Put them under the JMeter lib/ext path, and when you create a test plan, quote:






2, the connection parameters are defined first, placed in the "user-defined variables", easy to use.









3. Create a JSR request






4, look at the results, I in the local MongoDB database, in advance to create a database: MyDB, set: MyDB, which put some simple test data.









JMeter via groovy script to connect MongoDB


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.