LR接口压力测试实战(限量抢红包接口)
一、业务描述:微信群中,运营人员放出活动链接,用户单击活动链接进入活动页面如下图,用户输入手机号抢红包(红包数量有限)
二、接口测试代码
1 Action() 2 { 3 lr_rendezvous("抢红包并发"); 4 5 web_reg_find("Search=Body", 6 "SaveCount=n", 7 "Text=000000", 8 LAST); 9 lr_start_transaction("QiangHongBao"); 10 11 web_submit_data("fudai.htm", 12 "Action=http://10.72.32.226:8080/activity-center/springActivityRedPack/springActivityRedPack/{phone}/17/guchen", 13 "Method=get", 14 "RecContentType=text/html", 15 "Referer=http://10.72.32.226:8080/activity-center/springActivityRedPack/springActivityRedPack/{phone}/17/guchen", 16 "Snapshot=t1.inf", 17 "Mode=HTML", 18 // ITEMDATA, 19 // "Name=phone", "Value={phone}", ENDITEM, 20 // "Name=code", "Value=6", ENDITEM, 21 // "Name=param", "Value=hello", ENDITEM, 22 LAST); 23 24 if(atoi(lr_eval_string("{n}"))==1) 25 { 26 lr_end_transaction("QiangHongBao", LR_PASS); 27 lr_output_message("---------------------------恭喜%s,你抢到红包啦!",lr_eval_string("{phone}")); 28 } 29 30 else 31 { 32 lr_end_transaction("QiangHongBao", LR_FAIL); 33 lr_output_message("---------------对不起%s,你没有抢到",lr_eval_string("{phone}")); 34 } 35 return 0; 36 }
三、参数化配置