2017-09-25 190 views
1

在我的本地主机(127.0.0.1:8089)与蝗虫试过,但它提供了400坏请求错误:如何以编程方式调用Locust测试?

import requests 

response = requests.post('http://127.0.0.1:8089/swarm', params={"locust_count":10, "hatch_rate":5}) 
print response.text 

响应:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> 
<title>400 Bad Request</title> 
<h1>Bad Request</h1> 
<p>The browser (or proxy) sent a request that this server could not understand.</p> 

我已经验证了http://127.0.0.1:8089/确实达通过浏览器浏览它。 locustfile.py的代码可在this post处获得。

回答

0

如果你想从你的代码蝗虫开始,那么你有3种选择:

  1. (不是首选之一,但工作),您可以使用命令行运行蝗虫(--no-网络,-C ,-r) https://docs.locust.io/en/latest/running-locust-without-web-ui.html

  2. 实现你自己的蝗虫加载逻辑: https://github.com/locustio/locust/issues/222(使用消息线程提供的代码)

  3. USI NG Invokust: https://github.com/FutureSharks/invokust

第一个选项,即使不是最“Python的”是最容易做的。我仍然在第二种选择中尝试运气。

+0

感谢Abhimanyu的回复。我会尝试选项#1开始。 –

相关问题