Ask a Question

Property check points or insert script routine in Http load testing tasks.

tarleaa
Contributor

RE: Property check points or insert script routine in Http load testing tasks.

Hello Alex, 


I'm still having some issues with my load test. I have 2 different tasks for which I want to check the responseBody (script A and B). So, basically, here's the problem. I've created an event handler for script A and an event handler for script B. This is the event handler for script A. 


function A_OnLoadTestingResponse(Sender, User, Request)


{


var ping = Request.ResponseBody.Contents;

  if(aqString.Find(ping, "Welcome A") != -1)

{

Log.Message("String found.Test passed");

}

else

{Log.Error("String not found.Test failed");}


}


But when I run the test A that is associated with task A, in the log it shows that it also checked for the string that  coresponds to the script and event handler B. So basically, by running task A, I get load test results for task A and event handler results for task A and for task B. What am I doing wrong?


AlexKaras
Community Hero

RE: Property check points or insert script routine in Http load testing tasks.

Hi Andrei,



You did everything right. The only thing is that events are not attached neither to some given script unit nor to any other test project entity (task, web service, storage, etc.) but are global for the whole test project. Event is triggered and the handler's code it executed every time the given event was triggered regardless of what was the reason for triggering the event.



I am not sure if it is possible to figure-out from the handler code what task triggered the event. When I had to distinguish between two different tasks, I used the fact that these tasks requested different resources and the code was like this (DelphiScript mockup):

====================

  if (pos('details.jsp', Request.RequestHeader) > 0) then // the task that requests the company details page

  begin

    ...

  end

  else if (pos('process', Request.RequestHeader) > 0) then // the task that requests the directory page

    case Request.RequestID of // Checks the request ID

      1, 2:

      begin

        // make response contents available to other test procedures via strResponse global variable

        strResponse := Request.ResponseBody.Contents;

      end;

    else // case

        ...

    end // case

...

====================



Hope this will help.



P.S. Also I would recomment an excellent (from my point of view) thread available here: http://www.automatedqa.com/newsgroups/d.cgi?cmd=article&group=automatedqa.public.testcomplete&item=1...=
Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
tarleaa
Contributor

RE: Property check points or insert script routine in Http load testing tasks.

So, basically, I must treat each task separately in the EventHandler.


I have this:


function GeneralEvents_OnLoadTestingResponse(Sender, User, Request)

{

if(User.Name == "LiveData_PingTest")

{

var pingTest = Request.ResponseBody.Contents;

  if(aqString.Find(pingTest, "Welcome Data") != 1)  

{Log.message("passed data ");}

  else {Log.Error("failed data");}

}



  else if(User.Name == "LiveSecure_PingTest")

{

var pingTest = Request.ResponseBody.Contents;

  if(aqString.Find(pingTest, "Welcome secure") != 1)  

{Log.message("passed secure");}

else {Log.Error("failed1 secure ");}

}

  else {Log.Error("all failed");}



}


The problem is that the User.Name string "LiveData_PingTest" changes depending on how many users I run in the load test, becoming "LiveData_PingTest (1)", "LiveData_PingTest (2)" and so on, thus my test failing. How can I get, instead of the User.Name,  the task name that is beeing executed?





AlexKaras
Community Hero

RE: Property check points or insert script routine in Http load testing tasks.

Hi Andrei,



As I wrote, I'm not sure if it is possible to distinguish between tasks by their name in the handler code.

Instead of looking for exact match for the User.Name why not to check that the name starts from the needed characters?
Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
tarleaa
Contributor

RE: Property check points or insert script routine in Http load testing tasks.

Hi Alex, 


Thank you very much for your help. I've manage to make it work. 


Andrei

sguda
Regular Contributor

RE: Property check points or insert script routine in Http load testing tasks.

Hi I recorded the HTTP preformance test . This test has Login as one of the recorded events or connection.



Now i want to execute this test with 25 VU'S , few users with one login Id and few users with another login id. Is it possible either by paramiterization of the login id or is there any other way to do this.



Thanks in advance. So please let me know.
AlexKaras
Community Hero

RE: Property check points or insert script routine in Http load testing tasks.

Hi Andrei,



It's great to hear that you've managed to get what you needed.

BTW, I've found the following in the newsgroup thread that I mentioned:

=========

The User parameter of the event handlers contains a reference to the

VirtualUser object.

This object has the Task property that returns a reference to the user's

task instance. Please see the "VirtualUser Object" and "HTTPTask Object"

help topics for details.

=========

so it looks like that it is possible from the event handler's code to figure out what task triggered this given event...
Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
sguda
Regular Contributor

RE: Property check points or insert script routine in Http load testing tasks.

Hi Alex,



So for that i have to recognise the connection where it is looging in and check raise event for that connection to refer to user parameter?

 I will try and get back to you. Mean while i have one more question , i am exclusively trying to get the time it takes for the report to load after i click on export button. and this step would be last but one of my test.



Can you please tell me how can i do this. Can i record as seperate task of that action alone and append the traffic of previous task to this. Will it depict the same scenarion of what i am looking for.



Or is there any start transaction and end transaction like we specify in load runner.



Please suggest. T would be looking forword for this response.



Thanks a lot.


AlexanderM
Staff

RE: Property check points or insert script routine in Http load testing tasks.


Hello Sri,





Go through my reply in the other thread where you are asking the same question:

http://www.automatedqa.com/forums/forum/post.aspx?mode=singleThread&thread=44899f7e-839a-4194-91d1-1...





Does this not work for you? If so, please explain why.
-----

Alexander
Customer Care Manager
sguda
Regular Contributor

RE: Property check points or insert script routine in Http load testing tasks.

Hi Alexi,



I didn't quiet understand how to execute my load test few VU'S with different login id.I read the articles you mentioned. Can you clearly explain how to reference the VU object and pass the login parameter so that few user's run with different parameter.



That will bevery helpful. I don't see any sample code in thre for these.I don't have any choice.




cancel
Showing results for 
Search instead for 
Did you mean: