Exception when run load test use visual studio.

来源:互联网 发布:csol三米优化刀 编辑:程序博客网 时间:2024/04/30 01:47

  Sometimes you can single run the performance test pass, but when add them to load test and run, will get exception, this topic will list some exception and give the solution.

 

1. Extraction Rule  ExtractHiddenFields  No hidden fields were found in the response. 

This because some times the hiden filed that request1 returned response will lost, can change another way to extract the field and used it in request2, anyway you  need to make sure there's no extract rule in your code, and also some times you don't need to dynamic read the response, just debug and hard code some  this.Context value for some parameter that value won't change when you every run, likethis.Context["QueryStringParam8.wctx"].ToString(), the extract rule actually will get part of the request1's reponse content string, it's always the same everytime run.

 

privatevoid request1_PostRequest(object sender, PostRequestEventArgs e)

{

e.WebTest.Context["$HIDDEN1.__VIEWSTATE"] = "";

e.WebTest.Context["$HIDDEN1.__EVENTVALIDATION"] = "";

e.WebTest.Context["$HIDDEN1.__db"] = "";

if (e.ResponseExists)

{

e.WebTest.Context["nextRequestEncoding"] = e.Response.CharacterSet;

foreach (HtmlTag input in e.Response.HtmlDocument.GetFilteredHtmlTags("input"))

{

e.WebTest.Context["$HIDDEN1." + input.GetAttributeValueAsString("name")] = input.GetAttributeValueAsString("value");

}

}

else

 

{

thrownewException(string.Format("The requested url {0} does not response!", e.Request.Url));

}

}


////////////////////

WebTestRequest request1 = newWebTestRequest((this.Context["WebServer1"].ToString() + "/main.aspx"));

request1.ExpectedResponseUrl = @"https://adfs.cattest.redmond.corp.microsoft.com/adfs/ls/?wa=wsignin1.0&wtrealm=https%3a%2f%2ftest004.cattest.redmond.corp.microsoft.com%3a5443%2f&wctx=rm%3d1%26id%3d7dc2e961-d9ad-44e3-81a9-781510fd2e39%26ru%3dhttps%253a%252f%252ftest004.cattest.redmond.corp.microsoft.com%253a5443%252fmain.aspx&wct=2013-07-30T05%3a12%3a00Z&wauth=urn%3aoasis%3anames%3atc%3aSAML%3a1.0%3aam%3apassword";

//ExtractHiddenFields extractionRule1 = new ExtractHiddenFields();

 

//extractionRule1.Required = true;

 

//extractionRule1.HtmlDecode = true;

 

//extractionRule1.ContextParameterName = "1";

 

//request1.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule1.Extract);

request1.PostRequest += newEventHandler<PostRequestEventArgs>(request1_PostRequest);

 

ExtractText extractionRule2 = newExtractText();

extractionRule2.StartsWith = "&amp;wctx=";

extractionRule2.EndsWith = "&";

extractionRule2.Index = 0;

extractionRule2.IgnoreCase = false;

extractionRule2.UseRegularExpression = false;

extractionRule2.HtmlDecode = true;

extractionRule2.Required = false;

extractionRule2.ContextParameterName = "QueryStringParam8.wctx";

request1.ExtractValues += newEventHandler<ExtractionEventArgs>(extractionRule2.Extract);

ExtractText extractionRule3 = newExtractText();

extractionRule3.StartsWith = "&amp;wct=";

extractionRule3.EndsWith = "&";

extractionRule3.Index = 0;

extractionRule3.IgnoreCase = false;

extractionRule3.UseRegularExpression = false;

extractionRule3.HtmlDecode = true;

extractionRule3.Required = false;

extractionRule3.ContextParameterName = "QueryStringParam9.wct";

request1.ExtractValues += newEventHandler<ExtractionEventArgs>(extractionRule3.Extract);

yieldreturn request1;

request1 = null;

 

 

