本文介绍了有没有一种方法可以使用wrk将参数传递给GET请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要对将参数作为输入的REST API进行基准测试.我想知道是否有一种使用wrk
的方法.现在我看不到这样的选择:
I need to benchmark a REST API that takes parameters as input. I wondering if there is a way to do it using wrk
. Right now I don't see such an option:
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
存储库中对params
进行grepping并不会产生任何有用的结果.
I don't see params
used anywhere. Also grepping for params
in wrk
repo did not yield anything useful.
我想念什么吗?
推荐答案
您可以直接在url中添加它:
You can add it right inside url:
./wrk -c1 -t1 -d5s http://server.com/my_path?param_name=param_value
或者如果您想在测试期间生成它,则可以使用脚本来完成它:
or if you want to generate it during the test you can do it with a script:
./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
这篇关于有没有一种方法可以使用wrk将参数传递给GET请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!