使用loadrunner编写dubbo接口的性能测试脚本
2016-08-13 16:00
726 查看
强大的不是loadrunner,而是spring和dubbo。
近期跳槽换了份工作,新公司里使用dubbo和基于dubbo自己封装的一套中间件,于是性能测试就需要编写对dubbo类接口的脚本。
网上已经有一篇loadrunner压dubbo的文章,里面是通过编程的方式初始化与dubbo provider的连接和调用,但由于公司自己封装的那套中间件不提供编程方式访问,只能通过读取xml配置文件的方式来初始化,因此对脚本做了简单的修改。
将spring框架和dubbo相关的jar包拷贝到loadrunner脚本文件夹下,classpath里增加当前目录,applicationContext.xml也拷贝到脚本文件夹下,里面定义好dubbo的provider信息,loadrunner脚本内容如下:
以上脚本是个很简单的示例,使用jmeter封装java request同样可以实现dubbo类接口的调用,后续有空再补充。
近期跳槽换了份工作,新公司里使用dubbo和基于dubbo自己封装的一套中间件,于是性能测试就需要编写对dubbo类接口的脚本。
网上已经有一篇loadrunner压dubbo的文章,里面是通过编程的方式初始化与dubbo provider的连接和调用,但由于公司自己封装的那套中间件不提供编程方式访问,只能通过读取xml配置文件的方式来初始化,因此对脚本做了简单的修改。
将spring框架和dubbo相关的jar包拷贝到loadrunner脚本文件夹下,classpath里增加当前目录,applicationContext.xml也拷贝到脚本文件夹下,里面定义好dubbo的provider信息,loadrunner脚本内容如下:
/* * LoadRunner Java script. (Build: _build_number_) * * Script. Description: * */ import org.springframework.context.support.ClassPathXmlApplicationContext; import com.alibaba.dubbo.demo.DemoService;//这里导入你定义的接口 import lrapi.lr; public class Actions { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml"); DemoService demoService; public int init() throws Throwable { demoService = (DemoService) context.getBean("demoService"); return 0; }//end of init public int action() throws Throwable { lr.start_transaction("dubbo"); String hello = demoService.sayHello("dio"); System.out.println(hello); lr.end_transaction("dubbo",lr.PASS); return 0; }//end of action public int end() throws Throwable { return 0; }//end of end }
以上脚本是个很简单的示例,使用jmeter封装java request同样可以实现dubbo类接口的调用,后续有空再补充。
相关文章推荐
- Loadrunner Webservice接口性能测试脚本编写优化总结
- loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写
- 使用Eclipse编写LoadRunner测试脚本
- 利用LoadRunner编写socket性能测试脚本
- [LoadRunner]性能测试实践_Hessian协议脚本编写2
- loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写
- loadrunner使用java协议制作服务器接口测试脚本
- loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写
- loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写
- loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写
- Loadrunner编写socket性能测试脚本简述
- 使用Eclipse编写LoadRunner测试脚本
- Loadrunner录制使用ajax性能测试脚本方法
- 【loadrunner使用篇】LR调用QTP脚本来实现性能测试(一次现场特殊需求的解决方案)
- loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写
- 利用LoadRunner编写socket性能测试脚本
- 使用LoadRunner 编写JAVA 测试脚本
- loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写
- loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写
- loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写