-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadtest.lua
More file actions
32 lines (28 loc) · 856 Bytes
/
loadtest.lua
File metadata and controls
32 lines (28 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
transact = function()
headers = {}
headers["Content-Type"] = "application/json"
id = math.random(1, 5)
value = math.random(1, 10000)
tp = "cd"
tpidx = math.random(1,2)
body = '{"valor":' .. tostring(value) .. ',"tipo":"' .. string.sub(tp, tpidx, tpidx) .. '","descricao":"crebito"}'
return wrk.format("POST", "/clientes/" .. tostring(id) .. "/transacoes", headers, body)
end
history = function()
headers = {}
headers["Accept-Encoding"] = "gzip"
id = math.random(1, 6)
body = ""
return wrk.format("GET", "/clients/" .. tostring(id) .. "/extrato", headers, body)
end
requests = {}
requests[0] = transact
requests[1] = history
requests[2] = transact
requests[3] = history
requests[4] = history
requests[5] = history
requests[6] = history
request = function()
return requests[math.random(0,6)]()
end