2015-11-05 333 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

相关问题