How to make Jmeter recognize “localhost” URL?

血红的双手。 提交于 2019-12-23 21:52:09

问题


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 –


回答1:


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.




回答2:


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




回答3:


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):

The correct way:

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

Http Request Defaults (Jmeter):

Http Request (Test):




回答4:


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




回答5:


Get your ip addres using ipconfig (windows)

Think your URL is - http://192.168.8.149:3000/api/user/showTeams

Use Server Name or IP -192.168.8.149 Use Port Number - 3000 Use Protocol - http Use Path - api/user/showTeams




回答6:


  • Use IPv4 address instead of using localhost or 127.0.0.1 to access your local application.
  • Get JMeter's recording template from File > Template.
  • Set proxy on 8888 port and start recording


来源:https://stackoverflow.com/questions/29666220/how-to-make-jmeter-recognize-localhost-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!