Loadrunner11 pressure sensor interface simple tutorial

First, demand

Loadrunner pressure measurement using a target interface 1000 to support concurrent requirements.

Destination Interface: https://www.xxx.com/digitaldata/api/signer/1.0/signerRegist

Return: the result code is returned in a save was successful, as was abnormal parameters 4001, 0 is stored when abnormality.

 Execution equipment: Win10 (Education Edition), Loadrunner11 crack the Chinese version

Second, an overview

Loadrunner use of stress testing is generally divided into three steps, the first is the creation / editing the script, and the second is to run a load test, and the third is to analyze the test results.

 

 

 

Third, create / edit script

Click on "Create / Edit Scripts" to open the HP Virtual User Generator window. Click on "New Script" or open an existing script

 

 

Select a protocol type, here select Web (HTTP / HTML) type, create a new script.

 

 

Click "Create" dialog box appears recorded. We are due to submit a request to the interface, and then to accept the return value. There is no need to record, we manually add the script.

 

 

Next we add the script in Action inside, says:

Action()

{

         web_reg_save_param("return_code",

                  "LB=\"code\":",

                  "RB=,",

                  LAST);

   

         lr_start_transaction("发送请求事务");


         web_submit_data("web_submit_data",

                  "Action=https://www.xxxx.com/digitaldata/api/signer/1.0/signerRegist",

                  "Method=POST",

                  "TargetFrame=",

                  "Referer=",

        "RecContentType=application/json",

                  ITEMDATA,

                  "Name=signerName", "Value=xx", ENDITEM,

                  "Name=signerType", "Value=个人", ENDITEM,

                  "Name=country", "Value=cn", ENDITEM,

                  "Name=organization", "Value=xxx", ENDITEM,

                  "Name=organizationUnit", "Value=xxx", ENDITEM,

                  "Name=signerIDType", "Value=身份证", ENDITEM,

                  "Name=signerIDNo", "Value=xxx", ENDITEM,

                  LAST);


         lr_end_transaction("发送请求事务", LR_AUTO);

 
         if (atoi(lr_eval_string("{return_code}"))==1){

                  lr_output_message("操作成功");

         }

         else{

                  lr_output_message(lr_eval_string("{return_code}"));

         }

         return 0;

}

 

脚本的简单解释:

web_reg_save_param:主要是获取返回值中某些符合规则的值。

lr_start_transaction("发送请求事务"):是添加一条名为“发送请求事务”名称的事务,便于统计,与lr_end_transaction("发送请求事务", LR_AUTO); 配合使用。

web_submit_data:向接口提交数据,格式类似于键值对。

【注:如需在某个时间点达到1000的并发,需要设置集合点】

 

脚本编写完成后进行保存,保存后点击“运行”。

 

我们在条件判断中设定了如果返回值为1,则显示操作成功。由图可知,结果显示为操作成功,则说明我们编写的脚本正确且接口返回了正确的值。

 

 

 

四、     设置场景运行负载测试

点击“运行负载测试”,在弹出的页面选择可用脚本,如果没有则点击文件夹图标打开已有的脚本。

 

 

设置场景计划,双击全局计划中的操作可进行设置,双击“启动Vuser”来设置虚拟用户的总数。同理设置“停止Vuser”。

 

 

 

另外还需要设置Load Generator为localhost,不然会报错执行不了,报错为提示你 脚本是否可以执行

 

 

 

 

点击运行即可开始设置的场景,运行的过程可在运行的tab页中查看。

 

 

 

五、     查看分析结果

在运行界面的结果菜单中点击,结果——分析结果,可自动生成分析结果。

 

 

点击页面中的“报告”——“报告模板”——生成报告可生成一定模板的压测报告。

 

 

           

 

Guess you like

Origin www.cnblogs.com/bcaixl/p/11275410.html