Friday, June 20, 2014

Issues Encountered on Linux / Unix LG

Problem StatementDuring testing we might encounter situations where we have to simulate load from LINUX / UNIX LGs. Post installation of Loadrunner binaries on the server we might face certain issues as mentioned below and their solutions / workaround to solve them.

Issue Tags: $M_LROOT is not set, verify_generator failed, Verify running the product executables...Failed, Failed to load client QTWeb

Solution
The most common error that you can encounter is when you run the verify_generator.sh script; you will get the first error as shown below:
Once this is done, you should be able to run the script fine on your LINUX/UNIX.




This error comes when the verify_generator.sh calls the vuserchk.sh file; you can fix the issues by doing the changes in vuserchk.sh file as mentioned in the below screenshot:


The above changes should fix the issues in verify_generator.sh script.

Sometimes you might get the below shown error:


This issue comes because of missing run-time libraries; you can fix this issue by running the below command:

Install with root privelges - libstdc++.so.5  under /usr/lib/

The LG Operates in 2 modes - rsh mode and daemon mode; if the controller is not able to connect to the LG in rsh mode then you can make it work by running LG in daemon mode.

Do the following changes in your UNIX/LINUX LG to make it work in daemon mode:

Run Install command "./m_daemon_setup -install" from the /bin directory.
Command to start:  “./m_daemon_setup start”

Command to Stop: “./m_daemon_setup –remove”

From Controller UI
1. In the Load Generator Window, go to Details -> Unix Environment -> Shell settings section. 

2. Select the "Don't use RSH" checkbox.

once the daemon is running and you are able to connect the LG from controller machine, you can do a quick check by running a normal web protocol script. If you are getting the below shown screenshot (Failed to load client QTWeb) in controller then this can be due to a 64-bit OS which requires some additional libraries to be installed:



see the below snapshot for the steps to be done to resolve this issue:


Below i have mentioned some basic troubleshooting steps which you can do:

General debugging steps:
   a. Verify ping and rsh are working to and from the remote machine.
   b. The .rhosts file on remote machine with 644 permission minimum and + +.
   c. The following enviroment variables should be set:
      $M_LROOT
      $M_LROOT/bin library path included
      $M_LROOT/bin included in PATH
   d. Check the environment settings via rsh:
      K-shell (ksh): 
         rsh -n "/bin/ksh -c env"
      Bourne Shell (sh):
         rsh -n "/bin/sh -c env"
      C-shell (csh):

         rsh -n "/bin/csh -c env"

Wednesday, January 16, 2013

Running QTP Scripts in Performance Center over Firewall

Problem StatementDuring some of our non functional testing scenarios, there might be a need to get the actual end-user response timings. In that case the usual approach is to create a QTP script for the business flow and then add that in your performance center scenario and Run it. But the problem arises when the load generator (mainly the QTP machine) you want to use is behind a firewall and performance center can't connect to it directly.

Solution: There is a solution to do so:


If you want to run your QTP scripts in LoadRunner context then you need to configure your load injector and MI Listener properly as mentioned in my previous blog and then go to Step 9 for changes related to QTP:


http://commonlrissues.blogspot.co.uk/2009/03/working-with-firewalls-in-loadrunner.html


If you want to run the QTP scripts using Performance Center then follow the following steps.


Step-1: Install MI Listener from your HP ALM setup on a host machine which does not have any other ALM components:




















Once the MI listener is installed, it will ask you to configure it. Choose as a Performance Center installation.



Once MI configuration is done, you can see a loadrunner agent service being installed and running.

If you perform a "netstat -ano" on the MI Listener machine it will show that the loadrunner agent service has started listening on ports 443, 50500 and 54345. This confirms that MI_Listener has started working properly.

Step-2: Install the Load Generator component on your QTP machine (where you want to simulate the QTP users)


Step-3: Configure the Load Generator to be configured as a LoadRunner component; this is needed as we want to run the "magentproc" as a process which is needed to run QTP.





Step-4: Login to PC admin site (in PC 11 ALM login to Lab Management) and create new location and MI_Servers as shown below:






For the MI Server, better to mention the host-name in the server name and provide its IP and choose the appropriate action like "Running Vusers"

Step-5:Once the load generator is installed successfully, it will start the agent. But you need to enable it to work over firewall. So you need to change the agent config:




In this configuration (after you click the settings) you need to add the following:






Give the name (hostname) of your MI_ Listener server / machine;
Enter the local machine key as the combination of agent host name and Firewall Group in performance center separated by "_"

PS: Perform a check whether your agent is able to communicate with MI Listener, perform a telnet to the MI_Server on port 443.

