To write a performance test script for the Dubbo interface using LoadRunner

Source: Internet
Author: User
Tags throwable
Powerful is not loadrunner, but spring and dubbo. Recently, I changed jobs and changed jobs. The new company uses dubbo and a set of middleware based on dubbo's own packaging, so the performance test needs to write scripts for dubbo class interfaces. There is already a Dubbo article on loadrunner on the Internet, which initializes the connection and call to the dubbo provider programmatically, but because the company's own package of middleware does not provide programmatic access, it can only be read by reading the XML configuration file. Way to initialize, so a simple modification to the script. Copy the spring framework and dubbo related jar packages to the loadrunner script folder, add the current directory to the classpath, and also copy the applicationContext.xml to the script folder, which defines the provider information of dubbo. The content of the loadrunner script is as follows:
/ *
  * LoadRunner Java script. (Build: _build_number_)
  *
  * Script. Description:
  *
  * /

     import org.springframework.context.support.ClassPathXmlApplicationContext;

     import com.alibaba.dubbo.demo.DemoService; // Import your defined interface here

     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
} 



The above script is a very simple example, using the JMeter wrapper Java request can also implement the invocation of the Dubbo class interface, followed by an empty supplement.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.