Forum Discussion

sguda's avatar
sguda
Regular Contributor
14 years ago

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

In HTTP testing,



Is it possible to insert property check points or script routines in the task.



Suppose i am doing different tsaks like login, findreports etc. i want to include the script routine in the task like to wait for alias child or script routine to estimation the execution time of the report etc. How can i do this . please let me know as soon as possible.



Thanks a lot.

20 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    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=18660&utag=
  • 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's avatar
    AlexKaras
    Champion Level 3
    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?
  • Hi Alex, 


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


    Andrei

  • sguda's avatar
    sguda
    Regular Contributor
    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's avatar
    AlexKaras
    Champion Level 3
    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...
  • sguda's avatar
    sguda
    Regular Contributor
    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.


  • sguda's avatar
    sguda
    Regular Contributor
    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.