Step-6:Once the load generator is configured successfully, it will restart the agent and you can see a red traffic light below in your taskbar:

Step-7: After this you need to add the load generator details in the PC interface. For this you need to login to Lab Management in Performance Center and then add the details as shown below:



In the Name mention the hostname of the load generator;
in installation type, select standalone load generator;
in location choose the location created by you;
in MI_Listener choose the MI Server created by you earlier in step 4;
and click on Submit. If all the details are correct and connections are okay then it will get added without an error.

Step-8: Once all these configuration are done, you have made the LG to work over firewall. But before you start running your GUI / QTP test lets perform a basic check to see if everything works fine.

Create a normal web scenario with a dummy web protocol script, add this LG (over firewall) to the scenario and save it. Run the scenario from PC and see if it is able to connect to LG and running the test.

Once the connection is established between Controller and LG, the traffic light will turn green and  show a cloud saying the LG is serving the VUsers as shown below:
PS: If you are done till this step then you can use this LG to run your normal web protocol scripts. 
There are restriction(s) on other protocols while running via MI listener and some tweaking needs to be done before it can work. The same needs to be done for the QTP scripts, the below step is needed only for the case of QTP script.

Step-9: In order to run your QTP script on the LG over the firewall (once all the above steps are done), you need to make the following changes:

The below changes are needed on the QTP installation:


  • Please browse to the [QTP Install Dir]\dat\mdrv directory on the generator machines. 
  • Open the mdrv_qtp file in notepad
  • Please add 'SecurityMode=On' under the sections [tulip] and [ActiveScript]
  • In the [QTP Install Dir]\dat directory, open the mdrv.dat file and add the following to the very end:

        [tulip]
        SecurityMode=On

        [ActiveScript]
        SecurityMode=On


The below changes are needed on the Load Generator installation:

  1. Open the mdrv.dat file under the [LG Install Dir]\dat folder on Load Generator machine.
  2. Search for the [Tulip] and [ActiveScript] section and add "SecurityMode=On" to the list under it. If not then add the entries manually as shown above for QTP
  3. Repeat step 2 for the mdrv.dat file under the [LG Install Dir]\launch_service\dat folder on the Load Generator machine.
  4. Restart the Agent on the machine.



Step-10: Add the "mmdrv.exe" to your DEP (Data Execution Prevention) exception list; this process is placed at "[QTP Install Dir]\bin" folder. Once this step is done, you have successfully configured your LG to run QTP scripts through performance center to an agent over the firewall.

PS:If your are running Agent on a machine where UAC is turned high then change the UAC setting to medium and change property of magentproc.exe to run with Admin privileges. 

One more thing to note is that you must validate your QTP script in silent test runner and make sure that it runs fine without any issues.

Tuesday, November 20, 2012

How to Save the downloaded file to local system

Problem Statement: During some of our non functional testing scenarios, there might be a need to download some files. We are also asked to check the transaction time for that download process, but very rarely there is a need to save the downloaded files to your local system for some verification later. If this is the case then how can we do so...

Solution: There is a solution to do so, all you need to do is get the data from the server response and save it to a file using normal file operations. But you need to know beforehand the type of file you are going to download.

In this sample example let's consider that you are trying to download a .pdf file and want to save it to local system. Here is a sample code snippet to do so:
**************************************************

//declare the variables
int fp;
long i;

//create file for writing.
fp = fopen("c://test_file.pdf","wb");

//Start a transaction to measure the download time.
lr_start_transaction("file_download");

//Set the parameter size large enough to save the data.
web_set_max_html_param_len("100000");

//Use web_reg_save_param with the correct boundary to capture the data returned by the server (for the download)
web_reg_save_param("FILEDATA","LB=","RB=","Search=Body",LAST);

//HTTP call to download the .pdf file
web_url("http://serverURL:port/app/resource/getme.pdf");

//Get the download size.
i = web_get_int_property( HTTP_INFO_DOWNLOAD_SIZE );

//Write the data saved to an output file.
fwrite(lr_eval_string("{FILEDATA}"),i,1,fp);

//End the transaction
lr_end_transaction("file_download", LR_AUTO);

//Close the file pointer.
fclose(fp);
**************************************************

Hope this helps in your scenario.

Monday, October 8, 2012

Conversion Functions for Hash (SHA1) and Hex

Problem Statement: During a recent project there was a need to encrypt the data to be sent to target application using SHA1 algorithm. There was a need to develop some kind of function which can achieve this objective.

SolutionDuring this process i used Visual Studio 2010 to develop the required functions using c++ code and then export these functions using dll.

This dll can be called in your VUGen script to encode the string using SHA1 algorithm and send it back to you (this generates the code in base-64).

