Thrift API load test

后端 未结 3 1069
梦毁少年i
梦毁少年i 2020-12-20 11:03

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

3条回答
  •  被撕碎了的回忆
    2020-12-20 11:26

    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

提交回复
热议问题