测试就是来开荒 发表于 2017-6-9 16:06:25

LR 性能测试求助

说明

1.用户登录部分,用户名和密码我已经实现参数化了
2.用户登录成功之后,点击【我要报名】,点击【同意以下协议并报名】,进入选择课程页面,每个用户可以自由选择多种课程,选择好之后【保存班级】,主要就是做这一部分的压力测试
3.以下是我录制的脚本,请各位大神帮忙看看,哪些地方该设置参数化和关联
4.脚本需要做哪些修改

脚本顺序

https://testerhome.com/uploads/photo/2017/abf21fc825ffb85d6a3251b6f4d7dea1.png!large
脚本

1.登录脚本
ActionDL()
{

    web_set_max_html_param_len("1024");

    web_url("picinfo.ini",
      "URL=http://se.360.cn/cloud/picinfo.ini",
      "TargetFrame=",
      "Resource=1",
      "RecContentType=application/octet-stream",
      "Referer=",
      "Snapshot=t1.inf",
      LAST);

//web_add_cookie("CNZZDATA1254046670=1710710057-1491368334-%7C1491368334; DOMAIN=test.lndxpt.com");

//web_add_cookie("UM_distinctid=15b3ca07cf7e7d-0106a39880d561-6d247a13-15f900-15b3ca07cf8deb; DOMAIN=test.lndxpt.com");

/* Registering parameter(s) from source task id 7
    // {JSESSIONID3} = "jrt39txdore6"
    // */

    web_reg_save_param("JSESSIONID3",
      "LB/IC=jsessionid=",
      "RB/IC=\"",
      "Ord=1",
      "RelFrameId=1",
      "Search=body",
      LAST);

    web_url("lndxreg!toReg.do",
      "URL=http://test.lndxpt.com/lndx1/lndxreg!toReg.do?compCode=tjlndx",
      "TargetFrame=",
      "Resource=0",
      "RecContentType=text/html",
      "Referer=",
      "Snapshot=t2.inf",
      "Mode=HTML",
      EXTRARES,
      "URL=images/bg.png", "Referer=http://test.lndxpt.com/lndx1/lndxreg!toReg.do?compCode=tjlndx", ENDITEM,
      "URL=images/icon_x.png", "Referer=http://test.lndxpt.com/lndx1/lndxreg!toReg.do?compCode=tjlndx", ENDITEM,
      "URL=http://c.cnzz.com/core.php?web_id=1254046670&t=z", "Referer=http://test.lndxpt.com/lndx1/lndxreg!toReg.do?compCode=tjlndx", ENDITEM,
      "URL=http://z11.cnzz.com/stat.htm?id=1254046670&r=&lg=zh-cn&ntime=none&cnzz_eid=1710710057-1491368334-&showp=1600x900&t=%E5%A4%A9%E6%B4%A5%E5%B8%82%E8%80%81%E5%B9%B4%E4%BA%BA%E5%A4%A7%E5%AD%A6&umuuid=15b3ca07cf7e7d-0106a39880d561-6d247a13-15f900-15b3ca07cf8deb&h=1&rnd=1054212925", "Referer=http://test.lndxpt.com/lndx1/lndxreg!toReg.do?compCode=tjlndx", ENDITEM,
      LAST);

    lr_think_time(17);


    lr_start_transaction("登录");

    lr_rendezvous("登录");
    web_reg_save_param("sid",
      "LB=<a href=\"lndxreg!toleave.do?compCode=tjlndx&sid=",
      "RB=\">我要请假",
      "Ord=1",
      "RelFrameId=1",
      LAST);

    web_reg_save_param("sessionloginkey",
      "LB=sessionloginkey=",
      "RB=\">回首页</a>",
      "Ord=1",
      "RelFrameId=1",
      LAST);

    web_submit_data("lndxreg!checkCard.do;jsessionid=jrt39txdore6",
      "Action=http://test.lndxpt.com/lndx1/lndxreg!checkCard.do;jsessionid={JSESSIONID3}",
      "Method=POST",
      "TargetFrame=",
      "RecContentType=text/html",
      "Referer=http://test.lndxpt.com/lndx1/lndxreg!toReg.do?compCode=tjlndx",
      "Snapshot=t3.inf",
      "Mode=HTML",
      ITEMDATA,
      "Name=sname", "Value={SNAME}", ENDITEM,
      "Name=idCard", "Value={IDCARD}", ENDITEM,
      "Name=schoolname", "Value=天津市老年人大学", ENDITEM,
      "Name=compCode", "Value=tjlndx", ENDITEM,
      "Name=log", "Value=", ENDITEM,
      EXTRARES,
      "URL=images/nav_icon.png", ENDITEM,
      "URL=http://z11.cnzz.com/stat.htm?id=1254046670&r=http%3A%2F%2Ftest.lndxpt.com%2Flndx1%2Flndxreg!toReg.do%3FcompCode%3Dtjlndx&lg=zh-cn&ntime=1491368334&cnzz_eid=1710710057-1491368334-&showp=1600x900&t=%E5%A4%A9%E6%B4%A5%E5%B8%82%E8%80%81%E5%B9%B4%E4%BA%BA%E5%A4%A7%E5%AD%A6&umuuid=15b3ca07cf7e7d-0106a39880d561-6d247a13-15f900-15b3ca07cf8deb&h=1&rnd=518854306", ENDITEM,
      LAST);

    lr_end_transaction("登录", LR_AUTO);

    //lr_output_message("username = %s,idCard = %s", lr_eval_string("{SNAME}"), lr_eval_string("{IDCARD}"));

return 0;
}2.登录成功之后,我要报名脚本
ActionXZBMBJ()
{

    lr_think_time(37);

    web_url("sc.png",
      "URL=http://test.lndxpt.com/lndx1/images/sc.png",
      "TargetFrame=",
      "Resource=1",
      "RecContentType=image/png",
      "Referer=http://test.lndxpt.com/lndx1/lndxreg!tonet.do",
      "Snapshot=t6.inf",
      LAST);

    web_url("lndxreg!findclass.do",
      "URL=http://test.lndxpt.com/lndx1/lndxreg!findclass.do?compCode=tjlndx&sid={sid}&scnamelike=&week=&organid=1020002&courseId=11020002&page=1",
      "TargetFrame=",
      "Resource=1",
      "RecContentType=html/text",
      "Referer=http://test.lndxpt.com/lndx1/lndxreg!tonet.do",
      "Snapshot=t7.inf",
      LAST);

    web_url("lndxreg!verifySelectClass.do",
      "URL=http://test.lndxpt.com/lndx1/lndxreg!verifySelectClass.do?sid={sid}&termid=3020004&sclass=&sclid=1465020012",
      "TargetFrame=",
      "Resource=1",
      "RecContentType=html/text",
      "Referer=http://test.lndxpt.com/lndx1/lndxreg!tonet.do",
      "Snapshot=t8.inf",
      LAST);

    web_url("lndxreg!verifySelectClass.do_2",
      "URL=http://test.lndxpt.com/lndx1/lndxreg!verifySelectClass.do?sid={sid}&termid=3020004&sclass=1465020012,&sclid=1465020013",
      "TargetFrame=",
      "Resource=1",
      "RecContentType=html/text",
      "Referer=http://test.lndxpt.com/lndx1/lndxreg!tonet.do",
      "Snapshot=t9.inf",
      LAST);

    web_url("lndxreg!verifySelectClass.do_3",
      "URL=http://test.lndxpt.com/lndx1/lndxreg!verifySelectClass.do?sid={sid}&termid=3020004&sclass=1465020012,1465020013,&sclid=1465020014",
      "TargetFrame=",
      "Resource=1",
      "RecContentType=html/text",

      "Referer=http://test.lndxpt.com/lndx1/lndxreg!tonet.do",
      "Snapshot=t10.inf",
      LAST);

    return 0;
}4.提交报名班级的脚本
ActionBCBJ()
{

    lr_think_time(15);

    lr_start_transaction("保存报名");

    lr_rendezvous("保存报名");



    web_submit_data("lndxreg!checkSc.do",
      "Action=http://test.lndxpt.com/lndx1/lndxreg!checkSc.do",
      "Method=POST",
      "TargetFrame=",
      "RecContentType=text/html",
      "Referer=http://test.lndxpt.com/lndx1/lndxreg!tonet.do",
      "Snapshot=t11.inf",
      "Mode=HTML",
      ITEMDATA,
      "Name=scnamelike", "Value=", ENDITEM,
      "Name=schoolname", "Value=天津市老年人大学", ENDITEM,
      "Name=compCode", "Value=tjlndx", ENDITEM,
      "Name=sid", "Value={sid}", ENDITEM,
      "Name=sessionloginkey", "Value={sessionloginkey}", ENDITEM,
      "Name=log", "Value=", ENDITEM,
      "Name=sclass", "Value=1465020012,1465020013,1465020014,", ENDITEM,
      "Name=termid", "Value=3020004", ENDITEM,
      "Name=courseid", "Value=11020002", ENDITEM,
      "Name=week", "Value=", ENDITEM,
      "Name=organid", "Value=1020002", ENDITEM,
      "Name=page", "Value=1", ENDITEM,
      "Name=topage", "Value=2", ENDITEM,
      EXTRARES,
      "Url=http://z11.cnzz.com/stat.htm?id=1254046670&r=http%3A%2F%2Ftest.lndxpt.com%2Flndx1%2Flndxreg!tonet.do&lg=zh-cn&ntime=1491368334&cnzz_eid=1710710057-1491368334-&showp=1600x900&t=%E5%A4%A9%E6%B4%A5%E5%B8%82%E8%80%81%E5%B9%B4%E4%BA%BA%E5%A4%A7%E5%AD%A6&umuuid=15b3ca07cf7e7d-0106a39880d561-6d247a13-15f900-15b3ca07cf8deb&h=1&rnd=696609092", ENDITEM,
      LAST);

    web_url("lndxreg!checkwait.do",
      "URL=http://test.lndxpt.com/lndx1/lndxreg!checkwait.do?compCode=tjlndx&sid={sid}&sessionloginkey={sessionloginkey}",
      "TargetFrame=",
      "Resource=0",
      "RecContentType=text/html",
      "Referer=http://test.lndxpt.com/lndx1/lndxreg!checkSc.do",
      "Snapshot=t12.inf",
      "Mode=HTML",
      EXTRARES,
      "Url=http://z11.cnzz.com/stat.htm?id=1254046670&r=http%3A%2F%2Ftest.lndxpt.com%2Flndx1%2Flndxreg!checkSc.do&lg=zh-cn&ntime=1491368334&cnzz_eid=1710710057-1491368334-&showp=1600x900&t=&umuuid=15b3ca07cf7e7d-0106a39880d561-6d247a13-15f900-15b3ca07cf8deb&h=1&rnd=1916364215", "Referer=http://test.lndxpt.com/lndx1/lndxreg!checkwait.do?compCode=tjlndx&sid={sid}&sessionloginkey={sessionloginkey}", ENDITEM,
      LAST);

    lr_end_transaction("保存报名", LR_AUTO);

    return 0;
}



