【问题标题】:Is there a way to pass parameters to GET request using wrk?有没有办法使用 wrk 将参数传递给 GET 请求?
【发布时间】:2016-02-06 13:06:42
【问题描述】:

我需要对将参数作为输入的 REST API 进行基准测试。我想知道是否有办法使用wrk。现在我没有看到这样的选项:

user@Ubuntu-K56CA:~/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 在任何地方使用。在wrk repo 中寻找params 也没有产生任何有用的东西。

我错过了什么吗?

【问题讨论】:

  • Googling 为我工作。在它带来的结果中,this 似乎准确地描述了你所追求的。
  • @kostix,感谢您的回答,但我在那里看不到我的回答。您建议的示例处理 POST 并且它使用 BODY,我想使用 GET 和 PARAMS。

标签: rest benchmarking wrk


【解决方案1】:

您可以在 url 中添加它:

./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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-27
    • 2012-02-25
    • 1970-01-01
    • 2022-01-03
    相关资源
    最近更新 更多