web test LoadRunner xml / webservice / json / MQ / soapUI / baowen / WebService

转载地址:http://lindows.iteye.com/blog/1725279


loadrunner 学习笔记--Web Services

http://www.byywee.com/page/M0/S227/227297.html

使用loadrunner测试Web Services的程序

http://blog.sina.com.cn/s/blog_7833c84501010e9d.html

首页>> 文章精选>> 测试丛书>> 性能测试进阶指南——LoadRunner 11实战>> 查看资讯

性能测试进阶指南—LoadRunner 11实战(20) 发布时间: 2012-6-11 10:42 作者: 陈霁

http://www.51testing.com/html/42/n-815142.html

Loadrunner上传文件解决办法(大文件)

http://www.chinatesting.cn/212/12929212.shtml

 

Loadrunner 录制WebService协议测试脚本的两种方式 / WebService协议Loadrunner脚本录制的两种方式.doc

http://dl.iteye.com/topics/download/be0e0edc-f634-3fbf-8faa-bc4ea7c88ef3

文档背景:

信息体系各系统开发时会和多个系统交互,而交互过程中不可避免的会用到接口,而web service技术无疑提供了一种很好的方式,对于使用web service协议的接口如何进行测试以及测试脚本如何准备,这边基于现有条件,讲解web service协议的接口测试脚本准备的两种方式。

正文:

第一种方式:步骤一:需项目组事先提供报文、接口的入口URL以及接口正确调用时的响应。打开loadrunner11,新建单协议脚本,选择webservice协议,如下图1所示

https://i-blog.csdnimg.cn/blog_migrate/d70007ef639b9b4d630e76487b387cbf.png

 

loadrunner导入soap服务

https://i-blog.csdnimg.cn/blog_migrate/529d7d9080d7bc77143b0103c51ee84c.png

loadrunner导入soap服务项目组自定义XML文件

https://i-blog.csdnimg.cn/blog_migrate/29539c424ef03edd2272744480eb38db.png

步骤三:打开报文后,点击图三中的Load按钮,点击后如图四所示,在URL栏中,输入接口的地址,再在soap action中输入该接口的操作名称,可任意填写,但是最好是和接口所代表的意思一致,便于识别。这边用的例子为:

loadrunner导入soap_url和soap_saction业务名称

https://i-blog.csdnimg.cn/blog_migrate/b8734e87177fad9902a5fdf118ae10c8.jpeg

 

步骤四:点击OK,添加事务以及相应检查点和参数化。即可生成脚本。

https://i-blog.csdnimg.cn/blog_migrate/5cbf1beb4958ab0b1e47bbf1c9bb1373.png

   

   // 最好加上如下xml描述文件

   web_add_header("Content-Type","application/xml");

   // 最好加上如上xml描述文件

  

步骤五:脚本生成后,可以运行下,看脚本的相应是否和项目组提供的一致,如果一致的话,说明脚本正确,不一致的话,需要调试,至于如何调试,在此不一一赘述。唯一的条件是如果项目组提供的xml报文中的参数有中文,在转化成脚本后会成为乱码,最好采用数据或者字母,如果必须是中文的话,需要做转码处理。

===================================================================================

第二种方式:以pos价格服务的脚本准备为例

步骤一:打开loadrunner11,新建单协议脚本,选择webservice协议,如下图1所示

https://i-blog.csdnimg.cn/blog_migrate/d70007ef639b9b4d630e76487b387cbf.png

 

