Monday, 29 January 2018

How to handle JSON request in LoadRunner(LR 12.53)

JSON request can be handled using lr_eval_json function in LR 12.53.
lr_eval_json parses a JSON string, creates a JSON object, and stores the handle of the object in a parameter.
This function is not recorded. You can insert it manually into your script.

Step1: Capture JSON request from the response body using web_reg_save_param.

Step2: Input captured parameter of json parameter and save it in a string using below lr_save_sting function.
        lr_save_string(json_input, "JSON_Input_Param");
Step3: Create a Json object using above json string.
 //Create a Json object from a string.
 lr_eval_json("Buffer={JSON_Input_Param}",
              "JsonObject=json_obj_1", LAST);
 //Create a Json object from a file.
 lr_eval_json("Buffer/File=store.json", 
              "JsonObject=json_obj_2", LAST);

Step4: Using below function values can be fetched from json object and used in the scritps.
      lr_json_get_values("JsonObject=json_obj", 
                         "ValueParam=val", 
                         "QueryString=$.val", 
                         "SelectAll=Yes", 
                         LAST);
Values will be stored in parameter like val_1, val_2, val_3.........

Alternate way:
Using web_reg_save_param_json function.
The web_reg_save_param_json function supports array type parameters. When you specify SelectAll=Yes, all the occurrences of the match are saved in an array. 
Each element of the array is represented by the ParamName_index.
In the following example, the parameter name is A:
web_reg_save_param_json("ParamName= A", "QueryString=$..arguments.additional_context[0].name", "SelectAll=Yes", LAST );
The first match is saved as A_1, the second match is saved as A_2, and so forth. You can retrieve the total number of matches by using the following term: ParamName_count.
For example, to retrieve the total number of matches saved to the parameter array,
use: TotalNumberOfMatches=atoi(lr_eval_string("{A_count}"));
web_reg_save_param_json is not recorded. You can add it manually to a script.
Argument Description
ParamName The name of the parameter to store the returned value. If the parameter does not exist, it is created.
QueryString The path of the value to save. For the syntax of the query string, see Json Path on GitHub.
SelectAll Optional: If SelectAll=Yes, all the occurrences of the match are saved in an array. See Saving Multiple Matches below in this topic.
List of Attributes For details of each attribute, see Attributes for Save Parameter Registration Functions. Attribute value strings (e.g., "Search=body") are not case-sensitive. See the Restrictions.
SEARCH FILTERS Specifies the sections of the buffer to search for the string in. See Search Filters for Save Parameter Registration Functions. See the Restrictions.
LAST A marker that indicates the end of the argument list.

Thursday, 11 January 2018

Enable/Disable iptables firewall in linux

Enable/Disable iptables firewall in linux:
# /etc/init.d/iptables save
# /etc/init.d/iptables stop
# /etc/init.d/iptables start

On Boot:
# chkconfig iptables off

# chkconfig iptables on

Thursday, 18 May 2017

SQL Plus Important Commands

How to Connect to sqlplus?
Type "sqlplus" in terminal and enter user-name and password.
On successful login below information will be displayed along with version information
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

How to exit sqlplus?
Type "quit " to exit from sqlplus

How to login using command line arguments?
Type sqlplus system/pass (It opens a connection to our local database)
To login to schema use below command
sqlplus schemaname/password@SID(Servicename defined in tnsnames.ora file)

How to check location of sqlplus?
Type which sqlplus

How to check sqlplus environment variable?
Type echo $PATH

How to check Oracle SID?
Type echo $ORACLE_SID

How to Start and stop the listener?

Command: lsnrctl using this command we can start/stop the listener by tying start/stop command

Linux Performance Monitoring

Friday, 29 January 2016

Resolving DNS Caching Issue while Performance Testing Web Services.



How to disable DNS Caching in Load Runner to avoid misleading performance results while testing Web services.

Protocol Type:

Web Service



Scenario/Flow:

Load Runner-->WIP(Global Load Balance)-->VIP(Local Load Balancer)-->Host(Web Logic Server)

Note: WIP is a DNS service, the DNS reply can be cached locally and some load tests could give misleading results like the response time of web service request differs from the actual response time.



Issue:

Request was not reaching to WIP and it was not asking the WIP for DNS resolution or DNS lookup(translation of the unique IP address or domain of host in textual format to an IP address).



Symptom:

Local DNS Caching(Applications can cache the DNS reply, as can local DNS servers).



Resolution:

As the Web Service protocol in Load Runner does not have any option to disable DNS caching, we need to create a script using Web HTTP/HTML protocol by converting all your SOAP or JMS calls using web_custom_request in Web HTTP/HTML protocol. Once the migration is done, go to Runtime Setting > Click on Preferences under Internet Protocol group>Click Options button>Change the DNS Caching option to NO under General Tab(by default it is set to YES).