Archive for November 2009

LoadRunner function – Add Five Minutes to the current time and save as a string

I needed to write a function which adds five minutes to the current time so that I could create appointment start and end times for an application used in bank branches to make appointments for customers. The function that I’ve written could be modified to add more or less time, the clever bit is making sure that it handles the last few minutes of an hour properly.

For example.
13:56 + 5 minutes = 14:01

The function handles this by converting the 13 and the 56 into integers, doing the necessary sums and then converting the results back into strings which LoadRunner can use.

When the integers are converted back to strings, single digit number are displayed correctly e.g. 01,02,03 etc. rather than 1,2,3.
The function will not work in the last five minutes of the day because I haven’t added a function to add five minutes to 23:56 to get 00:01. (If you’re running tests this late, don’t use this function).

The sample script can be downloaded from my discussion forum.

http://www.bish.co.uk/forum/index.php?topic=32.msg39#msg39


I’d appreciate any feedback that you may have after looking at the code.

PAL – Performance Analysis of Logs

SAmple of PAL output

Today I received a report from one of the sys admin types at work. The report showed performance of a server during a test which I ran last night. He used a tool called PAL (Performance Analysis of Logs).

The tool produces nice graphs, similar to Excel 2003 (it uses Microsoft Office Web Components to produce charts).

SAmple of PAL output


I’ve attached a sample of the output to my website. (Server names changed)
http://bish.co.uk/PAL_sample/PAL.htm


I’ve started a discussion thread relating to this is on my discussion forum.
If anybody knows of other similar tools, I’d like to hear about them.

http://www.bish.co.uk/forum/index.php?topic=29.msg34#msg34

 

Google Chromium OS – first impression

Google Chromium screenshot

I thought that I’d have a quick look at Google Chromium OS. I’m not sure that it’s living up to the hype yet.

Where did I get it?
So far it’s only available as a VMware or Sun Virtual box download. I downloaded both the VMWare .vmdk file and the Sun Virtual box .vdi files from http://gdgt.com/. I had problems with my VMWare installation so I thought I’d try it in Sun Virtual Box. I’m running Sun Virtual Box on a Windows 7 64-bit host.

First impressions
The Sun Virtual Box image doesn’t boot properly and only boots to a black screen. Because Sun Virtual Box can support VMWare images, I thought that I’d try the .vmdk file. I noticed other posts which recommend configuring the network in “bridged mode” and running Virtual Box with administrator credentials. I did both of these things and Chromium booted first time. I was presented with a simple login screen.
At this point I entered my gmail account details. The image uses a US keyboard so the @ symbol is “Shift-2″.

After login you see a very simple browser screen with your Google mail and Google calendar tabs. Other tabs can be opened and it can be used as s simple browser. At the moment, I can’t see much value in it, but couple it with some nicer fonts and the ability to save/sync your Google Docs to the local hard disk of a laptop/netbook or USB key and it could have potential.

What’s the point?

Perhaps one use could be for students to all be issued with their own OS and Docs on a USB key, all Docs are backed up centrally, but they could take their key to any machine and boot from it to get the same locked-down experience wherever they work.

Alternatively, banks could issue secure keys for online banking containing an OS that can only access the bank’s online banking site. This could greatly reduce online account fraud by only granting access to web based banking to people who have a physical device (encrypted USB key), know the password for the key as well as the online account password.

If you can think of any other possible uses, why not post them to my discussion forum?

Google Chromium screenshot

LoadRunner Date/Time functions

LoadRunner stores date/time parameters locally on the LoadRunner PC. This means that opening a script on another users PC, where the date/time parameter is not stored, can cause corruption to the date/time parameters in a script. You know that this has happened when a date/time parameter in a format similar to this [%Y%m%d%H%M%S] is sent to the server rather than the format that you intended.

Due to this problem, we recommend that the lr_save_datetime function is used to save date or time values to a string. The string can then be used in the script and the script is portable between PCs because the script is no longer relying on the locally stored parameters.

