Skip to content

Instantly share code, notes, and snippets.

@DayoOliyide
Last active February 27, 2020 07:07
Show Gist options
  • Save DayoOliyide/30210afbd237d0ee65a02c99b06b9fb6 to your computer and use it in GitHub Desktop.
Save DayoOliyide/30210afbd237d0ee65a02c99b06b9fb6 to your computer and use it in GitHub Desktop.
Generate dynamic wrk/wrk2 requests
--[[
This is an example of a wrk/wrk2 script to dynamically generate a range of GET requests for load testing.
you can run it by tying something similar to the following
./wrk -t15 -c 15 -d 600s -R1 -s order-query.lua http://localhost:8080
NOTE: Noticed that the requests are dynamically generated once, given to all the threads
i.e you see request-a t times, then request-b t times.
Ideally i'd like each thread to send a dynamically generated request for each request,
What I see now is the group of threads getting a dynamically generated request.
--]]
orderIds = {"07290cc5-1ea4-4aa2-b340-9ddde96d8128",
"0758f91f-3ae0-42d1-be13-1adbb327f94f",
"099a7981-492f-49ed-b94c-d169e5d8e7e6",
"0a4d7d50-4a1c-4af7-b852-31f40b6e9aa2",
"0ae85927-cb5a-4f95-853e-8c0d755fe9f4",
"0c8d63ca-48aa-43cf-85fb-f3380c6195c9",
"0d12508b-7770-458c-b263-b4e99bd9637d",
"0d3150b8-f36e-48f9-bb20-88f0730717ec",
"0d545f7d-16b0-40ff-af30-b5a978efc779",
"14cef7d1-9bb8-4ef5-be74-2188c25096ac"}
apiRoute = {"", "/summary", "/details"}
setup = function(thread)
math.randomseed(os.time())
end
request = function()
local path = "/orders/" .. orderIds[math.random(#orderIds)] .. apiRoute[math.random(#apiRoute)]
-- print("Path is -->" .. path)
return wrk.format("GET", path)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment