Archive for June 2010

Calculate epoch time for last midnight

I had a requirement to calculate the epoch time in milliseconds for midnight at the start of today.

This function calculates this value.

 


Action() {
// Epoch time on 1/1/2010 00:00:00 was 1262304000
// N.B, If running this in subsequent years, change the hard coded value on the next line. // Value obtained from http://www.epochconverter.com/
//Declare integer iEpochStartYear – use it to hold the Epoch time (in secs) on 1st January this year.
int iEpochStartYear = 1262304000;      
//Declare integer to hold calculated value of Epoch time last midnight.
int iEpochSecsLastMidnight;            
//Declare integer to hold the current day (i.e. num of days since 1st Jan 2010)
int iCurrentDay;                  
//Declare char to contain final output value (N.B in milliseconds, not seconds)
char sEpochMilliSecsLastMidnight[13];   
// Current day is number of days since start of 1st Jan 2010.
// Need to subtract one day since midnight is nominally the end of yesterday (rather than the start of today).
lr_save_datetime(“%j “, DATE_NOW – ONE_DAY, “sCurrentDay”);
//Convert the SCurrentDay string to an integer
iCurrentDay = atoi(lr_eval_string(“{sCurrentDay}”));               
//Calculate Epoch time (in seconds) for last midnight
iEpochSecsLastMidnight = iEpochStartYear + (iCurrentDay * 86400);     
//Write Epoch time (in milliseconds) for last midnight to a string
sprintf(sEpochMilliSecsLastMidnight, “%d000″, iEpochSecsLastMidnight);    
lr_output_message(sEpochMilliSecsLastMidnight);
return 0; }

Installing LoadRunner on 64-bit Windows

n a recent assignment I had to install LoadRunner onto Windows 2003 64-bit servers.
After upgrading to LoadRunner 9.51 (by installing HP patch LR_03009), it was not possible to install LoadRunner 9.52 (patch LR 03012).

I kept getting the error message..
“Upgrade patch cannot be installed because the program to be upgraded may be missing, or the patch may update a different version of the program. Verify that “HP LoadRunner Software 9.51″ exists on your machine.”
LoadRunner upgrade error message

I had successfully installed LoadRunner from the same media onto a Windows XP (32-bit) PC so I was pretty confident that the media was OK. I had a think about this and came to the conclusion that perhaps the 9.52 patch couldn’t find the information relating to the LR 9.51 installation.

I looked in the registry and I found that the Mercury Interactive key was in the HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMercury Interactive tree. If the 9.52 patch was checking in HKEY_LOCAL_MACHINESOFTWAREMercury Interactive to find the version number, that might account for the problem.

These are the steps that I took to resolve this problem:

  • Open Registry Editor (REGEDIT)
  • Browse to the HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMercury Interactive key.
  • Export the contents of this key to a local file (perhaps on your desktop).
  • Make a copy of this key and rename the copy to avoid confusion.
  • Open the copy of the key using a text editor.
  • Perform a search and replace, to delete all references to Wow6432Node  
Regedit snapshot

  • Back up your old HKEY_LOCAL_MACHINESOFTWARE hive.
  • Double-click on the new registry file to import it into your machine’s registry.
  • Now proceed to install the 9.52 patch (LR 03012) as normal.
Once this is done, the installation runs normally.
LoadRunner patch installation snapshot