我在Load Impact中创建了一个用户场景,模拟我们web商店中的几百个用户。
问题是,我似乎无法模拟Azure队列中的用户。队列只随着+1个用户而增加,而不是我想要的数百个用户:)
我已经创建了一个随机关联id,但会话似乎仍然存在。
有没有一种方法可以销毁会话,以便在脚本循环时创建一个新的会话?
我找到了一个LUA参考,上面写着destroy:session
,但它对我不起作用。
function rnd()
return math.random(0000, 9999)
end
{"POST", "http://STORE.////",
headers={["Content-Type"]="application/json;charset=UTF-8"},
data="{"ChoosenPhoneModelId":0,"PricePlanId":"phone","CorrelationId":"e97bdaf6-ed61-4fb3-".. rnd().."-d3bb09789feb","ChoosenPhoneColor":{"Color":1,"Code":"#d0d0d4","Name":"Silver","DeliveryTime":"1-2 veckor","$$hashKey":"005"},"ChoosenAmortization":{"AmortizationLength":24,"Price":312,"$$hashKey":"00H"},"ChoosenPriceplan":{"IsPostpaid":true,"IsStudent":false,"IsSenior":false,"Title":"Fast ","Description":"Hello.","MonthlyAmount":149,"AvailiableDataPackages":null,"SubscriptionBinding":1,"$$hashKey":"00M"},"ChoosenDataPackage":{"Description":"20
GB","PricePerMountInKr":149,"DataAmountInGb":20,"$$hashKey":"00U"}}",
auto_decompress=true}
})
关于如何操作的任何提示。提前谢谢。
关联id不是一个随机数。它是由您的服务器在cookie中设置的。像这样获取和使用:
local response = http.request_batch({
{"GET", "http://store.///step1", auto_decompress=true},
})
-- extract correlation Id
local strCorrelationId = response[1].cookies['corrIdCookie']
{"POST", "http://STORE.////",
headers={["Content-Type"]="application/json;charset=UTF-8"},
data="{"ChoosenPhoneModelId":0,"PricePlanId":"phone","CorrelationId":"".. strCorrelationId .. "","ChoosenPhoneColor":{"Color":1,"Code":"#d0d0d4","Name":"Silver","DeliveryTime":"1-2 veckor","$$hashKey":"005"},"ChoosenAmortization":{"AmortizationLength":24,"Price":312,"$$hashKey":"00H"},"ChoosenPriceplan":{"IsPostpaid":true,"IsStudent":false,"IsSenior":false,"Title":"Fast ","Description":"Hello.","MonthlyAmount":149,"AvailiableDataPackages":null,"SubscriptionBinding":1,"$$hashKey":"00M"},"ChoosenDataPackage":{"Description":"20
GB","PricePerMountInKr":149,"DataAmountInGb":20,"$$hashKey":"00U"}}",
auto_decompress=true}
})
这就是您的用户的独特之处。如果将CorrelationId设置为任意随机数,则服务器将不会接受队列中的会话。
一旦它是唯一的和正确的,您的服务器将正确地接受POST。