Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

jmeter - Thrift API load test

I am new into Apache Jmeter. Basically I want to load test our couple of thrift APIs but have no clue where to start with. It is in java where api takes 2 parameter and then send java object as response.

Any pointer would be very helpful.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...