Thursday, January 13th, 2011
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:
(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]
Wednesday, January 12th, 2011
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]
Thursday, December 16th, 2010
Problem:
Cannot connect to port 25 on an MS Exchange server to use its SMTP service. A telnet test gave the following error:
telnet xx.xx.xx.xx 25
Connecting To xx.xx.xx.xx…Could not open connection to the host, on port 25: Connect failed
Background & Analysis:
One of my batch scripts used blat to send emails. However, I could not use the SMTP service on the Exchange Server. After liaising with the Exchange and Network administrators, we determined the following:
- There was no firewall between my machine and the Exchange server and a tracert completed quickly in just 2 hops.
- There was no firewall on the Exchange server.
- The firewall on my machine was turned off.
- The SMTP service was listening at port 25 on the Exchange server and was functioning properly.
Solution:
The McAfee Anti-Virus log on my machine had the following entry:
16/12/2010 12:41:02 PM Blocked by port blocking rule C:\WINDOWS\system32\telnet.exe Anti-virus Standard Protection:Prevent mass mailing worms from sending mail xx.xx.xx.xx:25
So, it was the McAfee anti-virus software that blocked outbound connections to port 25. To resolve this problem, you can add an exception to the anti-virus policy that permits your mail program (in my case, it was blat) to initiate connections to port 25 (recommended) or you may disable the anti-virus (not recommended).
Root Cause:
The Anti-virus software on the source machine had a policy enabled which prevented outbound connections to port 25.
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]
Thursday, October 28th, 2010
Blat is a handy Win32 console utility that enables you to send emails via the command line, on Windows machines. This is especially useful within batch scripts.
Given below are some how-tos on basic uses of blat. Refer the blat syntax page for more options with blat. The commands below have been tested on Windows Server 2003 with blat v2.6.2, unless otherwise stated.
HOW-TO 1: Configure the SMTP Relay for blat
The blat utility can perform functions of both an MUA and an MTA. Before using blat, you may configure certain options in the Windows Registry to avoid typing them repeatedly whenever sending emails (using overrides on the command line). An example configuration is given below:
blat -installSMTP mymailer.smtp.xyz.com sender@xyz.com 5 25
#
# where:
# mymailer.smtp.xyz.com => SMTP Relay host's domain name
# sender@xyz.com => sender's email address
# 5 => Number of retries (default=1)
# 25 => SMTP Server port (default=25)
#
After executing the command in the above example, your Windows Registry should have entries for blat as shown in the image below:
HOW-TO 2: Send email with empty body
blat -s "Test mail" -i "Cybergavin Tester" -to test@abc.com -body " "
#
# where:
# -s => Subject (NOTE: If you don't provide a subject, then default subject is
# "Contents of file: stdin.txt"
# -i => Sender's Name (NOTE: Sender's email address already configured in STEP 1)
# -to => Recipient's Email Address
# -body => blank body (blankspace within double-quotes)
#
NOTE: To send email with a body, just type the message within double-quotes in the -body option.
HOW-TO 3: Send email with body from a file
blat body.txt -s "Test mail" -i "Cybergavin Tester" -to test@abc.com
#
# where:
# -s => Subject (NOTE: If you don't provide a subject, then default subject is
# "Contents of file: stdin.txt"
# -i => Sender's Name (NOTE: Sender's email address already configured in STEP 1)
# -to => Recipient's Email Address
# body.txt => file containing message body
#
HOW-TO 4: Send attachment(s)
blat -s "Test mail" -i "Cybergavin Tester" -to test@abc.com -body "Please see attached"
-attach test.txt
#
# where:
# -s => Subject
# -i => Sender's Name
# -to => Recipient's Email Address
# -body => Message Body
# -attach => Binary File to be attached
#
HOW-TO 5: Send HTML email
blat body.html -s "Test mail" -i "Cybergavin Tester" -to test@abc.com -html
#
# where:
# -s => Subject (NOTE: If you don't provide a subject, then default subject is
# "Contents of file: stdin.txt"
# -i => Sender's Name (NOTE: Sender's email address already configured in STEP 1)
# -to => Recipient's Email Address
# body.html => file containing message body in HTML format
# -html => Use HTML format (Content-Type : text/html)
#
VN:F [1.6.5_908]
Rating: +9 (from 9 votes)
Thursday, October 28th, 2010
Copying a MySQL database from one server (MySQL server/host) to another may be done using a simple two-step process.
STEP 1: Backup the database on the source server
The mysqldump utility can be used to backup the database on the source server. An example using the root account is provided below:
mysqldump -u root --databases mytestdb > mytestdb.sql
NOTE:The "–databases" option above ensures that a "CREATE" statement for the database is written to the backup SQL, thereby enabling you to restore the database to a server where the empty database does not exist. If you do not use the "–databases" option before the database name, then the backup will still work, but in this case, you must have an empty database of the same name existing on the target server (no CREATE statement in SQL).
STEP 2: Restore the database on the target server
Restoring the database on the target server simply involves executing the "backup SQL" created on the source server.An example using the root account is provided below:
mysql --password=XXXXX < mytestdb.sql
VN:F [1.6.5_908]