SQL Server Reports are one of the key components in many of the applications and when we do Load test on an application we also make sure that the SQL Server is also capable of delivering the report in time on Load Conditions during concurrent scenarios. This Article will help to create a Web Test using Visual Studio Test Edition and and run the load test with.
Introduction
VSTS Test Edition provide different tests. One of the test framework is Web Test which will help us to record the tests and run that. But to do web test on a report the possiblity is less becuase of the limitations of report vieiwer becuase of AJAX report rending in MHTML. Say for example if the load test scenario is to execute the report in some other format it is not possible to create web test.
Web Test
To create Web Test we will use URL/Query based Report Rendering which will avoid the above limitations. You can used different commands in Query string you can get these details from Microsoft Site and here is the web test code
public class SimpleReportTest : WebTest
{
public SimpleReportTest()
{
this.PreAuthenticate = true;
//Enter your credenatials
this.UserName = "userid";
this.Password = "pwd";
}
public override IEnumerator<WebTestRequest> GetRequestEnumerator()
{
WebTestRequest request = new WebTestRequest("http://SSRSServer/ReportServer/Pages/ReportViewer.aspx");
WebTestRequestHeaderCollection headers = request.Headers;
// First remove all existing headers.
headers.Clear();
headers.Add("Cookie", "(automatic)");
// Before each request, clear all existing parameters.
request.QueryStringParameters.Clear();
request.QueryStringParameters.Add("rc:Toolbar", "False");
request.QueryStringParameters.Add("rs:Command", "Render");
// Choose to set Think Time to 20 seconds.
request.ThinkTime = 20;
//Report Name and Parameters
request.QueryStringParameters.Add("", "{ReportPath}", true, false);
request.QueryStringParameters.Add("{PARAM1}", "110106");
yield return request;
}
}
In above web test you just need to modify the highlighted details and create a Load Test by adding this web test as scenario in Visual Studio Test Edition. Many scenarios like export and other commands can be added to the request to do Load Test on SSRS Report.
Conclusion
For more information on how to create Load Test from Web Test Go To Visual Studi Test Edition Site or i will publish few more posts on this.