[英]Locust Error nodename nor servname provided, or not known
First time caller long time listener:)第一次来电者长时间听众:)
I'm running a locust test on a site (or at least trying) but getting 100% failure with the following error我正在一个站点上运行 locust 测试(或至少尝试),但 100% 失败并出现以下错误
from locust import HttpLocust, TaskSet, task, between from locust.events import request_success import logging, contextlib, requests try: from http.client import HTTPConnection # py3 except ImportError: from httplib import HTTPConnection # py2 from locust import HttpLocust, TaskSet, task, between from locust.events import request_success import logging, contextlib, requests try: from http.client import HTTPConnection # py3 except ImportError: from httplib import HTTPConnection # py2
def debug_requests_on(): '''Switches on logging of the requests module.''' HTTPConnection.debuglevel = 1 def debug_requests_on(): '''开启请求模块的日志记录。''' HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
def call_hook(resp, *args, **kwargs): print(f"{resp.url} returned status code of {resp.status_code}") def call_hook(resp, *args, **kwargs): print(f"{resp.url} 返回状态码 {resp.status_code}")
class RedirectTaskSet(TaskSet): class 重定向任务集(任务集):
def on_start(self):
pass
def on_stop(self):
pass
@task
def redirect_task(self):
name = '/voting'
response = self.client.get('/voting', allow_redirects=True, name=name)
print("Response status code:", response.status_code)
print("Response history:", response.history)
if not response.ok:
self.log_failure('Request failed ', name, response)
def log_failure(self, message, name, response):
pass # add some logging
#@task
#def log_response_codes(self):
# requests.get('https://thevoice.com.au/voting', hooks={'response': call_hook})
class RedirectLocust(HttpLocust): class RedirectLocust(HttpLocust):
task_set = RedirectTaskSet
wait_time = between(0.5,3)
host = "https://www.thevoice.com.au"
#debug_requests_on()
Thanks for adding your test plan.感谢您添加测试计划。 The problem is that thevoice.com.au cannot be resolved (has no DNS entry).
问题是voice.com.au 无法解析(没有DNS 条目)。 It is unrelated to locust.
它与蝗虫无关。 You can try it using curl, ping, or whatever other tool to confirm.
您可以使用 curl、ping 或任何其他工具进行确认。
~ curl https://www.thevoice.com.au
curl: (6) Could not resolve host: www.thevoice.com.au
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.