1. Install the ‘Tomcat’
Download apache-tomcat-8.5.50.zip
Let’s move this ‘.zip’ file into your project directory. and please unzip the file. then You can see the directory named same with the ‘.zip’ file.
1 | unzip apache-tomcat-8.5.50.zip |
Let’s download the ‘jmeter.war’ file. It will help you to understand about the way how it works. This file isn’t special just You can approach the web service more easily. After completing, You should move the file to ‘apache-tomcat-8.5.50/webapps’ directory.
1 | apache-tomcat-8.5.50/webapps> move jmeter.war |
Let’s execute your tomcat service using ‘apache-tomcat-8.5.50/bin/startup.sh’ from the ‘terminal’
1 | apache-tomcat-8.5.50> cd ./bin |
Sometimes you may need the ‘chmod’ command for changing the authority of the ‘startup.sh’ file. otherwise It’s not working.
http://127.0.0.1:8080/jmeter/search/index.html
If you enter the above link then you can see the below picture, Your ‘Tomcat’ was installed perfectly.
2. Install the ‘JMeter’
Download apache-jmeter-5.2.1.zip
Let’s download the ‘jmeter’ from the above link. and unzip the file.
Download jmeter-plugins-manager-1.3.jar
It will show the graphical the status about your test request. You should put down this file into ‘/lib/ext’
1 | apache-jmeter-5.2.1/lib/ext> move meter-plugins-manager-1.3.jar |
Let’s execute your jmeter service using ‘apache-jmeter-5.2.1/bin/jmeter.sh’ from the ‘terminal’
1 | apache-jmeter-5.2.1> cd ./bin |
3. JMeter simple test.
First of all, We will test your service is well or not just using the response code. like ‘200’, ‘404’ and The below is our test scenario.
1 |
|
Let’s make the ‘Thread Group’. It’s the collection of something like the users. These thread will request to your service as your configuration. and You can configure the number of the thread and the time for setting …
1 | Test plan > Right click > Add > Threads (Users) > Thread Group |
1 |
|
Secondly, We should create the ‘HTTP Request Default’. in here, You can control the overall setting associated to the HTTP Connection. like Server IP, Domain, Port, Url…
1 | Thread Group > Right Click > Add > Config Element > HTTP Request Defaults |
1 |
|
Additionally, If you want to control the Header and the Cookie, then you can use ‘HTTP Header Manager’, ‘HTTP Cookie Manager’ at that time.
It’s actual the task to request some service to your project. You should create two things of this.
1 | Thread Group > Right Click > Add > Sampler > HTTP Request |
1 | // First One |
Importantly, Your ‘HTTP Request Defaults’ setting should be located more higher than the ‘HTTP Request’ because all of the settings are applied only to the lower things.
And you have to add the listeners to two ‘HTTP Request’. They are for the monitoring your test.
1 |
|
Let’s execute the test
4. If you want to put the parameters dynamically using ‘.csv’
Please move the ‘HTTP Request Defaults’ item to outside of ‘Thread Group’. because It will use continuously. and We should disable about the above codes ‘Thread Group’ for this coding except ‘HTTP Request Defaults’. and Let’s make new one. Finally Copy and pase the ‘/jmeter/search/search?key=jmeter’ without parameter.
1 |
|
‘JMeter’ offer the function to change the parameters when you test your project. For that, You have to create the ‘.csv’ file. It’s named ‘search_keyword.csv’
1 | // search_keyword.csv |
This file should save into the directory having the save file(.jmx) of this. In my case, It’s root directory. and We should get this file into the JMeter program.
1 | '/jmeter/search/search' > Add > Config Element > CSV Data Set Config |
Configure like the below.
1 |
|
And Add the parameter from the ‘/jmeter/search/search’.
1 | Press Add Button. |
Let’s execute the test.
You have to compare between the parameters of the above codes. First one has the ‘2keyword’, and Second one have the ‘5keyword’.
5. If you want to redirect dynamically after page.
Before doing this step, You should disable your previous task like the above. and Create new ‘Thread Group’
1 |
|
Let’s see the response of the ‘/jmeter/search/search’. It has a lot of url so we will redirect that url using regular expression extractor.
1 | '/jmeter/search/search' > Add > Post Processors > Regular Expression Extractor |
1 | - Name of created variable : next_url |
And We have to create to connect for the next url. that is we need ‘HTTP Request’ one more.
1 | Thread Group > Add > Sampler > HTTP Request |
Follow the below setting.
1 | Name : next_url - ${next_url} |
Let’s execute the test
You can see the ‘next_url’ variable is different when it happened.
6. If you want to make the custom error on 200 response.
Let do disable your previous things. and Create new one. and It’s really different. We will create 4 ‘HTTP Request’ items.
1 |
|
We should modify the ‘HTTP Request defaults’ file. please add the below url into the ‘path’
1 | path : /jmeter/index.html |
And We will give the Assertion to each ‘HTTP Request’
1 |
|
Let’s execute the test