wrk是用得比较多的跨平台压测工具,不做赘述。
本文要解决的问题是用wrk的lua脚本,以post方式发送data-form数据进行压力测试。
wrk的安装什么的,随便搞吧。直接上lua脚本test.lua:
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"
wrk.body = "param={\"imgs\":[\"http://xxx-0107.jpg\"],\"imgsType\":\"url\", \"timeout\": 5}"
function response(status, headers, body)
if status == 200 then
if(not string.find(body,'"code": 0')) then
print("error, resp: ", body)
end
wrk.thread:stop()
end
end
以上lua脚本对应的postman中的格式为:
注意是post方式哈。
另外,可以看到postman当中返回的json结构中