步骤二:步骤一完成后,出现如下界面,如图二,点击Add Service Call如图三所示,在图三中的Service处选择Import Service,选择URL(注:开发人员提供的URL “http://192.168.100.125:8180/ws/AccessWS.jws?wsdl”),点击Import 生成如图四:

https://i-blog.csdnimg.cn/blog_migrate/e6a3cf1dd0e7aaba322fdc52cfda4c6b.png

https://i-blog.csdnimg.cn/blog_migrate/b7a35ed68dff8150425abdc8599365c5.png

点击id字段,选择value输入值,按照这种方法依次将pwd、fn、args字段赋值。如图五

https://i-blog.csdnimg.cn/blog_migrate/ed25b1200c0f67d80ea3f78e3e17d7dc.png

 

最后在Output Arguments的processResult处勾选Save returned value in para,如图六,该步骤是为将返回参数打印出来,以此来验证数据的正确性。然后点击OK,如图七:

https://i-blog.csdnimg.cn/blog_migrate/dca32bb342ac035d5601773e4f316b6e.png

 

添加事务和参数输出后即可:

https://i-blog.csdnimg.cn/blog_migrate/0c019dfbbb50833e58ae8eb1a5eebf05.png

总结

第一种方式和第二种方式各有各的使用优点和局限性,第一种方式,需要项目组提供报文,以及接口访问的url还有报文的响应。

第二种方式,需要了解输入输出参数的名字和类型。如果一个wsdl文件中包含多个接口以及接口和接口之间有关联性的话,脚本准备起来有一定的复杂性。

不过各种方式都要基于项目组所配合的程度以及提供数据的方式,如果提供第一种方便就用第一种,如果第二种方便就用第二种。

 

loadrunner baowen / 报文 / 接口报文 

loadrunner--中台商品寻源接口报文样例

D:\TestCase\20140604_zhongtai_xunyuan\TC_SSDS_PageSource\TC_SSDS_PageSource.usr

C代码   收藏代码
  1. Action()  
  2. {  
  3.      
  4.     lr_start_transaction("pageSource");  
  5.   
  6.     web_reg_find("Fail=NotFound",  
  7.         "Search=All",  
  8.         "SaveCount=pageCount",  
  9.         "Text=<Status>COMPLETE</Status>",  
  10.         LAST);  
  11.     web_custom_request("PageSource",  
  12.         "URL=http://ssdspre.cns*****.com/ssds-web/onLinePageSource.htm",  
  13.         //RL=http://10.27.39.75:9080/ssds-web/onLinePageSource.htm",  
  14.        // "URL=http://10.27.39.69:9080/ssds-web/onLinePageSource.htm",  
  15.        // "URL=http://10.27.39.56:9080/ssds-web/onLinePageSource.htm",  
  16.        // "URL=http://10.27.39.55:9080/ssds-web/onLinePageSource.htm",  
  17.         "Method=POST",  
  18.         "Mode=HTTP",  
  19.         "EncType=text/xml; charset=GB2312",  
  20.         "Body=<?xml version=\"1.0\" encoding=\"utf-8\"?>"  
  21.         "<MbfService>"  
  22.         "<input1>"  
  23.         "<MbfHeader>"  
  24.         "<ServiceCode>SearchSourceMgmt</ServiceCode>"  
  25.         "<Operation>queryOnlinePageSource</Operation>"  
  26.         "<AppCode>B2C</AppCode><UId>20140520131415161234567890123456</UId><AuthId>B2C;iEIKQ1lqBnW$</AuthId></MbfHeader>"  
  27.         "<MbfBody>"  
  28.             "<onLinePageSourceReq>"  
  29.             "<cmmdtyCode>{cmmdtyCode}</cmmdtyCode>"  
  30.             "<cityCode>{cityCode}</cityCode>"  
  31.             "<districtCode>{districtCode}</districtCode>"  
  32.             "<supplierCode/>"  
  33.             "<searchType>01</searchType>"  
  34.             "</onLinePageSourceReq>"  
  35.         "</MbfBody>"  
  36.         "</input1>"  
  37.         "</MbfService>",LAST);  
  38.     if((atoi(lr_eval_string("{pageCount}"))<1))                 
  39.     {     
  40.          lr_end_transaction("pageSource",LR_FAIL);    
  41.     }  
  42.     else  
  43.     {     
  44.          lr_end_transaction("pageSource",LR_PASS);  
  45.     }  
  46.     return 0;  
  47. }  

 

(参数文件数据要求:一一对应)

 D:\TestCase\20140604_zhongtai_xunyuan\TC_SSDS_PageSource\pageSource.dat

 

Dat代码   收藏代码
  1. cmmdtyCode,cityCode,districtCode  
  2. 000000000103929805,000001000186,70103  
  3. 000000000101063403,000001000016,56503  
  4. 000000000100005503,000001000048,75205  
  5. 000000000100005503,000001000051,75506  
  6. 000000000100005503,000001000057,76206  
  7. 000000000100042403,000001000096,79905  
  8. 000000000100042403,000001000097,31317  
  9. 000000000100042403,000001000098,31411  
  10. 000000000100042403,000001000100,31610  
  11. 000000000100042403,000001000000,01020  
  12. 000000000100081803,000001000154,73412  
  13. 000000000100081803,000001000155,73511  
  14. 000000000100081803,000001000159,73912  
  15. 000000000100081803,000001000163,74611  
  16. 000000000100092203,000001000199,41111  
  17. 000000000100154503,000001000333,02340  
  18. 000000000100154503,000001000273,81807  
  19. 000000000100165503,000001000151,73109  
  20. 000000000100165503,000001000161,74404  
  21. 000000000100171503,000001000139,71310  

 

Loadrunner WebService Exception 

问题1:

SOAP request failed due to incorrect SOAP format

Loadrunner Replay log:

Action.c(14): Error: The reason for the SOAP fault is: "com.s*****.framework.dal.exception.DalException incompatible with com.s×××××.framework.workflow.exception.WorkflowException"

Action.c(14): Error: SOAP request "SOAP Request" execution failed

Loadrunner Test Result: 

Xml代码   收藏代码
  1. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">  
  2.     <soap:Body>  
  3.         <soap:Fault>  
  4.             <faultcode>soap:Server</faultcode>  
  5.             <faultstring>com.s*****.framework.dal.exception.DalException. incompatible with   
  6.                 com.s*****.framework.exception.WorkflowException</faultstring>  
  7.         </soap:Fault>       
  8.     <soap:Body>     
  9. </soap:Envelope>    

Loadrunner Replay log: 

Virtual User Script started at : 2014-05-12 15:49:57

Starting action vuser_init.

Ending action vuser_init.

Running Vuser...

Starting iteration 1.

Starting action Action.

Action.c(7): SOAP request "SOAP Request" started

Action.c(7): Warning: HTTP status code 500 returned by the server

Action.c(7): Error: The reason for the SOAP fault is:"Error reading XMLStreamReader."

Action.c(7): Error: SOAP request "SOAP Request" execution failed

Ending action Action.

Ending iteration 1.

Ending Vuser...

Starting action vuser_end.

Ending action vuser_end.

Vuser Terminated.

 

Loadrunner Replay log: 

Virtual User Script started at : 2014-05-12 16:24:41

Starting action vuser_init.

Ending action vuser_init.

Running Vuser...

Starting iteration 1.

Starting action Action.

Action.c(7): SOAP request "SOAP Request" started

Action.c(7): Warning: HTTP status code 500 returned by the server

Action.c(7): Error: The reason for the SOAP fault is:"Error parsing document.. Nested exception is com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 start byte 0xbb (at char #1601, byte #1120)"

Action.c(7): Error: SOAP request "SOAP Request" execution failed

Ending action Action.

Ending iteration 1.

Ending Vuser...

Starting action vuser_end.

Ending action vuser_end.

Vuser Terminated.

 

 

解决:

Tip: To better understand the cause of failed steps, you can record movie clips of run sessions and view them together with the step result details.

在loadrunner测试脚本里加入如下定义描述即可。

   web_add_header("Content-Type","application/xml");

 

问题2: 

Loadrunner Scenario run-time setting 。

loadrunner 场景设置注意事项,当模拟多用户压测时,压测突然停止。

解决:

https://i-blog.csdnimg.cn/blog_migrate/f8c05842d379eb5ac97d75d9a96b9f49.png

D:\TestCase\20140428_OA_workflow_db2_update\tc_workflow_start22

 

问题3: 

Loadrunner Parameter loadrunner参数化设置问题,当取值唯一性unique number的参数设置注意事项

解决:

https://i-blog.csdnimg.cn/blog_migrate/b0b046bc027204adc21f97e9a02a5261.png

D:\TestCase\20140428_OA_workflow_db2_update\tc_workflow_start22

 

问题4

https://i-blog.csdnimg.cn/blog_migrate/bea26f3108e28e4620d931808ed9e845.png

Virtual User Script started at : 2014-05-13 14:54:30

Starting action vuser_init.

Web Services replay version 11.0.0 for WIN2003; Toolkit: "NotDefined"; build 8859

Run-Time Settings file: "D:\TestCase\20140428_OA_workflow_db2_update\tc_workflow_getAvailablePaths\\default.cfg"

Vuser directory: "D:\TestCase\20140428_OA_workflow_db2_update\tc_workflow_getAvailablePaths"

Vuser output directory: "D:\TestCase\20140428_OA_workflow_db2_update\tc_workflow_getAvailablePaths\"

LOCAL start date/time:  2014-05-13 14:54:30

Ending action vuser_init.

Running Vuser...

Starting iteration 1.

Starting action Action.

Action.c(10): Registering web_reg_find was successful  [MsgId: MMSG-26390]

Action.c(16): Notify: Transaction "getAvailablePaths" started.

Action.c(17): SOAP request "SOAP Request" started

Action.c(17): t=417ms: 150-byte response headers for "http://10.19.218.179/snf-workflow-web/webservice/EngineService?wsdl" (RelFrameId=1, Internal ID=1)

Action.c(17):     HTTP/1.1 400 Bad Request\r\n

Action.c(17):     Date: Tue, 13 May 2014 06:54:04 GMT\r\n

Action.c(17):     Content-Length: 226\r\n

Action.c(17):     Connection: close\r\n

Action.c(17):     Content-Type: text/html; charset=iso-8859-1\r\n

Action.c(17):     \r\n

Action.c(17): t=431ms: 226-byte response body for "http://10.19.218.179/snf-workflow-web/webservice/EngineService?wsdl" (RelFrameId=1, Internal ID=1)

Action.c(17):     <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n

Action.c(17):     <html><head>\n

Action.c(17):     <title>400 Bad Request</title>\n

Action.c(17):     </head><body>\n

Action.c(17):     <h1>Bad Request</h1>\n

Action.c(17):     <p>Your browser sent a request that this server could not understand.<br />\n

Action.c(17):     </p>\n

Action.c(17):     </body></html>\n

Action.c(17): Error: HTTP status code 400 returned by the server

Action.c(17): Error: SOAP request "SOAP Request" execution failed

Action.c(17): Notify: Transaction "getAvailablePaths" ended with "Fail" status (Duration: 0.1939 Wasted Time: 0.1633).

Ending action Action.

Ending iteration 1.

Ending Vuser...

Starting action vuser_end.

Ending action vuser_end.

Vuser Terminated.

解决:

   //web_add_header("Content-Type","application/xml");

//web_add_header("EncType=text/xml","charset=UTF-8");

 

//"EncType=text/xml; charset=GB2312",

 

web_reg_find("Fail=NotFound",

"Search=All",

"SaveCount=placeflag",

"Text/IC=COMPLETE",

LAST);

 

   lr_start_transaction("getAvailablePaths");

soap_request("StepName=SOAP Request",

"URL=http://10.19.218.179/snf-workflow-web/webservice/EngineService?wsdl",

"SOAPEnvelope="

        //"<?xml version=\"1.0\" encoding=\"GB2312\" ?>"   //这里加上XML编码即可把中文乱码数据传递失败解决

、、、

 

 

 

初步调试:WAS 版本 7.0.0.13

单压测WAS1 机器,loadrunner性能平稳,TPS 300笔/秒 ,响应时间 0.057秒

单压测WAS2 机器,拷贝WAS1应用代码包到WAS2,loadrunner性能异常,TPS 100笔/秒(一直下降) ,响应时间 0.057秒(一直上升),停止压测后,应用实例java进程一直占用内存不释放。

查找异常:

应用实例wf_srv2 SystemOut.log

[loguser@wfpreapp2~]$ tail -f/opt/IBM/WebSphere/AppServer/profiles/check/logs/wf_srv2/SystemOut.logSystemOut.log 无异常打印,

[loguser@wfpreapp2 ~]$ more wf_srv2_exception.log

 

 

 Index  Count  Time of first Occurrence    Time of last Occurrence     Exception SourceId ProbeId

------+------+---------------------------+---------------------------+---------------------------

     0      3     5/8/14 18:07:14:505 CST     5/8/14 18:07:15:404 CST com.ibm.websphere.management.exception.ConnectorException com.ibm.ws.man

agement.RoutingTable.Accessor.getConnector 583 /opt/IBM/WebSphere/AppServer/profiles/check/logs/ffdc/wf_srv2_4d984d98_14.05.08_18.07.14.521561

1502752903065554.txt

     1      3     5/8/14 18:07:14:609 CST     5/8/14 18:07:15:404 CST com.ibm.websphere.management.exception.ConnectorNotAvailableException co

m.ibm.ws.management.RoutingTable.Accessor.getConnector 610 /opt/IBM/WebSphere/AppServer/profiles/check/logs/ffdc/wf_srv2_4d984d98_14.05.08_18.

07.14.6097402533075760915140.txt

     2      1     5/8/14 18:09:03:024 CST     5/8/14 18:09:03:024 CST com.ibm.db2.jcc.am.SqlIntegrityConstraintViolationException com.ibm.ws.r

sadapter.jdbc.WSJccPreparedStatement.pmiExecuteUpdate 807 /opt/IBM/WebSphere/AppServer/profiles/check/logs/ffdc/wf_srv2_5b205b2_14.05.08_18.09

.03.0248465002192407646866.txt

     3      1     5/8/14 18:09:03:098 CST     5/8/14 18:09:03:098 CST com.ibm.db2.jcc.am.SqlIntegrityConstraintViolationException com.ibm.ws.r

sadapter.jdbc.WSJdbcPreparedStatement.executeUpdate 449 /opt/IBM/WebSphere/AppServer/profiles/check/logs/ffdc/wf_srv2_5b205b2_14.05.08_18.09.0

3.0981446527591284546629.txt

     4      1     5/9/14 14:46:28:738 CST     5/9/14 14:46:28:738 CST org.apache.soap.SOAPException com.ibm.ws.management.connector.soap.SOAPC

onnectorClient.invokeTemplate 846 /opt/IBM/WebSphere/AppServer/profiles/check/logs/ffdc/wf_srv2_2fae2fae_14.05.09_14.46.28.7386444650700322299

867.txt

------+------+---------------------------+---------------------------+---------------------------

[loguser@wfpreapp2 ffdc]$ pwd

/opt/IBM/WebSphere/AppServer/profiles/check/logs/ffdc

 

ddddd 

https://i-blog.csdnimg.cn/blog_migrate/9d495c794671ddcb1a18af55d7d61867.png

https://i-blog.csdnimg.cn/blog_migrate/9e7b940d260e2dff77be87f43881bf9f.png

  

异常解决:

最终是因为WAS 集群应用中 两台WAS 连接数据库的驱动jar 不一致导致性能异常,导入最新驱动包解决 

 

问题5:

Loadrunner WebService Script:

D:\TestCase\20140428_OA_workflow_db2_update\tc_workflow_endTask_soap_request\Action.c

 

C代码 
  1. Action()  
  2. {  
  3.     lr_start_transaction("审批流程");  
  4.   
  5.     web_add_header("Content-Type","application/xml");  
  6.   
  7.  // web_add_header("Content-Type","application/xml;charset=utf-8");  
  8.   
  9.     web_reg_find("Fail=NotFound",  
  10.         "Search=All",  
  11.         "SaveCount=placeflag",  
  12.         "Text=COMPLETE",  
  13.         LAST);  
  14.   
  15.     soap_request("StepName=SOAP Request",                                         
  16.         //"URL=http://esbpre.cns*****.com:9106/SuN***ServiceWeb/mb",   // 如经如经ESB PRE压测则改成这个                                      
  17.         "URL=http://10.19.218.179/snf-workflow-web/webservice/EngineService",                                         
  18.         "SOAPEnvelope="  
  19.         "<?xml version=\"1.0\" encoding=\"GB2312\"?>"  
  20.         "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"  
  21.             "<soap:Body>"  
  22. 、、、、、、  
  23.             "</soap:Body>"  
  24.         "</soap:Envelope>",                                         
  25.         "SOAPAction=endTask",                                         
  26.         "ResponseParam=response",                                         
  27.         "Snapshot=t1398759266.inf",                                       
  28.         LAST);  
  29.   
  30.     lr_output_message("output message:%s",lr_eval_string("{placeflag}"));  
  31.   
  32.      if((atoi(lr_eval_string("{placeflag}"))<1))  
  33.      {    
  34.      lr_end_transaction("审批流程",LR_PASS);            
  35.      }    
  36.      else    
  37.      {  
  38.      lr_end_transaction("审批流程",LR_FAIL);    
  39.      }  
  40.   
  41.     return 0;  
  42. }   

 

Loadrunner Replay log:

、、、

Action.c(98): Warning: The string 'placeflag' with parameter delimiters is not a parameter.

、、、

原因:

Loadrunner webservice协议的测试脚本soap_request() 方法不支持loadrunner http协议的web_reg_find检查点函数

解决一

所以改成web service 脚本soap_request方法的检查点函数

D:\TestCase\20140428_OA_workflow_db2_update\tc_workflow_endTask_soap_request\Action.c

 

C代码 
  1. Action()  
  2. {  
  3.     lr_start_transaction("审批流程");  
  4.   
  5.     web_add_header("Content-Type","application/xml");  
  6.   
  7.  // web_add_header("Content-Type","application/xml;charset=utf-8");  
  8.   
  9. /*     http 协议的检查点函数不适用web service 检查点 
  10.     web_reg_find("Fail=NotFound", 
  11.         "Search=All", 
  12.         "SaveCount=placeflag", 
  13.         "Text=FAIL", 
  14.         LAST); 
  15. */  
  16.     soap_request("StepName=SOAP Request",                                         
  17.         //"URL=http://esbpre.cns*****.com:9106/SuN***ServiceWeb/mb",   // 如经如经ESB PRE压测则改成这个                                      
  18.         "URL=http://10.19.218.179/snf-workflow-web/webservice/EngineService",                                         
  19.         "SOAPEnvelope="  
  20.         "<?xml version=\"1.0\" encoding=\"GB2312\"?>"  
  21.         "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"  
  22.             "<soap:Body>"  
  23. 、、、、、、  
  24.             "</soap:Body>"  
  25.         "</soap:Envelope>",                                         
  26.         "SOAPAction=endTask",                                         
  27. //此处表示保留web service 的response返回数据,不能缺失  
  28.         "ResponseParam=response",                                         
  29.         "Snapshot=t1398759266.inf",                                       
  30.         LAST);  
  31.   
  32. //   lr_output_message("output message:%s",lr_eval_string("{response}"));  
  33. //   if((atoi(lr_eval_string("{placeflag}"))>0))  
  34. //   if(strstr(lr_eval_string("{response}"),"FAIL")>0)  
  35.   
  36. // 改成web service 的检查点函数方法  
  37.      if(strstr(lr_eval_string("{response}"),"COMPLETE")>0)  
  38.      {    
  39.      lr_end_transaction("审批流程",LR_PASS);            
  40.      }    
  41.      else    
  42.      {  
  43.      lr_end_transaction("审批流程",LR_FAIL);    
  44.      }  
  45.   
  46.      return 0;  
  47. }  

 解决二:

直接将loadrunner webservice协议的soap_request()方法改成loadrunner http协议的web_custom_resquest()方法,再使用 web_reg_find()函数的检查点,即可。

D:\TestCase\20140428_OA_workflow_db2_update\tc_workflow_endTask_web_custom_request\Action.c

C代码 
  1. Action()  
  2. {  
  3.     lr_start_transaction("审批流程");  
  4.   
  5.     //web_add_header("Content-Type","application/xml");  
  6.   
  7.  // web_add_header("Content-Type","application/xml;charset=utf-8");  
  8.   
  9.     web_reg_find("Fail=NotFound",  
  10.         "Search=All",  
  11.         "SaveCount=placeflag",  
  12.         "Text=COMPLETE",  
  13.         LAST);  
  14. //转换成 http协议  
  15.     web_custom_request("Test",  
  16.                       "Method=POST",   
  17.         "URL=http://10.19.218.179/snf-workflow-web/webservice/EngineService",                                         
  18.         "EncType=text/xml;charset=GB2312",    //增加编码方式  
  19.         "Body="  
  20.         "<?xml version=\"1.0\" encoding=\"GB2312\"?>"  
  21.         "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"  
  22.             "<soap:Body>"  
  23. 、、、、、、  
  24.             "</soap:Body>"  
  25.         "</soap:Envelope>",             
  26. // 去掉web service XML的response返回数据  
  27.         LAST);  
  28.   
  29.     lr_output_message("output message:%s",lr_eval_string("{placeflag}"));  
  30.   
  31.      if((atoi(lr_eval_string("{placeflag}"))>0))  
  32.      {    
  33.      lr_end_transaction("审批流程",LR_PASS);            
  34.      }    
  35.      else    
  36.     {  
  37.      lr_end_transaction("审批流程",LR_FAIL);    
  38.      }  
  39.     return 0;  
  40. }  
  41.       

 

 

 

loadrunner测试mq的长连接

loadrunner java测试类中mq的初始化方法放在 init 方法里,循环放在action里即可

如:车辆GPS场景,长连接发数据且24小时发送地理位置GIS信息

 

Loadrunner Run-time Settings 里设置短连接 / 每次新用户,短连接

https://i-blog.csdnimg.cn/blog_migrate/74d717cae6f44dc5c194b9d0af05974e.png

 

 

 

 

 

用Loadrunner录制和测试WebSphere MQ

http://bbs.51testing.com/thread-138553-1-1.html

首先安装 MQ License
然后安装9.1中的附件
安装MQTEST
安装成功后可以在录制 协议 中看见
支持的语言Application being recorded must be written in C/C++ or Visual Basic.
缺点不支持JAVA

 

 

使用LoadRunner遇到无法维持长连接的问题

http://bbs.51testing.com/thread-48408-1-1.html

 

使用的是LoadRunner 8.0+web service pack.
我在RunTime Setting 中的preferences中已经设定了Keep-alive HTTP connection为Yes.
使用Wsdl方式录制 web service (soap)脚本 后,在Action中指定了发送请求的操作。
实际运行 指定循环1000次,用ethereal抓包发现,每次的http连接都被断掉。
检查 抓到的包体:
在Post请求的头域中, 给出
请求消息为SendSMS HTTP1.1
连接头域为Connection: Keep-Alive

在服务 器的回应中,没有给出connection头域,
使用的编码方式为Transfer-Encoding: chunked.

但是在LR收到该请求后,它发出了FIN-ACK包拆除了已有的连接。
重新建立一个新的连接再次发送请求。
但是我希望它以长连接的方式在已经建立的端口发送,从而提高效率。

 

 

你是否在runtime setting中选上了"simulate a new user each iteration"

这样的话,每次迭代,会断开重连.去掉此选项.
用ethereal抓包分析.表扬一下!

 

 

在脚本中手动写入循环,总算实现了所谓的长连接。
然后在设定中选取每REQUEST单位统计。

 

二楼说的设置是在HTML协议录制时才有的,用WEB SERVICE是没这个东西的,与你说的没有关系。
我以前没注意过这方面的问题。但我建议你先看一下软件在实际使用中是否也是要断开的,如果也需要断开,那我建议你不要改脚本,让脚本反映真实情况是最好的做法。
如果确实需要想办法解决这个问题,就需要检查脚本执行过程中什么时候断开连接,我估计有几个可能:
1。循环1次断1次连接,那肯定是header的问题,它修改了头文件导致需要重新连接,语句肯定是一开始的web_add_auto_header,修 改脚本中的相关内容,或者(也许是并且,没把握)调整录制属性中的header,content,修改脚本的方式是将这些内容放在脚本初始化部分;
2。每调用SOAP1次就断1次,那估计有可能是header问题,也可能是soap_request代码的问题。检查方法是试着把 web_add_header内容合并到web_add_auto_header里去。如果是soap_request导致必须先断开才能再调用,那我估 计这个问题没法解决。

 

确实的,在LR8.0版本中,关于webservice的已经命名为“web service”协议了,在runtimesetting中没有browser选项了
但是在7.51版本之前的webservice测试,使用的协议名称为“SOAP”,runtimesetting中有browser emulation选项的。特此更正。

 

晕,在帮助中都查到了相应的条文,目前暂时还没有发现对应的设定sdlkfj1

 

我直接在脚本中写入循环,就用简单的for循环。
在Run-time Setting ->Miscellaneous->Automatic Transactions中define each step as a transaction.

 

 

to jackloo
在http1.1中实现了所谓的长连接,根据我的测试,在使用长连接的情况下,最大北向吞吐量(tomcat+axis)是700左右, (tomcat+xfire)是1600左右。如果使用短连接,最大北向吞吐量(tomcat+axis)是450左右, (tomcat+xfire)是1200左右。同时,CPU的占用率降低了20%左右。(4*3G CPU, 2G MEM, JRE1.4.2)
可见,长连接在降低系统开销方面还是有优势的。

基于此,所以我们希望使用长连接来进行测试。
在脚本中写入循环后,runtime setting中的iteration次数可以写成1,循环次数在脚本中给定。

LoadRunner的确功能强大,不过很多地方还是需要动手去调整阿~~

 

 

 

[求助] 使用LoadRunner遇到无法维持长连接的问题,谢谢大牛了!!!

使用的是LoadRunner 8.0+web service pack.
我在RunTime Setting 中的preferences中已经设定了Keep-alive HTTP connection为Yes.
使用Wsdl方式录制 web service (soap)脚本 后,在Action中指定了发送请求的操作。
实际运行 指定循环1000次,用ethereal抓包发现,每次的http连接都被断掉。
检查 抓到的包体:
在Post请求的头域中, 给出
请求消息为SendSMS HTTP1.1
连接头域为Connection: Keep-Alive

在服务 器的回应中,没有给出connection头域,
使用的编码方式为Transfer-Encoding: chunked.

但是在LR收到该请求后,它发出了FIN-ACK包拆除了已有的连接。
重新建立一个新的连接再次发送请求。
但是我希望它以长连接的方式在已经建立的端口发送,从而提高效率。

项目 紧急,请大大们不吝赐教,十分感谢!!!!
收藏 分享
 

 

  

Rank: 3Rank: 3

2 #
 
发表于 2006-11-11 18:47 |  只看该作者

你是否在runtime setting中选上了"simulate a new user each iteration"

这样的话,每次迭代,会断开重连.去掉此选项.

用ethereal抓包分析.表扬一下!
 

TOP

  

Rank: 3Rank: 3

3 #
 
发表于 2006-11-12 13:38 |  只看该作者
多谢楼上的指点,不过我翻遍了Controller和User Generator中关于runtime setting的所有设置,并没有发现你所说的选项啊,请解释详细一点,谢谢!!
我用的是LR8.0+web service pack 1
 
 

TOP

  

Rank: 3Rank: 3

4 #
 
发表于 2006-11-12 13:45 |  只看该作者
晕,在帮助中都查到了相应的条文,目前暂时还没有发现对应的设定sdlkfj1
 

TOP

  

Rank: 3Rank: 3

5 #
 
发表于 2006-11-12 18:15 |  只看该作者
呵呵,最后没有办法,在脚本中手动写入循环,总算实现了所谓的长连接。
然后在设定中选取每REQUEST单位统计。
 

TOP

  
Zee

Zee

Rank: 7Rank: 7Rank: 7

为人民服务好版主勋章

6 #
 
发表于 2006-11-13 00:32 |  只看该作者
你脚本怎么写的。二楼说的在:runtime setting->browser emulation里。
200 字节以内
不支持自定义 Discuz! 代码
 

TOP

  

Rank: 4

7 #
 
发表于 2006-11-13 10:31 |  只看该作者
二楼说的设置是在HTML协议录制时才有的,用WEB SERVICE是没这个东西的,与你说的没有关系。
我以前没注意过这方面的问题。但我建议你先看一下软件在实际使用中是否也是要断开的,如果也需要断开,那我建议你不要改脚本,让脚本反映真实情况是最好的做法。
如果确实需要想办法解决这个问题,就需要检查脚本执行过程中什么时候断开连接,我估计有几个可能:
1。循环1次断1次连接,那肯定是header的问题,它修改了头文件导致需要重新连接,语句肯定是一开始的web_add_auto_header,修 改脚本中的相关内容,或者(也许是并且,没把握)调整录制属性中的header,content,修改脚本的方式是将这些内容放在脚本初始化部分;
2。每调用SOAP1次就断1次,那估计有可能是header问题,也可能是soap_request代码的问题。检查方法是试着把 web_add_header内容合并到web_add_auto_header里去。如果是soap_request导致必须先断开才能再调用,那我估 计这个问题没法解决。
 
 

TOP

  

Rank: 4

8 #
 
发表于 2006-11-13 10:38 |  只看该作者
二楼说的设置是在HTML协议录制时才有的,用WEB SERVICE是没这个东西的,与你说的没有关系。
我以前没注意过这方面的问题。但我建议你先看一下软件在实际使用中是否也是要断开的,如果也需要断开,那我建议你不要改脚本,让脚本反映真实情况是最好的做法。
如果确实需要想办法解决这个问题,就需要检查脚本执行过程中什么时候断开连接,我估计有几个可能:
1。循环1次断1次连接,那肯定是header的问题,它修改了头文件导致需要重新连接,语句肯定是一开始的web_add_auto_header,修 改脚本中的相关内容,或者(也许是并且,没把握)调整录制属性中的header,content,修改脚本的方式是将这些内容放在脚本初始化部分;
2。每调用SOAP1次就断1次,那估计有可能是header问题,也可能是soap_request代码的问题。检查方法是试着把 web_add_header内容合并到web_add_auto_header里去。如果是soap_request导致必须先断开才能再调用,那我估 计这个问题没法解决。
 

TOP

  

Rank: 3Rank: 3

9 #
 
发表于 2006-11-14 09:37 |  只看该作者

呵呵!

原帖由  jackloo 于 2006-11-13 10:38 发表
二楼说的设置是在HTML协议录制时才有的,用WEB SERVICE是没这个东西的,与你说的没有关系。

确实的,在LR8.0版本中,关于webservice的已经命名为“web service”协议了,在runtimesetting中没有browser选项了
但是在7.51版本之前的webservice测试,使用的协议名称为“SOAP”,runtimesetting中有browser emulation选项的。特此更正。
 

TOP

  

Rank: 3Rank: 3

11 #
 
发表于 2006-12-18 21:31 |  只看该作者
我直接在脚本中写入循环,就用简单的for循环。
在Run-time Setting ->Miscellaneous->Automatic Transactions中define each step as a transaction.
 

TOP

  

Rank: 3Rank: 3

12 #
 
发表于 2006-12-18 21:39 |  只看该作者
to jackloo
在http1.1中实现了所谓的长连接,根据我的测试,在使用长连接的情况下,最大北向吞吐量(tomcat+axis)是700左右, (tomcat+xfire)是1600左右。如果使用短连接,最大北向吞吐量(tomcat+axis)是450左右, (tomcat+xfire)是1200左右。同时,CPU的占用率降低了20%左右。(4*3G CPU, 2G MEM, JRE1.4.2)
可见,长连接在降低系统开销方面还是有优势的。

基于此,所以我们希望使用长连接来进行测试。
在脚本中写入循环后,runtime setting中的iteration次数可以写成1,循环次数在脚本中给定。

LoadRunner的确功能强大,不过很多地方还是需要动手去调整阿~~

 

loadrunner 学习笔记--Web Services

http://www.byywee.com/page/M0/S227/227297.html

使用loadrunner测试Web Services的程序

http://blog.sina.com.cn/s/blog_7833c84501010e9d.html

首页>> 文章精选>> 测试丛书>> 性能测试进阶指南——LoadRunner 11实战>> 查看资讯

性能测试进阶指南—LoadRunner 11实战(20) 发布时间: 2012-6-11 10:42 作者: 陈霁

http://www.51testing.com/html/42/n-815142.html

Loadrunner上传文件解决办法(大文件)

http://www.chinatesting.cn/212/12929212.shtml

 

loadrunner 与 xml / loadrunner 与报文 / loadrunner 与Json格式

C代码   收藏代码
  1. Action()  
  2. {  
  3.    web_reg_find("Fail=NotFound",  
  4.    "Search=Body",  
  5.    "SaveCount=Flag",  
  6.    "Text=<flag>0</flag>",  
  7.    LAST);  
  8.   
  9.    lr_start_transaction("koujianziyuan");  
  10.   
  11.    web_custom_request("name",  
  12.    "URL=http://prescp.cns*****.com/scp-web/excuteSale.htm",  
  13.    "Method=POST",  
  14.    "Resource=1",  
  15.    "Mode=HTTP",  
  16.    "Referer=",  
  17.    "Body=<?xml version=\"1.0\" encoding=\"utf-8\"?>"  
  18. "<MbfService>"  
  19. "  <input1>"  
  20. "    <MbfHeader>"  
  21. "      <ServiceCode>excuteSale</ServiceCode>"  
  22. "      <Operation>1</Operation>"  
  23. "      <AppCode></AppCode>"  
  24. "      <UId>20bdfcb2089495aa04bed69d76cfdac69268f8dd5f64252</UId>"  
  25. "        <AuthId>POS;O0guYW8sNHON</AuthId>"  
  26. "    </MbfHeader>"  
  27. "   <MbfBody>"  
  28.   "<sourceSystem>POS</sourceSystem>"  
  29.   "<sourceList>"  
  30.    " <operateType>1</operateType>"  
  31.     "<subComId>1001</subComId>"  
  32.     "<store>*</store>"  
  33.    " <bu>00002</bu>"  
  34.     "<invLocat>*</invLocat>"  
  35.    " <channel>10</channel>"  
  36.    " <resType>0001</resType>"  
  37.     "<quato>10</quato>"  
  38.     "<serialNumber>CZC020206817610</serialNumber>"  
  39.   "</sourceList>"  
  40. "   </MbfBody>"  
  41. "  </input1>"  
  42. "</MbfService>",  
  43.    LAST);  
  44.     lr_end_transaction("koujianziyuan", LR_AUTO);  
  45.   
  46.    return 0;  
  47.   
  48. }  

 

范例二 loadrunner 与 xml / loadrunner 与报文 / loadrunner 与Json格式

 Action()

C代码   收藏代码
  1. {  
  2.     web_reg_find("Fail=NotFound",  
  3.     "Search=Body",  
  4.     "SaveCount=Flag",  
  5.     "Text=<flag>0</flag>",  
  6.     LAST);  
  7.   
  8.    web_add_header("Content-Type","application/json;charset=utf-8");  
  9.    web_custom_request("modifyStatus",   "URL=http://possit.cns*****.com/nsf-sale-web/useCoupon/syncNonStdOrderCfmUse.do",  
  10.    "Method=POST",  
  11.    "Resource=0",  
  12.    "RecContentType=application/json",  
  13.    "Mode=HTTP",  
  14.    "EncType=application/json",  
  15.    "Referer=",  
  16.    "Body={"  
  17. "    \"MbfService\": {"  
  18. "        \"input1\": {"  
  19. "            \"MbfHeader\": {"  
  20. "                \"ServiceCode\": \"useCoupon\","  
  21. "                \"AppCode\": \"POS\","  
  22. "                \"Operation\": \"syncNonStdOrderCfmUse\","  
  23. "                \"AuthId\": \"\","  
  24. "                \"UId\": \"\""  
  25. "            },"  
  26. "            \"MbfBody\": {"  
  27. "                \"caller\": \"2\","  
  28. "                \"memberId\": \"6001769384\","  
  29. "                \"sourceSystemNo\": \"W011046957610\","  
  30. "                \"operateType\": \"1\","  
  31. "                \"channelId\": \"37\","  
  32. "                \"enddeviceId\": \"\","  
  33. "                \"cityId\": \"1000173\","  
  34. "                \"entityStoreId\": \"7610\","  
  35. "                \"productInfoType\": \"2\","  
  36. "                \"productList\": {"  
  37. "                    \"productInfo\": ["  
  38. "                        {"  
  39. "                            \"sourceSystemItemId\": \"W011046957610\","  
  40. "                            \"commdtyCode\": \"00000000010824614X\","  
  41. "                            \"productGrpId\": \"\","  
  42. "                            \"productListPrice\": \"1000.00\","  
  43. "                            \"storeId\": \"\","  
  44. "                            \"productQty\": \"1\""  
  45. "                        }"  
  46. "                    ]"  
  47. "                },"  
  48. "                \"couponUsedList\": {"  
  49. "                    \"couponUsedInfo\": ["  
  50. "                        {"  
  51. "                            \"couponNumber\": \"40000000081628\","  
  52. "                            \"changeHeterotypeId\": \"\""  
  53. "                        }"  
  54. "                    ]"  
  55. "                }"  
  56. "            }"  
  57. "        }"  
  58. "    }"  
  59. "",  
  60.    LAST);  
  61.    return 0;  
  62. }  

 

loadrunner json

D:\TestCase\20160308_openTSDB

请求URL如下

http://10.27.113.44:4242/api/put

POST json文件格式如下

{"metric":"mysql.cpu","tags":{"host":"web9"},"timestamp":1307591390000,"value":"1"} 

以上这样的json参数直接放body发送过来

 

编写loadrunner 脚本如下:

 

 

loadrunner xml

 

 

 

end




  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值