Jump to content
WAPT Forum
Sign in to follow this  
Guest kc_tester

Running db cleanup script

Recommended Posts

Guest kc_tester

Hi, I have a question about running a script prior to load testing and/or during -- I need to clean up some database tables that fill up due to duration testing. In my current tool, I have the option of writing some code prior to each test iteration running .. that cleans up some db tables.

 

How could I do this with WAPT?

 

Here's an example of what I'm using now (javascript):

 

////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////

// connect to db and clean up users notes tbls for duration testing ////

////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////

 

// set global variables

var loopcount=0;

// set the loop iteration to clear the db

var NUM_ITER = 20;

 

function GeneralEvents_OnStopTest(Sender)

{

// lock any logging to help with memory issues

//Log.LockEvents();

 

// initially, we'll clear out tbls at 0

if (loopcount % NUM_ITER == 0) {

clearNotes();

//Log.Message("Cleaned Database on loop #" + loopcount);

}

loopcount++;

}

 

function clearNotes() {

 

var adoConnection, cmd, param, taskIds, taskId, sqlIp, username, pwd, i;

 

sqlIp = "servername"; //TODO: add end of IP

username = "xxx";

pwd = "xxx!"; //TODO: update password

 

try {

 

//TODO: Update this array with the proper task IDs.

taskIds = [39, 9, 95, 113, 7, 117, 17, 149, 28, 160, 50, 172];

 

adoConnection = ADO.CreateConnection();

 

//TODO: Test Connection String

adoConnection.ConnectionString = "Driver=SQL Server;Server=" + sqlIp + ";" + // "\\SQLExpress;" may be needed in the future

"Database=cr2007;" +

"User ID=" + username + ";" +

"Password=" + pwd + ";";

 

adoConnection.Open();

 

for (i = 0; i < taskIds.length; i++) {

taskId = taskIds;

cmd = ADO.CreateCommand();

cmd.ActiveConnection = adoConnection;

cmd.CommandType = adCmdText;

cmd.CommandText = "DELETE FROM ChecklistTaskNotes " +

"WHERE ChecklistTaskID = " +

taskId;

 

cmd.Execute();

}

adoConnection.Close();

}

catch (exception) {

Log.Message("Exception", exception.description);

}

}

 

 

Thx!

Share this post


Link to post
Share on other sites
Guest Aks
... i guess i could run a bat file ... just thought others might have ideas out there.

 

I used a JSP file to call the stored procedure to run the external database script and for making the database script dynamic I used orderlist.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...