Exception when run load test use visual studio.
2013-08-02 13:00
344 查看
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 =
"&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 =
"&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/
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 =
"&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 =
"&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/
相关文章推荐
- Open question when load testing web site use Visual studio.
- visual studio load test usage and notice
- Visual Studio Team Test 2010 Load Agent支持 64 位测试运行了 !
- Visual Studio Team Test 2010 Load Agent支持 64 位测试运行了 !
- Microsoft Visual Studio 2010 Load Test Feature Pack安装排错
- Result analysis on Loading test use visual studio.
- How to Use the Visual Studio .NET Application Center Test
- If you have multiple web application run how to determin which is yours when you debug using visual studio 2008?
- Hand to hand teach you load testing web site use Visual studio.
- 四、Load test your app(Visual Studio Online负载测试)
- 每次打开excel弹出要安装Microsoft.VisualStudio.QualityTools.LoadTestExcelAddIn.vsto的窗口
- 在使用Microsoft Visual Studio Test Controller 2010进行测试时,报如下错误: System.DllNotFoundException: 无法加载 DLL“Microsoft.VisualStudio.QualityTools.RecorderBarBHO100.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。
- When should I create threads and when should I use thread pool to run work items asynchronously?
- 简易扩展Visual Studio UnitTesting支持TestMethodCase
- use Visual studio2012 developing kernel driver monitor thread creation on Windows8
- 演练:使用 Visual Studio Team Test 进行单元测试
- Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
- Microsoft.VisualStudio.Dialogs.DialogInitializationException 问题解决
- The XML Litmus Test Understanding When and Why to Use XML
- Visaul Studio 2008(TeamSuit/Professional/Development/TFS/TestLoad)全系列下载链接