(I also found a few shortcomings/annoyances, which is great, because that gives me some incentive to improve the hack.)
- If I needed to change the hosts, the database, the credentials, you needed to rebuild and redeploy the jar.
- There was no way to tweak the options [http://api.mongodb.org/java/2.7.2/com/mongodb/MongoOptions.html].
- Connections didn't seem to be getting recycled. You had to shutdown jmeter before the open connections were tried up.
- Wanted to ensure that the connection didn't need to be created every time there was an iteration, and that the connection pooling could be utilised
1. Easy enough to the change this, I added the fields that had been frustrating me.
2. Again, easy enough to add these additional properties, though I did come up against a slight frustration
3. This was also slightly frustrating. JMeter didn't seem to be release any of the resources tied up in the Sampler. This was eventually resolved by a bit of experimentation and a bit of 4.
4. This turned out to be a lesson in RTFM. Implementing TestListener allows you to connect to MongoDB at the start of the test run, use the connection pooling during the iterations, and tidy up resources at the end of the run.
I don't really do 'and the moral of the story is...', but in this case, RTFM is reasonably apt. And, it's quick and easy to hack together something that works, it's not so easy to put together something usable in the longer term; but we all know that.
Request For Comments
If you found this useful, please leave a comment.
If there is a missing feature, please let me know and I'll try and add it.