Topic
  • 7 replies
  • Latest Post - ‏2012-06-04T19:00:35Z by petersda
SystemAdmin
SystemAdmin
5507 Posts

Pinned topic Extract response on error setting

‏2012-05-25T12:56:52Z |
Hi
Does anyone know settings to extract response from server as soon as the error occurs. Under load, I am experiencing errors in the test. I would like use this option to analyse what response content we getting back from server.

Thanks
Shambu
Updated on 2012-06-04T19:00:35Z at 2012-06-04T19:00:35Z by petersda
  • RobertoFdez
    RobertoFdez
    50 Posts

    Re: Extract response on error setting

    ‏2012-05-28T10:24:43Z  
    If you are executing a test, you can check the response from the server in the Protocol Data tab. If you are executing a Performance Schedule, you must select "Watch Virtual user" in the same tab. In both options you can see in real time the response from the server to each request
  • SystemAdmin
    SystemAdmin
    5507 Posts

    Re: Extract response on error setting

    ‏2012-05-29T15:00:15Z  
    If you are executing a test, you can check the response from the server in the Protocol Data tab. If you are executing a Performance Schedule, you must select "Watch Virtual user" in the same tab. In both options you can see in real time the response from the server to each request
    Thanks Roberto. I did try watching virtual user when running from performance schedule. But the issue was the error would have occurred prior to choosing the user and hence cannot capture the response for the error that had occurred.

    I guess way forward for my solution is to capture response and do verification check, if verification check fails, then print the response (or part of response)into log. For ajax calls, I have response which are small in content and should be okay for me to log.

    The thing I am concerned with this approach is any memory implications on the rpt? Any thoughts on this highly appreciated.
  • SystemAdmin
    SystemAdmin
    5507 Posts

    Re: Extract response on error setting

    ‏2012-05-29T16:34:39Z  
    Thanks Roberto. I did try watching virtual user when running from performance schedule. But the issue was the error would have occurred prior to choosing the user and hence cannot capture the response for the error that had occurred.

    I guess way forward for my solution is to capture response and do verification check, if verification check fails, then print the response (or part of response)into log. For ajax calls, I have response which are small in content and should be okay for me to log.

    The thing I am concerned with this approach is any memory implications on the rpt? Any thoughts on this highly appreciated.
    Hi

    I created below custom code to capture response when the text that is required to check is not found.

    package CaptureResponseonError;

    import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;

    /**
    * @author unknown
    */
    public class Class implements
    com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {

    /**
    * Instances of this will be created using the no-arg constructor.
    */
    public Class() {
    }

    /**
    * For javadoc of ICustomCode2 and ITestExecutionServices interfaces, select 'Help Contents' in the
    * Help menu and select 'Extending Rational Performance Tester functionality' -> 'Extending test execution with custom code'
    */
    public String exec(ITestExecutionServices tes, String[] args) {
    String RegExpStr = "\"actionStatus\":\"(.*?)\"";
    String CheckText = new String("\"actionStatus\":\"PAYMENT_SUCCESSFULL\"");
    int i = 0;
    String CardBasedOnOccurence = null;
    Pattern pattern = Pattern.compile(RegExpStr,Pattern.DOTALL);

    Matcher matcher = pattern.matcher(args[0]);
    //tes.getTestLogManager().reportMessage( "Total " + matcher.groupCount());
    if (matcher.find())
    {
    if (CheckText.equals(matcher.group()))
    {
    tes.getTestLogManager().reportMessage("Response Passes");
    }
    else
    {
    tes.getTestLogManager().reportMessage("Response" + args[0]);
    }
    }
    else
    {
    tes.getTestLogManager().reportMessage("Response" + args[0]);

    }
    return null;

    }
    }

    This serves the purpose which I wanted. But wondering what are the implication of using this on memory and test running with huge of users.

    Thanks
    Shambu
  • RobertoFdez
    RobertoFdez
    50 Posts

    Re: Extract response on error setting

    ‏2012-05-31T08:36:38Z  
    Hi

    I created below custom code to capture response when the text that is required to check is not found.

    package CaptureResponseonError;

    import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;

    /**
    * @author unknown
    */
    public class Class implements
    com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {

    /**
    * Instances of this will be created using the no-arg constructor.
    */
    public Class() {
    }

    /**
    * For javadoc of ICustomCode2 and ITestExecutionServices interfaces, select 'Help Contents' in the
    * Help menu and select 'Extending Rational Performance Tester functionality' -> 'Extending test execution with custom code'
    */
    public String exec(ITestExecutionServices tes, String[] args) {
    String RegExpStr = "\"actionStatus\":\"(.*?)\"";
    String CheckText = new String("\"actionStatus\":\"PAYMENT_SUCCESSFULL\"");
    int i = 0;
    String CardBasedOnOccurence = null;
    Pattern pattern = Pattern.compile(RegExpStr,Pattern.DOTALL);

    Matcher matcher = pattern.matcher(args[0]);
    //tes.getTestLogManager().reportMessage( "Total " + matcher.groupCount());
    if (matcher.find())
    {
    if (CheckText.equals(matcher.group()))
    {
    tes.getTestLogManager().reportMessage("Response Passes");
    }
    else
    {
    tes.getTestLogManager().reportMessage("Response" + args[0]);
    }
    }
    else
    {
    tes.getTestLogManager().reportMessage("Response" + args[0]);

    }
    return null;

    }
    }

    This serves the purpose which I wanted. But wondering what are the implication of using this on memory and test running with huge of users.

    Thanks
    Shambu
    Well, in my experience this kind of operations are not very heavy compared with other operations I usually perform in custom code like connection to db and execution of queries. Have you tried with Verification Points?
  • SystemAdmin
    SystemAdmin
    5507 Posts

    Re: Extract response on error setting

    ‏2012-05-31T11:59:56Z  
    Well, in my experience this kind of operations are not very heavy compared with other operations I usually perform in custom code like connection to db and execution of queries. Have you tried with Verification Points?
    Thanks Roberto.

    That was reassuring.

    Yes, I did try the verification points, but there is no option with verification point to capture the response on failure. The option are more related to controlling the user, but not related with what happened to user response.
  • andyh
    andyh
    20 Posts

    Re: Extract response on error setting

    ‏2012-05-31T13:34:50Z  
    Thanks Roberto.

    That was reassuring.

    Yes, I did try the verification points, but there is no option with verification point to capture the response on failure. The option are more related to controlling the user, but not related with what happened to user response.
    You may want to try changing the Test Log levels in the Schedule. If you set the Log Level for 'Show Errors and Failures' to 'All' then a verification point failure should lead to the response being captured in the test log I believe.
    You may need to deselect 'Only sample information from a subset of users' to guarantee you get the response for any users that experience the failure.
  • petersda
    petersda
    376 Posts

    Re: Extract response on error setting

    ‏2012-06-04T19:00:35Z  
    • andyh
    • ‏2012-05-31T13:34:50Z
    You may want to try changing the Test Log levels in the Schedule. If you set the Log Level for 'Show Errors and Failures' to 'All' then a verification point failure should lead to the response being captured in the test log I believe.
    You may need to deselect 'Only sample information from a subset of users' to guarantee you get the response for any users that experience the failure.
    This is correct information and is the recommended way of getting your response content for the failing response.