I trust that someday, you will understand me.
Though out there are plenty documents to run JMeter with Ant task, sometimes it’s not the best solution. For example, if the plan is to run several test scripts on several cloud server instances, it may not worth the effort to install Ant on each of those instances.
In that case, we can run JMeter script from command line, using one statement in the followings:
[jmeterBinDirectoryPath]/jmeter -n -t <testfile>
[jmeterBinDirectoryPath]/java -jar ApacheJMeter.jar -n -t <testfile>
Credit goes to this blog post and this discussion in mailing list.
/** Vietnamese: bài viết trình bày về cách dùng JMeter Counter để giả lập nhiều user truy xuất hệ thống cùng lúc **/
In load testing field, JMeter is a powerful tool, and powerful tool often means high learning curve. The fact that JMeter document is not so well-written caused programmers lots of troubles getting around with it. If you know how things to be done, it’s very simple. If not, you are going to spend several hours searching for the solution.
The situation: I need to simulate 1000 users to login in my system, using different username (ofcourse). After logging in, each user must input their activation code, gotten from the database. Then they go for the site functions as usual.
The interesting thing is that the activation code are random strings: I have no control how it be. But I must do mapping accurately from user to activation code. To do that, I write bootstrap code to generate 1000 users (user1 -> user1000) and their activation code. Next, export them to a CSV file to be read by JMeter.
But how to get those information to JMeter? Using bean shell script, I managed to put these values in custom variables CurrentUser and CurrentUserActivationCode. But I must only put one pair of different value for each thread. Since JMeter have no global variable, I can’t tell it to increase each time a new thread start!
I searched for global variables for a while and try some suggestion (properties and the likes) without success. And then I remember that I only need a counter, because it simply doesn’t matter if the users log in in a order or not.
Solution: It’s JMeter Counter Config Element(actually I have no idea why a counter is a Config Element).
**Vietnamese: mục tiêu của bài viết này là giới thiệu sơ lược về công cụ JMeter và cách áp dụng nó để kiểm tra tính bền vững của một website với số lượng truy cập lớn. **
The purpose of this article is to make a quick introduce about JMeter tool and how to apply it to test the performance of a website with high loading.
Why using JMeter for load testing
JMeter is a free tool, with a wide range of supported functions, and is very popular. Well, as I know (from several StackOverflow questions) there’s hundreds of popular web-testing tools out there. Just pick one, and this time I take JMeter.
Another notice is that this article won’t tell you how to configure Ant to use it along with JMeter. This tutorial is the guide to build a basic test plan to run with the JMeter GUI.
Build a test plan
First you need a test plan. For example, you want to test a Library Website when there are 200 users access at the same time. This is a very high load, given the fact that if your website has about 1000 users, it’s very rare to see 10 of them access the website resource simultaneously.
We need to specify what a typical user do when accessing our website, for example:
- The user login
- The user browse books in library
- The user review some page of the book