Also this dll has some more basic utility like converting a string to hex and vice-versa. The usage of the functions can be seen in the screenshot below:


Hope this is helpful to you in your projects; if anyone needs any custom functions then i can probably add them later into this dll.

PS: I can't post the dll here in this post due to option restrictions; you can mail me if you need it then i can send you the dll.

Thursday, September 13, 2012

Minimum Permission Level to Install and Run Loadrunner

Problem Statement: What is the minimum access level a user needs to Install and Run Loadrunner and its components ?

Solution: Ideally the user needs to be part of Administrator group on the machines where he wants to install and run loadrunner.

But actually a user needs to be Administrator for installation and power user for running LoadRunner.


It is recommended to be a member of at least power users to run LoadRunner. 
Sometimes, due to security restrictions, this is not possible. In that case, the user must have at least the following rights; these rights needs to be provided appropriately by an Administrator:
1. Full access (read/write permissions) to registry keys as mentioned below:
HKEY_CURRENT_USER\Software\Mercury Interactive
HKEY_LOCAL_MACHINE\Software\Mercury Interactive 
HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\engines\text
HKEY_LOCAL_MACHINE\Software\Microsoft\Tracing
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\WMI
2. Full access (read/write permissions) to the file system (preferably to the local drive where user account is present and other drive if Loadrunner is installed on a secondary drive) to be able to copy files.

If there is any problem either with agent start up or connection from Controller to the agent on a Windows 2K machine with a power user, then ask the system administrator to perform the following:
1. Open the Local Security Settings window through Start -> Programs -> Administrative Tools -> Local Security Policy.
2. Select Security Settings -> Local Policies -> User Rights Assignments.
3. Add the user to the "Create global objects" policy.

Tuesday, September 11, 2012

Is there a way to suppress errors from perfmon counters in controller

Problem Statement: During our day to day life as performance testers / experts, we must have noticed a lot of errors related to counters during a long running scenario. Mostly the errors are like "A counter with a negative denominator value was detected.", "A counter with a negative time base value was detected." or "A counter with a negative value was detected."

All these errors make the online monitoring a lot difficult to filter out the actual errors coming from the application.

Is there a way to mask these errors related to counters?

SolutionThe answer is Yes, it is possible to do so.
For this you need to do the below change in both Controller and Load Generator machine.


  • Go to the Loadrunner (or performance center host) installation dir; then go to folder "dat -> monitors" 
  • under that folder open the file "nt.cfg" in a wordpad; it will be like as shown in the snapshot below:




  • You can see the "general" section in the file, there is an entry called as "FilterErrors" which has the current value as 6.
  • Now to set the proper value for other errors which you want to suppress, get the Hexa value of the error from MSDN website: " http://msdn.microsoft.com/en-us/library/aa373046(v=VS.85).aspx "
  • Look for the hexa code like " 0x800007D6 (PDH_CALC_NEGATIVE_DENOMINATOR) " for the error " A counter with a negative denominator value was detected. "
  • Open Calculator in scientific mode (in case of XP / win 2003 machine) or programmer mode (in case of win 7 or 2008 server) as shown below


  • Move it to Hex mode and make the entry for the Hex code as it appears for the particular error, in this example it will be "800007D6". Once entered, change the calculator to Dec mode and you will get a number like "2147485654" (see the screenshot below):

  • Copy the value from the calculator and put it in the "nt.cfg" file along with the earlier value separated by comma (,) as shown in the screenshot below:

  • Once done you can perform similar steps for other error types you are getting from windows perfmon counters.
  • Save the "nt.cfg" file and restart the loadrunner agent process (or service) on Load generator.



Monday, September 10, 2012

Functions not allowed while running vusers over firewall

Problem Statement: In certain cases your VUGen script has certain functions (may be custom functions in C like malloc, etc) which runs fine during replay on your machine. But the same function gives an error while running the script on a load generator over firewall (i.e. the vuser is running over a firewall). The error given by LR is: "Error: -19886: CCI security error:You are running under secure mode and the function is not allowed in this mode"

Is there a way to allow the function to be run in the load generator?

PS: This error doesn't come while running the script on a normal load generator (not behind the firewall).


Solution: The answer is Yes, it is possible to do so. 
go to the load generator machine where the above mentioned error is coming; go to the installation directory and open the folder called as "merc_asl".

There will be many "*.asl" files, each corresponding to protocols support during running Vusers over firewall. 

Open the .asl file for the protocol in a wordpad for which you are getting the above error, add your function in that file as shown below:
[Function name]= 
below the [Allowed_Functions] tag


Once you have added the custom function in the asl file; restart the agent service (or process) on the load generator and your script should pass now.

Hope this helps in resolving your issues.