Ahoy there! This is my personal blog which I use as my memory extension and a medium to share stuff that could be useful to others.

Archive for January, 2011

Monitoring QTP (command-line)

Our test team uses HP QuickTest Professional (QTP) to perform data loads by importing data from an MS-Excel workbook and using a Web Form to load the data. Some data loads took a while and some were performed outside office hours. As these data loads were performed manually via the QTP GUI, QTP errors would be detected only when the Test team personnel manually check the results of the QTP run, thereby delaying further action or resolution. Given below is a solution to enable receipt of email notifications for terminating QTP errors:

STEP 1: Record and save a test using the QTP GUI

Using the QTP GUI, record the user journey for your test and save the results. Let’s assume you save the QTP test in C:\QTP\Test1

STEP 2: Customize settings using VBScript

Download the VBScript template QTPAutoRunTemplate.vbs (download zip and extract) and place it in the QTP test directory (C:\QTP\Test1). If you are familiar with the QTP Automation Object Reference model, then you may customize the test settings in this VBScript template. Note that the line qtTest.Settings.Run.OnError = "Stop" in the template. This setting was used as our requirement was to stop the QTP test upon first error. Also, this solution was built using this setting as a pre-requisite.

STEP 3: Execute QTP Test using PowerShell

Download the PowerShell Script QTPAutoRun.ps1 (download zip and extract) and do the following:

(1)    Edit the script using your favorite editor and do the following:

  • Set the $email_recipients variable on line 64 to appropriate value(s).
  • Set the $smtp_server variable on line 65 to an appropriate value.

(2)    Execute the script. This script will do the following:

  • Modify QTPAutoRunTemplate.vbs to include the path to the recorded QTP test (passed as a parameter to the script).
  • Execute QTPAutoRunTemplate.vbs and capture the results.
  • Check the results and dispatch email notifications.

NOTE: In order to execute the PowerShell Script, you must have Windows PowerShell 2.0 installed on your Windows machine. For email notification to work, you must have connectivity and authorization to use the SMTP server to relay email.

VN:F [1.6.5_908]
Rating: -1 (from 1 vote)

Cannot grep UTF-16 Unicode files

Problem:

Microsoft SQL Server error logs had I/O errors in them. After transferring 4 months’ logs over to a UNIX machine to analyze them with grep/awk/sed, the grep command did not return any output when searching for strings which were present as indicated when viewing the file using the vi editor.

Background & Analysis:

On the UNIX host, I checked the file type of the SQL Server error log as follows:

$> file ERRORLOG.1
ERRORLOG.1: Little-endian UTF-16 Unicode English character data, with very long lines,
with CRLF line terminators

So, the grep command couldn’t parse the UTF-16 Unicode file. Hence, the file had to be converted to a format which ‘grep’ could parse. The iconv program helps us perform this file format (character encoding) conversion.

Solution:

Change the file’s character encoding from UTF-16 to UTF-8 and then perform the grep as follows:

$> iconv -f UTF-16 -t UTF-8 ERRORLOG.1 | grep "SQL Server has encountered.*I/O requests"

Root Cause:

The grep program cannot parse files with certain character encodings like UTF-16.

 

NOTE:

(1) The solution above describes a successful problem-solving experience and may not be applicable to other problems with similar symptoms.

(2) Your rating of this post will be much appreciated. Also, feel free to leave comments.

 

VN:F [1.6.5_908]
Rating: +1 (from 1 vote)