2017-09-25 24 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開始。 –

相關問題