Friday, 13 November 2020

Editing Average Response time for JMeter - Grafana

 In this topic, I explain the modifications I did in the Average Response time graph for Grafana - Jmeter integration. If you configured the integration, the graph will be displayed like this>


Here the data points are partially visibile and mostly we may not be able to get the most of this chart. Especially, if your test is having more number of transactions, then this will looks glumpsy. To modify this we can tweak some parameters of the grafana chart as below. 

To edit the chart click on the drop down icon next to chart legend (in this case Transaction Response Times) . In the menu, click on Edit .


Now you can get the edit screen so that we can customize. Note: If you dont have the edit rights in grafana, you may not be getting the menu. 

Look at the query in the query window (If you use influx db as a middle layer) . 

In case if you are not getting this query window you can click on the highlighted button to get text query editor. If you want to skip some transactions to be displayed in this graph, you can slightly edit the query. 

SELECT mean("pct90.0") FROM "$measurement_name" WHERE ("application" =~ /^$application$/) AND $timeFilter GROUP BY "transaction", time($__interval) fill(null)

You can add addtional filter in the query as below:

SELECT mean("pct90.0") FROM "$measurement_name" WHERE ("application" =~ /^$application$/) AND $timeFilter AND "transaction" !~ /XYZ*/ GROUP BY "transaction", time($__interval) fill(null)

In the place of XYZ you can put your regex or starting letters of the transactions to be hidden. If you want to show only certain transactions you can modify the query accordingly. 

By default, a transation named "all" will be displayed in the chart. you can hide that as well by tweaking like this.

SELECT mean("pct90.0") FROM "$measurement_name" WHERE ("application" =~ /^$application$/) AND $timeFilter AND "transaction" !~ /XYZ*/ AND  "transaction" = 'all' GROUP BY "transaction", time($__interval) fill(null)

Please note the single quotes and double quotes to avoid mistakes. In case if you want to remove the transaction response times of failed transactions you can set your query like this:

SELECT mean("pct90.0") FROM "$measurement_name" WHERE ("application" =~ /^$application$/) AND $timeFilter AND "transaction" !~ /XYZ*/ AND  "transaction" = 'all' AND "statut" = 'ok' GROUP BY "transaction", time($__interval) fill(null)

Now look at the graph visual settings. On the same screen, right hand side we can see three tabs for editing ( Panel, Field and Overrides) 

In the Panel - Visualization used to change the chart type but not right now .

Go to Panel - Display tab and look at the Area fill option. If you don't want to shade the chart lines change Area = 0. 

Another important option is how to display null values in the chart. Default is null which will show the lines as disconnected and leave more dots in the chart. Change the value as Connected which will connect the data points to make it smoother to view. 

After adjusting Area & null value display the chart will look like this:


Now lets adjust the Hover Tool tip. This is the one when we move the mouse cursor over the chart and by default it displays all transaction names and its response time graphs. Our aim is to highlight only the pointed line and its transaction name and detail instead of all . To do this, look for option called Hover Tool Tip in the display section and change to Single as below:



Dual Axis Graphs (Overlay Graphs) :

Let us see how we can create a overlay graph like Loadrunner analysis in Grafana. For example, I need to overlay Vusers (Active Threads in terms of JMeter) on Error count graph. You can pick up the Errors graph from the default Json and click on Edit as we shown above. In the query section, add another query to the graph by clicking on the +Query button. In the query editor enter the below query to plot Vusers on top of Errors graph. 

SELECT last("maxAT") FROM "$measurement_name" WHERE ("transaction" = 'internal' AND "application" =~ /^$application$/) AND $timeFilter GROUP BY time($__interval) fill(null)

Now you can see the Vusers (Active threads) line on top of the Errors graph. Some times default area shading will hide the errors. Lets go to the Panel --> Display and change Area Fill to zero. 

In the Legends section, turn on Average and current values for Errors for better clarity. 

To tune it better , lets change the graph to dual axis graph. One axis for Errors and the other for Active Threads. we need to click on the color line just before the  graph legend. I highlighted the area to click for better clarity. 



if we click on  the color line, we can get the axis tab and enable the Y-Axis:

Now we can configure the right Y-axis properties in the  Panel -->Axis section. Provide a label name, and if required change the units. The graph will look likes below:

By the same way we can overlay Vusers on top of Response time / hits per second graphs. 


Tuesday, 20 October 2020

Increasing JMeter JVM Memory

 This article applies for JMeter version 5.3.


By default, JVM memory size will be 1GB alloted to Jmeter which will not suffice if you run a test with more than 100 Vusers. Also if you have not increased the JVM Memory size you might be running the test with headless mode which will be difficult to monitor unless you setup Grafana / Blazemeter/ . 

To increse the JVM size you need to alter 2 files. Go to Jmeter Bin folder and open JMeter.bat file in a text editor of your choice.


Add these lines before get standard environment variables


set HEAP=-Xms512m -Xmx6g

set JVM_ARGS=-Xms512m -Xmx6g


Then open Jmeter.sh file

# add the Java9 args before the user given ones

JVM_ARGS="$JAVA9_OPTS $JVM_ARGS"

JVM_ARGS="-Xms1g -Xmx6g"


Now save both the files and the JVM Memory size increased to 6GB. 

Thursday, 3 September 2020

Verification in Karate

Verification in Karate:

In this post, I am going to discuss about various level of verification we are going to apply in Karate..

Once we are able to successfully make the request (GET/POST/DELETE/...) now we need to validate the response . Response validation will go into three stages:
1. Response Status code validation (http)
2. Response Schema validation
3. Response value validations.

Karate has these abilities for all these validations with more in built functions. we can see them one by one.

1. Response Status code validation (HTTP)


Thursday, 9 July 2020

KARATE (API TESTING) BASICS

KARATE API Testing Basics:

Karate , I started with Intellij IDE . I added the required dependencies in Maven. I started creating a new Maven Project and click on Add Archetypes. I have given below information in the small popup

Archetype Group Id= com.intuit.karate
ArchetypeArtifactId= karate-archetype
ArchetypeVersion=0.2.7

Then I entered my project name and its created my first project. Then in the project explorer, i started creating my directory structure. In Karate directory structure becomes so important since we are going to deal with .feature files, and a java runner class and request and response Json files. So we need to arrange them in  a particular fashion so that the IDE picks it up from right location.

Before that , lets have a look at the Maven dependencies . Karate needs an integration with Junit to run the test cases. so we need to add / or make sure these dependencies are in place.

<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
</dependencies>


Here karate.version may be the current version of karate. The current version we can check it from Maven repository (https://mvnrepository.com/artifact/com.intuit.karate/karate-junit5)

At this point of time, the current stable version is 0.9.5 , that I updated into my maven dependencies like below
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>0.9.5</version>
<scope>test</scope>
</dependency>

Now is the time to create folder structure:
Expand the project folders, expand src, and then Java. Now right click java and select new and package. Enter the name of the package
then in the package you can create sub folders requests, responses, if required features as a separate folder. 


Shrinking the size of Oracle Virtual Box

First, zero fill your virtual disk. Boot the VM and run: sudo dd if=/dev/zero of=/bigemptyfile bs=4096k status=progress sudo rm -f /bigempty...