Pergunta

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.

Foi útil?

Solução 2

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.

Outras dicas

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!!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top