测试的味道 发表于 2017-6-9 16:42:20

脚本问题:

没有检查点
没有特殊原因,登录请放在init里进行初始化
参数化:

从你的描述来看 需要参数化的有这几个

用户名密码
课程参数
最后:
脚本方面能看到的东西不多,性能测试难点是在方案上.
在有明确的业务场景模型后,脚本应该参数化哪些 模型里都会告诉你

小爸爸 发表于 2017-6-9 16:43:10

思考时间可以优化下~ 现在全是用的实际的思考时间~ 可以结合业务设置思考时间,然后使用随机分布 如80%-120%。
另:如果做狭义并发的话,需要添加集合点。

小皮球的故事 发表于 2017-6-9 16:45:04

建议:

关于什么地方需要参数化和关联,这需要你去分析业务、压测需求来做,你们的业务并不复杂

1. 登录脚本问题

问题1:LR脚本中,最好不要用中文
lr_rendezvous("登录");
web_reg_save_param("sid",
    "LB=<a href=\"lndxreg!toleave.do?compCode=tjlndx&sid=",
    "RB=\">我要请假",   //左右边界不要中文
    "Ord=1",
    "RelFrameId=1",
    LAST);

web_reg_save_param("sessionloginkey",
    "LB=sessionloginkey=",
    "RB=\">回首页</a>",   //左右边界不要中文
    "Ord=1",
    "RelFrameId=1",
    LAST);

