Thrift API load test

◇◆丶佛笑我妖孽 提交于 2019-11-29 13:06:25

You can use JSR223 Sampler + Groovy (add groovy-all.jar in jmeter/lib) and look at this client example, see NonblockingClient code for an example:

Make your groovy code call a least the following at end:

SampleResult.setSuccessful(true/false)
SampleResult.setResponseCode("code")
SampleResult.setResponseMessage("message")

See:

And of course, ensure you add the required dependencies in jmeter/lib.

JMeter isn't especially for it but it's flexible enough to support your use case.

There is an extensibility mechanism which uses BeanShell. JMeter provides BeanShell Sampler which is capable of invoking Java code, including using external jars.

Simple usage:

  1. Start with empty JMeter project
  2. Create a Thread Group with all defaults (you can play with number of threads, ramp-up, etc)
  3. Add a BeanShell Sampler with following code:

    Thread.sleep(2000L);
    
  4. Add View Results Tree listener

  5. Save and run

You should see a green triangle (or triangles) basing on your number of threads and loops) with output like following:

 Thread Name: Thread Group 1-1
 Sample Start: 2013-11-02 14:48:11 GMT+03:00
 Load time: 5030
 Latency: 0
 Size in bytes: 0
 Headers size in bytes: 0
 Body size in bytes: 0
 Sample Count: 1
 Error Count: 0
 Response code: 200
 Response message: OK

If you use any of techniques to analyze results, i.e.

  • JMeter embedded listeners like Aggregate Report, Summary Report, Graph Resuls, etc.
  • Storing results to CSV file and opening them with Excel or equivalent (see jmeter.properties file under /bin directory of your JMeter installation. Properties prefix is "jmeter.save.saveservice."
  • JMeter Ant Task (see Test.jmx and build.xml in /extras folder under your JMeter installation)
  • JMeter Results Analysis Plugin

You'll see your request(s) success rate, min/max/average times (something like 2 seconds I guess) and some more information (depending on your configuration).

Particular your use case assumes

  1. IMPORTANT Placing thrift (or whatever) jars under lib/ext folder (or you won't be able to access your APIs
  2. importing classes you need to test somewhere in BeanShell Sampler

    import yourpackage.YourClass;

  3. Invoking methods you want to test from BeanShell Sampler

  4. (optional) do some assertions on responses. i.e.

    if (yourresponse != yourexpectedresponse){
    IsSuccess=false;
    ResponseMessage= "Test Failed";
    }
    

Hope this helps

I have writtena CustomThriftSampler for JMeter to load test HBase through thrift service. You can get the details about it at my blog - http://1-st.blogspot.in/2013/12/load-testing-thrift-services-custom.html . Couldn't create a generalized code. Anyway its simple and starightforward java code. Anyone could try it. If time permit I shall write a generalised code and commit to github!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!