Lua variable not updated in wrk

71 Views Asked by At

I need to run a script in wrk to test my endpoint. My script is as followed:


thread_counter = 0
local thread_id = 1
setup = function (thread)
    thread_counter = thread_counter + 1
    thread_id = thread_counter
    print("thread_id 1 " ..thread_id)
end

request = function() 
    idx = math.random(200)
    print("thread_id 2 " ..thread_id)
...
end

I can see that thread_id is updated in the setup function, but not the request function. Why and how can I fix this?

0

There are 0 best solutions below