Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Jmeter recognize "localhost" URL?

How to do performance testing of localhost url which is accessible only to my computer?

I am able to do performance testing using jmeter for live websites like google etc but jmeter is not able to detect local url. URL of application-192.168.121.20:8001
2. Output of View Results Tree listener- ALL failed http alerts Description of screenshot of HTTP Request sampler- added only server name i.e URL –

like image 415
Wayne Hodges Avatar asked Apr 16 '15 05:04

Wayne Hodges


5 Answers

I have the same problem, but my mistake is that I thik the Server Name was the URL Base and it is not works.

This is the wrong way:

  • Server Name: "localhost/api/v1" (Wrong)
  • Http Request -> Path: "/auth"

Http Request Defaults (Jmeter):

Http Request Defaults (Jmeter)

The correct way:

  • Server Name: "localhost"
  • Http Request -> Path: "/api/v1/auth"

Http Request Defaults (Jmeter):

Http Request Defaults (Jmeter)

Http Request (Test):

Http Request (Test)

like image 139
Rita Pissarra Avatar answered Oct 13 '22 00:10

Rita Pissarra


JMeter doesn't care whether application under test is local or remote, if you cannot hit local URL with JMeter - something is wrong with your HTTP Request Sampler configuration, most likely "Port" value is wrong.

In order to be able to help we need to know the following: 1. URL of your application 2. Output of View Results Tree listener 3. Contents of JMeter log 4. Description of screenshot of your HTTP Request sampler

As an alternative option you can try recording your scenario using JMeter Chrome Extension and see if you're able to replay recorded scenario without errors. Again, use View Results Tree listener to inspect request and response details.

In general it is not recommended to run the application under test and the load generator on the same physical or virtual machine as the load generator (JMeter in your case) may consume immense amount of resources like CPU and RAM and it may interfere your application health (unless you're using completely isolated containers), so I would recommend use separate hosts for application and the load generator.

like image 24
Dmitri T Avatar answered Oct 13 '22 01:10

Dmitri T


For anyone testing localhost with JMeter for the first time, make sure endpoint are configured correctly.

For a Get request of http://localhost:8080/rest/comments, set:

  • Server Name or IP: localhost
  • Port Number: 8080
  • Path: /rest/comments

Method: Get

like image 39
Emin Avatar answered Oct 13 '22 01:10

Emin


please note that i have attached images for each step

Step 1 : First create Thread Group .After Create thread group you will see three part. Number of thread means how many requests you want to perform and loop count means how many time you want to execute

enter image description here

enter image description here

Step 2 : right click on the thread group Add --> Sampler --> http request as like attach image .In the name filed just give a name as like whats you want.In my case it was Order Service http request

  • In protocol filed i am going to http request so for that i have given http in the box
  • In the server name i have set it to localhost because i am using local machine .If you use just remote server then use Ip address or domain name . Don't use http or port number before or after the ip address or domain name
  • In the port number field i am using 9003 that's why I have given 9003 .
  • In the http request field use your desired http method in my case i will post some data so i am using POST method so that i have selected post method
  • Path field just use the path after the ip address or domain name or localhost in my case it was order/create-order . please note that do not add forward slash before that. slash will automatically added by JMeter.
  • As it is post request so My server side request some body data so i have attached that as json format so click on the body data enter image description here

enter image description here

step 3 : Sometimes you need to pass some header information for example content type . for that you need to create another option HTTP header manager to create that option . Right click on the thread group then add-> config element- > http header manage as like attach image . I have given the content type enter image description here enter image description here

Step 4 : Now you are ready to for request to server but sometimes you need to check the response and other thing so for that click on the thread group then add -> listner -> view result tree enter image description here

Final Step : To execute the request, click on the greeen button from the top bar.

like image 28
Hoque MD Zahidul Avatar answered Oct 12 '22 23:10

Hoque MD Zahidul


In order to have Jmeter "recognize" localhost (and any other program on your machine) you have to modify host file:

On Windows

  1. Typically host is located under C:/windows/system32/drivers/etc/. Just open it with any text editor.
  2. Add following record to this file and save changes:

    127.0.0.1 localhost

On OSx

  1. Open /private/etc/hosts file for editing with any text editor
  2. Add following record to this file and save changes:

    127.0.0.1 localhost

As a result you'll map localhost to your computers default local IP address which is 127.0.0.1

like image 38
Viktor Malyi Avatar answered Oct 13 '22 01:10

Viktor Malyi