This sample code shows different le_save_datetime functions which can be incororated into your scripts. As usual this sample code can be downloaded from the discussion forum for further examination. http://www.bish.co.uk/forum/index.php?action=dlattach;topic=22.0;attach=21

lr_save_datetime(“%d/%m/%y”, DATE_NOW, “DDMMYY”);
lr_output_message(“Today’s Date is %s”,lr_eval_string(“{DDMMYY}”));

lr_save_datetime(“%d/%m/%Y”, DATE_NOW, “DDMMYYYY”);
lr_output_message(“Today’s Date is %s”,lr_eval_string(“{DDMMYYYY}”));

lr_save_datetime(“%B %d %Y”, DATE_NOW, “Today”);
lr_output_message(“Today is %s”,lr_eval_string(“{Today}”));

lr_save_datetime(“%B %d %Y”, DATE_NOW + ONE_DAY, “Tomorrow”);
lr_output_message(“Tomorrow is %s”,lr_eval_string(“{Tomorrow}”));

lr_save_datetime(“%A”, DATE_NOW – ONE_DAY, “Yesterday”);
lr_output_message(“Yesterday was %s”,lr_eval_string(“{Yesterday}”));

lr_save_datetime(“%A”, DATE_NOW, “Today”);
lr_output_message(“Today is %s”,lr_eval_string(“{Today}”));

lr_save_datetime(“%A”, DATE_NOW + ONE_DAY, “Tomorrow”);
lr_output_message(“Tomorrow is %s”,lr_eval_string(“{Tomorrow}”));

lr_save_datetime(“%X”, TIME_NOW , “Time”);
lr_output_message(“The time is %s (in this locale’s date format)”,lr_eval_string(“{Time}”));

lr_save_datetime(“%X”, TIME_NOW + ONE_HOUR , “Time”);
lr_output_message(“In one hour it will be %s”,lr_eval_string(“{Time}”));

lr_save_datetime(“%A”, DATE_NOW + ONE_DAY, “Tomorrow”);
lr_output_message(“Tomorrow is %s”,lr_eval_string(“{Tomorrow}”));

lr_save_datetime(“%j”, DATE_NOW, “Today”);
lr_output_message(“Today is day %s in the year”,lr_eval_string(“{Today}”));

lr_save_datetime(“%Z”, DATE_NOW, “TimeZone”);
lr_output_message(“This machine is in the ‘%s’ time zone”,lr_eval_string(“{TimeZone}”));

lr_save_datetime(“%p”, DATE_NOW, “AMPM”);
if (strcmp (lr_eval_string(“{AMPM}”),”PM”)!=0)
{
lr_output_message(“Good Morning”);
}
else
lr_output_message(“Good Afternoon”);

Filter individual strings from a long string of text

Another C/LoadRunner function brought to you by Mark Sibley.

I wrote this function specifically to address an unusual issue. I needed to capture a linked set of five pieces of data but was unable to use the standard web_reg_save_param function because the individual boundaries were not specific enough. I was however able to capture all five pieces of data as one long string of text.

This function is designed to take a long string of text and then filter out the data you want based on delimiters you supply. It saves each piece of data as a sequentially numbered parameter using a prefix you supply each time you call the function.

You can download a working example of this function here. In the example you’ll see how it turns a string like (‘Mark Sibley’,’01234567′,’01-23-45′,’01/12/2009′,’AA1 1AA’) into seven sequentially numbered parameters named {SecondSet_1} through to {SecondSet_7}.

I often call this function within a WHILE loop where I compare one of the filtered parameters against a known value until I find the one that matches a known value and then save the related values as separate parameters.

For example lets assume you’re writing a LoadRunner script that simulates usage of online banking. You may only be able to complete the process you’ve recorded if you access the current account. What you’ll probably find is that some customers have more than one type account and they’re not always listed in a predictable order. This function, combined with the WHILE statement, allows you to capture the details of each account on screen and compare the known account number to the one you’ve filtered. When you identify the row of data that has the account information you need this function then saves the associated details like the sort code or account name etc into the sequentially numbered parameter names.