开发者

Getting stats on cookieless session page using VS2008 load testing feature

I'm load testing a web page using visual studio load testing tool, but I have problems displaying results. The problem is cookieless sessi开发者_开发问答on. Everytime new user comes to a page, page URLL changes and I'm not able to calculate average page response time. What can be done about it?


We moved the cookie to the querystring.

Before that I wrote a case insensitive url validation event handler that ignores the session component of the Url. The one below only removes case sensitivity.

class QueryLessCaseInsensitiveValidateResponseUrl : ValidateResponseUrl
{
    public override void Validate(object sender, ValidationEventArgs e)
    {
        Uri uri;
        string uriString = string.IsNullOrEmpty(e.Request.ExpectedResponseUrl) ? e.Request.Url : e.Request.ExpectedResponseUrl;
        if (!Uri.TryCreate(e.Request.Url, UriKind.Absolute, out uri))
        {
            e.Message = "The request URL could not be parsed";
            e.IsValid = false;
        }
        else
        {
            Uri uri2;
            string leftPart = uri.GetLeftPart(UriPartial.Path);
            if (!Uri.TryCreate(uriString, UriKind.Absolute, out uri2))
            {
                e.Message = "The request URL could not be parsed";
                e.IsValid = false;
            }
            else
            {
                uriString = uri2.GetLeftPart(UriPartial.Path);
                ////this removes the query string
                //uriString.Substring(0, uriString.Length - uri2.Query.Length);
                Uri uritemp = new Uri(uriString);
                if (uritemp.Query.Length > 0)
                {
                    string fred = "There is a problem";
                }
                //changed to ignore case
                if (string.Equals(leftPart, uriString, StringComparison.OrdinalIgnoreCase))
                {
                    e.IsValid = true;
                }
                else
                {
                    e.Message = string.Format("The value of the ExpectedResponseUrl property '{0}' does not equal the actual response URL '{1}'. QueryString parameters were ignored.", new object[] { uriString, leftPart });
                    e.IsValid = false;
                }
            }
        }
    }
}

Called by

public EventHandler<ValidationEventArgs> AddUrlValidationEventHandler(WebTestContext context, WebTest webTest)
{
    EventHandler<ValidationEventArgs> urlValidationRuleEventHandler = null;
    // Initialize validation rules that apply to all requests in the WebTest
    if ((context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.Low))
    {
        QueryLessCaseInsensitiveValidateResponseUrl validationRule1 = new QueryLessCaseInsensitiveValidateResponseUrl();
        urlValidationRuleEventHandler = new EventHandler<ValidationEventArgs>(validationRule1.Validate);
        webTest.ValidateResponse += urlValidationRuleEventHandler;
    }
    return urlValidationRuleEventHandler;

}

Now all I need to do is add

    //add case insensitive url validation for all requests
    urlValidationRuleEventHandler = common.AddUrlValidationEventHandler(this.Context, this);

into a web test to get case insensitive calling. Be aware that this code contains the following innappropriate line

string fred = "There is a problem";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