wrk-scripts icon indicating copy to clipboard operation
wrk-scripts copied to clipboard

The script requests path / when it's not presented in paths.txt

Open sergeysolovev opened this issue 6 years ago • 0 comments

Found a bug the script https://github.com/timotta/wrk-scripts/blob/master/multiplepaths.lua Check out these lines:

if counter > #paths then
  counter = 0
end

This will get you out of array boundary when counter = 0, since lua arrays' indices start from 1. In this case path variable will get nil value, thus the requested path will be /. It doesn't crash, but it may be not what's expected by a user. For example, if a service under test doesn't serve from /, wrk will output: "Non-2xx or 3xx responses: ..."

To reproduce, put these prints in the request function:

request = function()
  path = paths[counter]

  print ("counter: " .. counter)
  print ("path: " .. (path or "empty"))

  counter = counter + 1
  if counter > #paths then
    counter = 0
  end
  return wrk.format(nil, path)
end

I will suggest a fix as a PR

sergeysolovev avatar Sep 28 '17 08:09 sergeysolovev