2013-05-09

Introduction to JMeter Google PlugIn- Post Processors

In this article we are going to see what are additional features/items added after installing jmeter plugin (Google Plugin) and what we can do with it. I will discuses about Post Processors only. To know about basic of jmeter see my this page. And, the process to install plug in , see this post.

After adding google plug in we get 4 types of Post Processors. Basically a post processor will perform processing from response data to retrieve meaningful information. It also help in making further decision and communication with results.

1. jp@gc - Inter-Thread Communication PostProcessor.
-Right click a Test Plan or thread > Post Processors> jp@gc - Inter-Thread Communication PostProcessor.

-By name we understand it's purpose. It actually provides a global string queues(FIFO) for communication. We put string in to it and er get that from different thread group.
-It allows separate thread group to be synchronized on getting same value.
-It allows separate thread group to pass variable.
-Normally, we use this with its brother jp@gc - Inter-Thread Communication PreProcessor.Where , pre processor get the values from previous thread's post processor. Both are following FIFO.
-It clears queue before and after test
-It is better to uses changeable name as queue names. If there we have not use post processor, previous data may not be cleared. So, it may provide wrong values.
-As it is FIFO system, there 4 logical functions are implemented, fifoPut, fifoGet, fifoPop, fifoSize.
 All of them have two parameter, name of fifo and the string value.
Ex- The image showing an example, if we want to apply putting that string in queue, it will be
${_fifoPut(SYNC_FIFO, Shantonu Test)}
-We can set time out of the queue by adding the following string in jmeter.properties or user.properties. 
kg.apc.jmeter.functions.FifoTimeout=[our time in second]

2. jp@gc - JSON Format Post Processor
This need spatial plugin library to be installed. Download link is here. Keep the files in \apache-jmeter-2.9\lib directory.  To add.
-Right click a Test Plan or thread > Post Processors>  jp@gc - JSON Format Post Processor
-It is very useful when we need to debug test cases with view result tree listener. What it do is that, it makes the response data of view result tree more readable(if there are lot's of JSONs).
-The main purpose is to make response data more easier to read.

3. jp@gc - JSON Path Extractor
This need spatial plugin library to be installed. Download link is here. Keep the files in \apache-jmeter-2.9\lib directory.  To add,
-Right click a Test Plan or thread > Post Processors> jp@gc - JSON Path Extractor
 

-This will Extract JSON path. There are two items, Name = The name of the extracted path. JSON path = the extraction syntax to get the JSON path. To know about the syntax, see this. I will try a different post for some idea about JSON path.
-It is very useful when we need to extract data from a JSON object and use in the test plan.

4. jp@gc - XML Format Post Processor
-Right click a Test Plan or thread > Post Processors> jp@gc - XML Format Post Processor
-Like as JSON format post processor, it does the same for XML response data. When we add this to our request, the response data in XML view(of response data) become more readable. When I need to debug any test step, I use this to see View Result Tree listener's response data in XML view in more readable way.
-The main purpose is to make response data more easier to read. 

Thanks..:) 

6 comments:

  1. what is the main difference b/w JSON format and XML format?

    ReplyDelete
  2. JSON format is different from XML, you may find similarity on way of using, but JSON is more like holding data/info in a object useful for passing data. And XML is a full markup language used in many purposes. For JSON basics, see this http://www.json.org/.

    ReplyDelete
  3. Is it possible to use __fifoPut() in Beanshell script?
    I have something like this:
    String threadName = ctx.getThread().getThreadName();
    int indexOfDash = threadName.indexOf("-");
    String currentThreadCounter = threadName.substring(indexOfDash+1);
    String fileUrl = vars.get("fileUrl");
    String fileUrl1 = "";
    String size = "";
    ${__fifoPut(currentThreadCounter, fileUrl)};
    ${__fifoSize(currentThreadCounter, size)};
    ${__fifoPop(currentThreadCounter, fileUrl1)};
    print("put to queue " + currentThreadCounter + " fileUrl :"+fileUrl1 + "; size:" +size);

    But the output shows that the fileUrl is empty:
    put to queue 22 fileUrl :; size:
    put to queue 5 fileUrl :; size:
    put to queue 6 fileUrl :; size:

    ReplyDelete
    Replies
    1. -> fifoPut, fifoGet, fifoPop, fifoSize.
      These are spacial function for inter thread communication (communicate among thread group) . The queue looks like top to bottom (not tree). So, i suggest use function in thread group context not individual thread context(ctx.getThread().getThreadName() should not be used)see, full context list -> https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html

      you out put will be like that as, it shown current thread count (exact moment of call) try this call getThreadNum()

      These are provide by jmeter plugins and should be used as independent function (as declared), if you invoke from beanshell , you need to follow JSR-274 specification to access jmeter functions from beanshell (Java functions are simple and straightforward) .. I usually use JSR223 sampler with Java to make things simple & straight forward.

      Again, if you state more clearly about your objective, I can add some ideas or tricks.

      Delete
  4. Hi Bro,

    I just want to use the data(userId) across multiple thread group which has been extracted from login request. could you please help me in this.
    I used Beanshell property to extract jwtToken and used it in all the upcoming thread groups but I can't use the same for userId.

    Thanks in advance.

    ReplyDelete
    Replies
    1. you need to have setup thread (or once only controller) where you login and collect the token and use in all thread groups

      Delete