web_submit_data("lndxreg!checkCard.do;jsessionid=jrt39txdore6",
    "Action=http://test.lndxpt.com/lndx1/lndxreg!checkCard.do;jsessionid={JSESSIONID3}",
    "Method=POST",
    "TargetFrame=",
    "RecContentType=text/html",
    "Referer=http://test.lndxpt.com/lndx1/lndxreg!toReg.do?compCode=tjlndx",
    "Snapshot=t3.inf",
    "Mode=HTML",
    ITEMDATA,
    "Name=sname", "Value={SNAME}", ENDITEM,
    "Name=idCard", "Value={IDCARD}", ENDITEM,
    "Name=schoolname", "Value=天津市老年人大学", ENDITEM,   //这里的中文,写入后应该不是正常的中文
    "Name=compCode", "Value=tjlndx", ENDITEM,
    "Name=log", "Value=", ENDITEM,
    EXTRARES,
    "URL=images/nav_icon.png", ENDITEM,
    "URL=http://z11.cnzz.com/stat.htm?id=1254046670&r=http%3A%2F%2Ftest.lndxpt.com%2Flndx1%2Flndxreg!toReg.do%3FcompCode%3Dtjlndx&lg=zh-cn&ntime=1491368334&cnzz_eid=1710710057-1491368334-&showp=1600x900&t=%E5%A4%A9%E6%B4%A5%E5%B8%82%E8%80%81%E5%B9%B4%E4%BA%BA%E5%A4%A7%E5%AD%A6&umuuid=15b3ca07cf7e7d-0106a39880d561-6d247a13-15f900-15b3ca07cf8deb&h=1&rnd=518854306", ENDITEM,
    LAST);
