Mloadgen is a Mongo Document injector for MongoDB. It let you insert documents in the specified collection.
MLoadGen had only a component which is a Java Request Sampler. It let you configure the connection to a mongo server define the collection and the document you wanto insert in.
MLoadGen uses Java, hence on JMeter machine JRE 8 or superior:
Install openjdk on Debian, Ubuntu, etc.,
sudo apt-get install openjdk-8-jdk
Install openjdk on Fedora, Oracle Linux, Red Hat Enterprise Linux, etc.,
su -c "yum install java-1.8.0-openjdk-devel"
For windows and mac and you can:
- download oracle JDK 8 setup from here
- using chocolatey (windows): https://chocolatey.org/packages?q=java brew (mac):
brew tap adoptopenjdk/openjdk
brew cask install adoptopenjdk8
mvn clean install
Once build is completed, copy target/mloadgen->version>.jar file to JMETER_HOME/lib/ext directory. You also need to replace the mongo library version shipped with JMeter to at least the same defined in the pom.xml. Nowadays Jmeter version 5.2 use the version 2.11.3, which is quite old for this plugin and if you try to connect the modern mongo cluster.
- hostname : Mongodb server hort name or Master server in a Mongo Cluster.
- port : Mongodb server port.
- username : User name allowed to insert documents.
- password : Password for the account.
- dbname : Data base name where collection is.
- collection : Collection where we want to insert documents.
- document : Document in JSON format we want to insert.
Document will be converted into BSON Document and inserted in the collection. The collection name is validated, if it is not in the server, the collection will not be created. Just to avoid duplicated collections and missdirections.