WebTestRequest request2 = newWebTestRequest((this.Context["WebServer2"].ToString() + "/adfs/ls/"));

request2.Method = "POST";

request2.Headers.Add(newWebTestRequestHeader("Referer", (this.Context["WebServer2"].ToString()

+ ("/adfs/ls/?wa=wsignin1.0&wtrealm="

 

+ (this.Context["WebServer3"].ToString() + "%2f&wctx=rm%3d1%26id%3d7dc2e961-d9ad-44e3-81a9-781510fd2e39%26ru%3dhttps%253a%252" +

"f%252ftest004.cattest.redmond.corp.microsoft.com%253a5443%252fmain.aspx&wct=2013" +

"-07-30T05%3a12%3a00Z&wauth=urn%3aoasis%3anames%3atc%3aSAML%3a1.0%3aam%3apassword" +

"")))));

request2.QueryStringParameters.Add("wa","wsignin1.0",false,false);

request2.QueryStringParameters.Add("wtrealm", (this.Context["WebServer3"].ToString() + "%2f"),false,false);

request2.QueryStringParameters.Add("wctx",this.Context["QueryStringParam8.wctx"].ToString(),false,false);

request2.QueryStringParameters.Add("wct",this.Context["QueryStringParam9.wct"].ToString(),false,false);

request2.QueryStringParameters.Add("wauth","urn%3aoasis%3anames%3atc%3aSAML%3a1.0%3aam%3apassword",false,false);

FormPostHttpBody request2Body = newFormPostHttpBody();

request2Body.FormPostParameters.Add("__VIEWSTATE",this.Context["$HIDDEN1.__VIEWSTATE"].ToString());

request2Body.FormPostParameters.Add("__EVENTVALIDATION",this.Context["$HIDDEN1.__EVENTVALIDATION"].ToString());

request2Body.FormPostParameters.Add("__db",this.Context["$HIDDEN1.__db"].ToString());

request2Body.FormPostParameters.Add("ctl00$ContentPlaceHolder1$PassiveIdentityProvidersDropDownList","");

request2Body.FormPostParameters.Add("ctl00$ContentPlaceHolder1$PassiveSignInButton","Continue to Sign In");

 

2.

fffaultstring>Microsoft.Crm.CrmException: INVALID_WRPC_TOKEN: Validate WRPC Token: WRPCTokenState=Invalid, TOKEN_EXPIRY=4320, IGNORE_TOKEN=False, TOKEN_KEY=aoKRQfjUEeKYSDxKkuEPMhFIUwoBdTv/zf9ENFPrhU6oepFBffE3ASKqfHsbhHOk at Microsoft.Crm.Application.Security.WrpcContext.ValidateTokenState() at Microsoft.Crm.Application.Security.WrpcContext.ValidateToken() at Microsoft.Crm.Application.WebServices.AppWebService..ctor(Boolean wrpcCheck) ---> INVALID_WRPC_TOKEN: Validate WRPC Token: WRPCTokenState=Invalid, TOKEN_EXPIRY=4320, IGNORE_TOKEN=False, TOKEN_KEY=aoKRQfjUEeKYSDxKkuEPMhFIUwoBdTv/zf9ENFPrhU6oepFBffE3ASKqfHsbhHOk</faultstring>
<faultactor>https://perf02.catperf.microsoft.com:5443/AppWebServices/CustomerService.asmx</faultactor>
 


request33.Headers.Add(newWebTestRequestHeader("CRMWRPCToken", token));

request33.Headers.Add(newWebTestRequestHeader("CRMWRPCTokenTimeStamp", timeStamp));
 
This becuause you didn't input the right token when call the service. currently, 1 walk around is use fiddler to catch the request and hard code the token and timeStamp, but the token will change, if you change another machine to run test code or time out of 24 hour,


Another walk around:

http://rajeevpentyala.wordpress.com/tag/tocken-check/