2. 报名脚本问题
ActionWYBM()
{
    lr_think_time(19);

    web_url("lndxreg!login.do",                  //这里的参数化sid注意要和sessionloginkey、jsessionid 一一对应
      "URL=http://test.lndxpt.com/lndx1/lndxreg!login.do?compCode=tjlndx&sid={sid}&sessionloginkey={sessionloginkey}",
      "TargetFrame=",
      "Resource=0",
      "RecContentType=text/html",
      "Referer=http://test.lndxpt.com/lndx1/lndxreg!checkCard.do;jsessionid={JSESSIONID3}",
      "Snapshot=t4.inf",
      "Mode=HTML",
      EXTRARES,
      "URL=http://z11.cnzz.com/stat.htm?id=1254046670&r=http%3A%2F%2Ftest.lndxpt.com%2Flndx1%2Flndxreg!checkCard.do%3Bjsessionid%3D{JSESSIONID3}&lg=zh-cn&ntime=1491368334&cnzz_eid=1710710057-1491368334-&showp=1600x900&t=%E5%A4%A9%E6%B4%A5%E5%B8%82%E8%80%81%E5%B9%B4%E4%BA%BA%E5%A4%A7%E5%AD%A6&umuuid=15b3ca07cf7e7d-0106a39880d561-6d247a13-15f900-15b3ca07cf8deb&h=1&rnd=543153531", "Referer=http://test.lndxpt.com/lndx1/lndxreg!login.do?compCode=tjlndx&sid={sid}&sessionloginkey={sessionloginkey}", ENDITEM,
      LAST);

    lr_output_message("username = %s,idCard = %s", lr_eval_string("{SNAME}"), lr_eval_string("{IDCARD}"));


    lr_think_time(31);


    lr_start_transaction("同意协议");

    lr_rendezvous("同意协议");

    web_submit_data("lndxreg!tonet.do",                //该函数做一个检查点,验证是否“同意协议”成功
      "Action=http://test.lndxpt.com/lndx1/lndxreg!tonet.do",
      "Method=POST",
      "TargetFrame=",
      "RecContentType=text/html",
      "Referer=http://test.lndxpt.com/lndx1/lndxreg!login.do?compCode=tjlndx&sid=3020002&sessionloginkey=1491370819744-3355",
      "Snapshot=t5.inf",
      "Mode=HTML",
      ITEMDATA,
      "Name=Submit", "Value=同意以下协议并报名", ENDITEM,
      "Name=schoolname", "Value=天津市老年人大学", ENDITEM,
      "Name=sessionloginkey", "Value={sessionloginkey}", ENDITEM,
      "Name=compCode", "Value=tjlndx", ENDITEM,
      "Name=log", "Value=", ENDITEM,
      "Name=sid", "Value={sid}", ENDITEM,
      EXTRARES,
      "URL=images/search_b.png", ENDITEM,
      "URL=images/fenye_nav.gif", ENDITEM,
      "URL=images/jia.gif", ENDITEM,
      "URL=http://z11.cnzz.com/stat.htm?id=1254046670&r=http%3A%2F%2Ftest.lndxpt.com%2Flndx1%2Flndxreg!login.do%3FcompCode%3Dtjlndx%26sid%3D{sid}%26sessionloginkey%3D{sessionloginkey}&lg=zh-cn&ntime=1491368334&cnzz_eid=1710710057-1491368334-&showp=1600x900&t=%E5%A4%A9%E6%B4%A5%E5%B8%82%E8%80%81%E5%B9%B4%E4%BA%BA%E5%A4%A7%E5%AD%A6&umuuid=15b3ca07cf7e7d-0106a39880d561-6d247a13-15f900-15b3ca07cf8deb&h=1&rnd=2067943120", ENDITEM,
      LAST);



    lr_end_transaction("同意协议", LR_AUTO);

return 0;
}
3.同意协议之后,选择报名班级的脚本

问题1:图片获取部分可以去掉
问题2:具体搞清楚那个是“选择报名班级”的部分,在该部分做检查点、事务定义

4.提交报名班级的脚本

问题1:做检查点
问题2:request body中,最好不要有中文,LR好像不识别
页: [1]
查看完整版本: LR 性能测试求助