Internal For Loop not working - Load Test
-
Wednesday, May 30, 2012 4:37 AM
I have a coded webtest where i have defined a For Loop for a script that should iterate for 'n' iterations. When i add this to my Load Test and run, the script does not run for the iterations defined.
Scenario:
abc is a script that should run for 90 iterations (defined in Run Settings --> Test Iterations)
xyz is a script that should run for 90 x 10 iterations (defined in Run Settings --> Test Iterations & 10 is the For loop defined)
Script is as follows:public CountingLoopRule GetConditionalRule()
{
CountingLoopRule conditionalRule1 = new CountingLoopRule();
conditionalRule1.ContextParameterName = "Loop Counter";
conditionalRule1.IterationsCount = 10D;
return conditionalRule1;
}foreach (WebTestRequest r in IncludeWebTest(new abc(), true)) { yield return r; }
bResult[iResultIndex] = main.bMainResult;this.BeginLoop(conditionalRule1, maxIterations1, advanceDataCursors1);
int sInt = 1;
for (; this.ExecuteConditionalRule(conditionalRule1); )
{
fStreamWriter.WriteLine("Script Loop" + sInt.ToString());
foreach (WebTestRequest r in IncludeWebTest(new xyz(), true)) { yield return r; }
bResult[iResultIndex] = main.bMainResult;
sInt++;
}
fStreamWriter.Close();
fStreamWriter.Dispose();
this.EndLoop(conditionalRule1);
When i execute my load test, VSTS will perform the test only for about 700 iterations. Can anyone let me know why this happens. Is this because we are kind of straining the Load Test Engine??
Thanks! Vish
- Edited by VishKi Wednesday, May 30, 2012 4:37 AM
All Replies
-
Thursday, May 31, 2012 6:16 AM
The load test iterations are controlled by the property "Number of test iterations" if "use test iterations" is set to true. Otherwise, it runs for the specified duration. So if your test runs everytime for 700 iterations, it could be becuase you have set the number of iterations to 700. Otherwise, it will run for as many iteartions as it can complete within the duration.
Thanks,
Anuj
http://www.anujchaudhary.com
-
Monday, June 04, 2012 5:02 AM
Nope, my test is not set to run for 700 iterations.
My LoadTest has the following settings % of new users = 100, Max Test Iterations = 0, Use Test Iterations = True, Test Iterations = 90 (90 because the For Loop has a Loop Counter set to 10)
Thanks! Vish
-
Tuesday, June 05, 2012 2:40 AMModerator
Hi Vish,
Thank you for posting in the MSDN forum.
Just to make this issue clearly, you set Test Iterations = 90 in your load test, when you running your load test, it runs for 90 times, but the web test runs for 700 times, since you use the Loop in your web test, so the correct result is that the web test should run for 900 times. Am I right? If you run your web test for one time, does your web test run for 10 times?
To repro this issue, I could create a simple coded web test, but I’m not sure where to insert this Loop, so it will be better, you could share us a simple sample, we try to check it in my computer.
Please attach your web test, you can upload it to the sky driver, and then share the download link in your post.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
-
Wednesday, June 06, 2012 9:27 AM
Yes Jack, my webtest should run for 900 times . If i run my webtest for one time, it runs for the 10 iterations as expected.
And related to sharing of my webtest, as i have communicated to you on e-mail that ours is a intranet application. So even if i share my webtest, you wont be able to run it :(
I tried the following code, still to no avail
int loopcount = 10;
for (int i = 1; i < loopcount; i++)
{
foreach (WebTestRequest r in IncludeWebTest(new mftt(), true)) { yield return r; }
}
Thanks! Vish
-
Thursday, June 07, 2012 6:08 AMModerator
Hi Vish,
Sorry for my delay.
Maybe you could share us your screen shots like the following results.
Actually we could add the Loop in web test, open your web test, and right click your web test->Add Loop…->Counting Loop, then set the Number of Iterations “3”, then I could get the web test like screen shot 1.
Then I add it to the load test, like your settings, I set Test Iterations = 20, then I get the result like the screen shot 2, I generated the web test to coded Web test, it has the same result in the load test. So as my understanding, the Loop just used to the web test, it doesn’t impact the load test Iterations.
Maybe it is different from your coded web test, since we couldn’t repro this issue. Maybe you could share us a simple similar web test for a simple site, then share it to us.
If you couldn’t share it, I’m afraid that I don’t have the really solution, but you submit this feedback to Microsoft Connect feedback portal: http://connect.microsoft.com, Microsoft engineers will evaluate them seriously.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
- Proposed As Answer by Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator Monday, June 11, 2012 4:42 AM
- Unproposed As Answer by VishKi Tuesday, June 12, 2012 5:10 AM
-
Tuesday, June 12, 2012 5:19 AM
Sorry for the delay in posting the screenshots,
If you see the screen shot, you can see that the load test ran for 546 iterations only (it should have run for 60 Iterations x 10 Loop). I dont have any complex Loops/conditions in my project. Its a custom built framework which works as follows:
1. Define a user name in abc.cs which in turn a file xyz.cs
2. xyz.cs has the scripts as well as the target scripts that are defined like this:
foreach (WebTestRequest r in IncludeWebTest(new ordercreate(), true)) { yield return r; }
int loopcount = 10;
for (int i = 1; i < loopcount; i++)
{
foreach (WebTestRequest r in IncludeWebTest(new mftt(), true)) { yield return r; }
}
3. the abc.cs file is loaded to the loadtest template & executed
If i run my test for a single user (1 * 10) i don't face any problems at all. The problem i face is only when doing the LoadTest
Thanks! Vish
- Edited by VishKi Tuesday, June 12, 2012 5:20 AM
-
Tuesday, June 12, 2012 8:10 AMModerator
Hi Vish,
Glad to receive your reply.
If possible, I sincerely suggest you send me this sample, you could send it to jackzhai at Hotmail dot com, since it is hard for us to repro this issue and check the load test result.
As my previous reply, if you couldn’t share it, I’m afraid that this issue requires more troubleshooting and I can’t reproduce this scenario on my machine. If it is urgent issue, I suggest you to contact a Professional Support Service at http://support.microsoft.com/common/international.aspx?RDPATH=gp;en-us;offerprophone to gain more support on this case.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
-
Tuesday, June 12, 2012 3:04 PM
We had MS guys visit our company for training on this tool last year and when we were doing the same scenario, VSTS crashed for once, yet there was no solution for this issue :)
So i thought if any one of the MS guys in this forum can help me, i posted it here.
Thanks! Vish
-
Wednesday, June 13, 2012 3:08 AMModerator
Hi Vish,
Glad to receive your reply.J
We had MS guys visit our company for training on this tool last year and when we were doing the same scenario, VSTS crashed for once, yet there was no solution for this issue :)
Could you send us a sample? If not, would you mind submitting this feedback to Microsoft Connect feedback portal: http://connect.microsoft.com?
About this issue, one workaround is that you could create a load test without the Loops, for example, set the iterations to the value, and then get the information for your web test.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us

