2015-11-05 338 views
1

我需要對以參數作爲輸入的REST API進行基準測試。我想知道是否有一種方法可以使用wrk。現在我沒有看到這樣一個選項:有沒有辦法使用wrk將參數傳遞給GET請求?

[email protected]:~/wrk$ ./wrk 
Usage: wrk <options> <url>        
    Options:            
    -c, --connections <N> Connections to keep open 
    -d, --duration <T> Duration of test   
    -t, --threads  <N> Number of threads to use 

    -s, --script  <S> Load Lua script file  
    -H, --header  <H> Add header to request  
     --latency   Print latency statistics 
     --timeout  <T> Socket/request timeout  
    -v, --version   Print version details 

當我看到這個文件:https://github.com/wg/wrk/blob/master/src/wrk.lua

我沒有看到params任何地方使用。 paramswrk回購也沒有產生任何有用的東西。

我錯過了什麼嗎?

+0

[Googling](https://www.google.com/search?q=「wrk」+ POST + with + JSON)適用於我。在它所帶來的翻版中,[this](http://riteshkrmodi.blogspot.ru/2014/08/running-wrk.html)似乎恰好描述了你所追求的內容。 – kostix

+0

@kostix,感謝您的回答,但我沒有在那裏看到我的答案。您建議的示例涉及POST,它使用BODY,我想使用GET和PARAMS。 – Akavall

回答

2

您可以添加它直接在網址:
./wrk -c1 -t1 -d5s http://server.com/my_path?param_name=param_value

或者如果你想在測試過程中產生它,你可以用一個腳本做到這一點:
./wrk -t1 -c1 -d5s -s ./scripts/my_script.lua http://server.com

其中my_script.lua是: request = function() wrk.headers["Connection"] = "Keep-Alive" param_value = math.random(1,100) path = "/my_path?param_name=" .. param_value return wrk.format("GET", path) end

+0

感謝一個非常明確的例子。 – Akavall

相關問題