Seminar 13: Setting Up JMeter and generating test plan containing different user groups
Goal: In this practical Session, we are going to set up JMeter. We will also create a Test Plan of three different Thread Groups (user groups) running three different algorithms having complexity of the order of O(ni), where i = 2,3 etc. Then the test needs to be run on JMeter slave server and JMeter master server. The test results or logs need to be generated in a .csv file. This log file can be used to extract different performance metrics like arrival time, utilization, throughput, average response time etc.
Background Jmeter is a tool that allows you to load-test a system. Generally it is used to test how web-services hold up against increasing loads etc, and since all large scale web-services are distributed we can also think of JMeter as a tool to measure performance of distributed systems. It is a bad idea to simply deploy a large scale system without load-testing it. You wouldn’t want to find out that your server crashes after it hits a load of 69420 users. JMeter allows you to simulate a configurable load, and test your system before you deploy it to actual users.
- .jmx file
- It’s a configuration file, which tells JMeter what to run. In our case, we need a config file which can tell JMeter to run three different test scripts: two sorting algorithms, and an implementation of Towers of Hanoi.
- JSR223 sampler
- A sampler is simply an object that collects or samples the performance of whatever it is that we are testing. The JSR223 sampler is a sampler which allows us to run scripts in different languages. This is what we will work with. In our case, we will configure it to run Python scripts and run different algorithms. At this point it doesn’t matter too much what script we run, but later we could be expected to implement specific algorithms.
Prerequisites: JDK . You can also check the version of the Java using Java -version in cmd
Exercise:
- Set up JMeter:
- Please download the Apache JMeter from here. You can either download the binaries (prefered, no need to compile) or source based on your convenience or whatever suits you better.
- Download jythoninstaller and put it in apache-jmeter/lib folder
- Download jythonstandlone and put it in apachejmeter/lib folder
- Launch JMeter client GUI: Run the jmeter.bat/jmeter.sh file in the bin folder of JMeter.
- $ jmeter.bat
- Create a JMeter TestPlan.
- Check links or video on how to create a TestPlan and how to add different Threadgroups and JSR223 Sampler to the respective threadgroups. Building JMeter test plan
- Add the scripts of bubble sort. The scripts need to be added in JSR223 Sampler and check the language dropdown to be in jython format.
- Add a listener in the form of view in a table, graphs or trees or JSR223 listener, after which we can save and run
- Run the Test Plan on JMeter locally:
- Open terminal/Command Prompt and set the current working directory to jmeter/bin
- Execute the following command:
$ jmeter -n -t "test.jmx" -l "test.csv"
- The results csv file of the test can be found in the jmeter/bin folder.
- Run the Test on JMeter Server (remote use):
- One of the servers will act as a master, sending out tests to slave servers and collecting results. The second server will act as a slave, which performs the tests provided by the master, and returns results
- In the JMeter slave server (again might require the .bat/.sh extension or ./ suffix):
$ jmeter-server.bat
- If you receive an error regrading rmi.keystroke.jks:
- In jmeter.properties file which is present in /bin folder, go to line containing server.rmi.ssl.disable and set this to true: server.rmi.ssl.disable=true. Also uncomment this line.
- It is more preferable to create the rmi.keystroke.jks using create-rmi-keystroke.bat. In this case you don't need to disable the SSL.
- In the JMeter master server:
- If you receive an error regrading rmi.keystroke.jks:
$ jmeter -n -t "test.jmx" -l "test.csv" -R "172.20.10.4"
- (Option) Add the jmeter server IP address in the jmeter.properties file (this is not necessary if using the -R "X.X.X.X" flag). The remote_hosts variable (line 268 by default in the jmeter.properties file) would be used with the -r flag and the IP(s) are not listed as command-line arguments in this case. This way you can remote test even from the JMeter GUI.
Task: Based on the exercise, generate a testplan resulting in a (.jmx file). Create 3 ThreadGroups with 3 loops in the form of BubbleSort, MergeSort and any other algorithm (in my case TOH).
- Add the scripts of bubble sort, Merge sort and Tower of Hanoi to the ThreadGroups in the (.jmx file) namely BubbleSort, MergeSort and the other algorithm respectively.
- Run the Test on JMeter Server (remote use)
Your implementation to generate the (test.jmx) file should be similar to this in the GUI interface
Deliverables: Zip file containing the test code file (.jmx), GUI interface showing the generated (.jmx file), the JMeter Log File(s) (.csv file) and the screenshot of JMeter slave server and master server.
Link:
NOTE: Watch the video if something is not clear.