Jump to content


How to do "traditional" logging in WAPT Pro 2.1


  • Please log in to reply
5 replies to this topic

#1 Guest_Siegfried Goeschl_*

Guest_Siegfried Goeschl_*
  • Guests

Posted 29 June 2011 - 02:39 PM

I have long-running performance test up to 24 hours and a hundreds of users - one thing being tested is account creation. SInce this is a formal test I need to provide the list of accounts I created during the performance test and match those accounts with the accounts actually found in the database. Therefore it is critical to write all created accounts into a logfile.

I tried the following options

+) using the "log" object provided does not help me for various reasons - it would be spread across all of my users and reporting is becoming unstable in my case (getting socket problems while downloading/parsing the logs)
+) using JavaScript (see the code below) does not work under high load because the Windows Scripting stuff throws exceptions - I think that concurrently writing to the same file causes the issue

Any other ideas?

Thanks in advance

Siegfried Goeschl



=== Start of Script ===

/**
* Logs to the given file and prepends a timestamp. If the file does not exist it will be created.
*/
function logToFile(fileName, line)
{
var date = new Date();
var timestamp = null;
var minuteString = null;
var secondString = null;

var hourString = (date.getHours() < 10) ? "0" + date.getHours() : date.getHours();
var minuteString = (date.getMinutes() < 10) ? "0" + date.getMinutes() : date.getMinutes();
var secondString = (date.getSeconds() < 10) ? "0" + date.getSeconds() : date.getSeconds();
var timestamp = hourString + ":" + minuteString + ":" + secondString;
var lineWritten = timestamp + ";" + line;

var fso = null;
var fh = null;

try
{
fso = new ActiveXObject("Scripting.FileSystemObject");
fh = fso.OpenTextFile(fileName, 8, true);
fh.WriteLine(lineWritten);
}
catch(e)
{
log.error("Unable to append to the logfile : " + lineWritten);
}
finally
{
if(fh != null)
{
fh.Close();
}
}
}

=== End Of Script ===

#2 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 663 posts

Posted 30 June 2011 - 05:50 AM

Use an unique file name for each virtual user (for example, use $UserID for file name) and merge files after test completion.
Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com

#3 Guest_Siegfried Goeschl_*

Guest_Siegfried Goeschl_*
  • Guests

Posted 30 June 2011 - 03:06 PM

Hi Sergei,

there are many ways to skin the cat .... :-)

I implemented that in the mean time and need to test it but I think that better logging support would be a valuable addition to WAPT - image what my customer says if I try to explain why I need to write to 500 individual logfiles ... :-(

#4 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 663 posts

Posted 04 July 2011 - 03:22 AM

Ok, we will think.
Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com

#5 Guest_Siegfried Goeschl_*

Guest_Siegfried Goeschl_*
  • Guests

Posted 05 July 2011 - 09:16 AM

I tested the solution using a single file for each virtual user and it does not work - when I have more virtual users trying to log causes an Exception saying "Object error".

For the records the script I'm using

/**
* Logs to the given file and prepends a timestamp. If the file does not exist it will be created.
*/
function logToCsv(baseFileName, line)
{
var date = new Date();
var fileName = baseFileName + "." + context.userId + ".csv";

var hourString = (date.getHours() < 10) ? "0" + date.getHours() : date.getHours();
var minuteString = (date.getMinutes() < 10) ? "0" + date.getMinutes() : date.getMinutes();
var secondString = (date.getSeconds() < 10) ? "0" + date.getSeconds() : date.getSeconds();
var timestamp = hourString + ":" + minuteString + ":" + secondString;
var lineWritten = timestamp + ";" + line;

var fso = null;
var fh = null;

try
{
fso = new ActiveXObject("Scripting.FileSystemObject");

if (fso.FileExists(fileName))
{
fh = fso.OpenTextFile(fileName, 8, true);
}
else
{
fh = fso.CreateTextFile(fileName, true);
}

fh.WriteLine(lineWritten);
}
catch(e)
{
log.error("Unable to append to the logfile : " + lineWritten);
log.error("Root Cause : " + e);
}
finally
{
if(fh != null)
{
fh.Close();
}
}

#6 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 663 posts

Posted 06 July 2011 - 05:11 AM

What is your hardware specification and how many virtual users did you run?
Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users