How to loadtest the WebService using UnitTest and analyze the results ?
-
lundi 2 juillet 2012 15:56
Hi
I have a 7 WCF services which returns json reponse. I have created a unit test and in each UnitTest i have created 7 TestMethods to test those 7 WCF Services which belong to the same domain.
Later I have created a LoadTest and in the LoadTEst Wizard i have added those 7 TestMethods of my UnitTest.I have executed the load test and below are the results.
Load Pattern is :Initial User Count : 10
Maximum User Count : 60
Pattern : Step
Step Duration(seconds) : 60
Step Ramp Time(Seconds): 0
Step USer Count : 10
LoadTest Results:Name Scenario Total Tests Failed Tests (% of total) Avg. Test Time (sec)
GetUserInf LoadTestMetroUnitTest 452 0 (0) 7.70
SearchEmployee LoadTestMetroUnitTest 446 0(0) 6.24
GetEmployeeDetails LoadTestMetroUnitTest 495 0 (0) 3.59
GetChartDetails LoadTestMetroUnitTest 463 0 (0) 3.45
GetUserTaskPriviledge LoadTestMetroUnitTest 451 0 (0) 2.04
GetSystem LoadTestMetroUnitTest 484 0 (0) 1.89
GetHeadCount LoadTestMetroUnitTest 486 0 (0) 1.57What i would like to know is with the inital load of 10users does the loadtest tool apply 10*7 calls to the service which is one user hitting the 7 services at a time to the server and all the 10 users doing the same thing simultaneously ?
Does the load test pass the each test call to the service passed only after it received the response ? Can i save the response as a proof it waited till it got the response?
And Is the Load Test tool making async calls with the services?
What is the Number of Tests Indicate in the above LoadTest Results ?Ultimately i want to give statistics to my client as : what is the maximum number of users accessing each service at any given point of time ,what is the trasaction time and reponse time ?
Any help would be greatly appreciated.
Regards Krrishna
Toutes les réponses
-
mardi 3 juillet 2012 11:12
We would need more information about the test mix to answer all of your questions but I'll give it a shot here:
Q) 10users does the loadtest tool apply 10*7 calls to the service which...
A) No - the 10 virtual users will not make one call per test method rather it will call one test method based on the text mix. If the test mix is such that no service call gets more weight than the other, most services will get a single request, a few of them may be getting multiple concurrent requests but none of them would likely be getting all 10 of the requests
Q) Does the load test pass each test call to the service passed only after it received the response ? And Is the Load Test tool making async calls with the services?
A) Not sure I understand the question Depends on whether your WCF services supports Asynch service operations .
Q) Can i save the response as a proof it waited till it got the response?
A) You would have to use a plugin or write some code to persist all the responses. Frankly I am not sure you would want to
Q) Ultimately i want to give statistics to my client as : what is the maximum number of users accessing each service at any given point of time ,what is the trasaction time and reponse time ?
A) Opinion really. I woudl apply a step load pattern to each of the service operations in isolation so that you can say that you can expect a given response time for a given service operation under a given load (base line the ideal). Then I would set up another step load pattern with all the operations in the mix taking care that the test mix reflected reality (meaning if you call GetUserInf 3X more often than GetSystem the test mix is configured to account for this) Then you can say given a user count of X you can expect these response times and given a user count of Y you can expect these response times and so on
Tim
- Marqué comme réponse Krrisshna mercredi 4 juillet 2012 02:02
- Non marqué comme réponse Krrisshna mercredi 4 juillet 2012 14:50
- Proposé comme réponse Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator mardi 10 juillet 2012 10:37
- Non proposé comme réponse Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator mercredi 11 juillet 2012 01:27
-
mercredi 4 juillet 2012 03:07
The webservice supports asynch web operations.So does the Loadtest tool checks the response from the async web services ?
And How does the totaltests in loadtestresults is calculated ?When i ran a test with 10 users the WCF service has been called 100's of times .I woulld like know how did it arrive at this count ? Will it fire the requests on a regular interval ?
Can i control the number of times a user calls the web service at a given specified time ?
Regards Krrishna
- Modifié Krrisshna mercredi 4 juillet 2012 14:50
-
jeudi 5 juillet 2012 15:07
can you post a sample unit test? It might help explain how the load test is handling the asynch calls.
How is total tests calculated: The way you have things set up there is no calculation. Say you are at your max load of 60 virtual users. The load test will execute 60 tests concurrently. As soon as one test ends another will start (assuming no think times) and this will happen for the durration of the load test so the number of tests really depends on how fast your service can respond.
If you want to control the number of times a user calls the web service use set the test mix model to "based on user pace"
http://msdn.microsoft.com/en-us/library/dd997826
Tim
-
lundi 9 juillet 2012 04:15Hi Tim
Below is one the UnitTest method.I have 6 other unit testmethods like this.
[TestMethod]
public void GetempInfo()
{
string tmr = string.Empty;
TestContext.BeginTimer(tmr);
string str = GetResponse("http://HeadCntWebSrvr:80/HdCntService.svc/GetemployeeInfo?empnbr=90453481");
TestContext.EndTimer(tmr);
if (string.IsNullOrEmpty(str))
{
Assert.Fail("Empty or No Response for the given endpoint ");
}
else
{
//global::System.Windows.Forms.MessageBox.Show(str);
Assert.AreEqual(str, str, "Successfull");
//Assert.Inconclusive("Successfull");
}
}Regards Krrishna
-
lundi 9 juillet 2012 14:30Can you include the GetRespnse(URI) method? I am almost certain you are calling the service asynch, then waiting for the response based on your description but can't prove it with the code
Tim
-
mardi 10 juillet 2012 04:57
Sorry,My bad.Here is the complete code.
public static string GetResponse(string endPoint)
{
HttpWebRequest request = CreateWebRequest(endPoint);
// Assign the credentials of the logged in user or the user being impersonated.
request.Credentials = CredentialCache.DefaultCredentials;using ( var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;if (response.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("POST failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}// grab the response
using (var responseStream = response.GetResponseStream())
{
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}return responseValue;
}
}Regards Krrishna
-
mardi 10 juillet 2012 09:09
Sometimes all my test cases are passed but the Test Results stillshows the below message in "Tables" tab -> "Thresholds" section:
00:02:35 WINServer01RP PhysicalDisk % Idle Time 0 C: The value 1.444987 is less than the critical threshold value of 20.
Can this be ignored?
Regards Krrishna
- Modifié Krrisshna mardi 10 juillet 2012 09:49
-
mardi 10 juillet 2012 10:36Modérateur
Hi Krrisshna,
Sorry for my delay.
If possible, one thread for one issue, you could post a new thread for a new issue, in this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well.
00:02:35 WINServer01RP PhysicalDisk % Idle Time 0 C: The value 1.444987 is less than the critical threshold value of 20.
About this new issue, I think Captain Fan and Tim shared us the detailed information in this thread about it.
The load test just use the certain counters to collect the specific data, it doesn't have any effect on load test results.
PhysicalDisk\% Idle Time: This measures the percentage of time the disk was idle during the sample interval. If this counter falls below 20 percent, the disk system is saturated. You may consider replacing the current disk system with a faster disk system.
If you are generating the load you want you don't need to worry about the disk usage on the controller and agents. Be aware that writing this info to a file will limit the number of virtual users your rig can simulate. It would be more of a concern if the web server had the High disk usage, this would indicate a bottleneck on the web server.
Reference:
Analyzing Threshold Rule Violations in Load Tests Using the Load Test Analyzer. Hope it could help.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
-
mardi 10 juillet 2012 13:52
Because you are calling request.GetResponse() you are making the call synchronously. To be asynch you would call request.BeginGetResponse() but then you would have to worry about completeing the callback or timing out before the testmethod completes. This does prove that the unit test and therefore load test waits for the response to complete before starting another test.
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx
Tim
- Marqué comme réponse Krrisshna mardi 10 juillet 2012 14:41

