Guest kc_tester Report post Posted May 27, 2009 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! Quote Share this post Link to post Share on other sites
Guest kc_tester Report post Posted September 24, 2009 ... i guess i could run a bat file ... just thought others might have ideas out there. Quote Share this post Link to post Share on other sites
Guest Aks Report post Posted October 5, 2009 ... 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. Quote Share this post Link to post Share on other sites