Commit f9846f3e f9846f3e3a09918ed331b35154150bda191ed736 by Christian Gerdes

New features on the Think Time Emulator 10/190 plugin

- Can now modify the min and max percentages
- Can now provide regex to run on only matching test names or scenario names
1 parent 23bf58af
...@@ -110,16 +110,30 @@ namespace LIL_VSTT_Plugins ...@@ -110,16 +110,30 @@ namespace LIL_VSTT_Plugins
110 [DisplayName("Think Time Emulator 10/190"), Description("Sets a context parameter named ThinkTime in each starting test to a random value between 10%-190% of the specified value.")] 110 [DisplayName("Think Time Emulator 10/190"), Description("Sets a context parameter named ThinkTime in each starting test to a random value between 10%-190% of the specified value.")]
111 public class ThinkTimeEmulator10190 : ILoadTestPlugin 111 public class ThinkTimeEmulator10190 : ILoadTestPlugin
112 { 112 {
113 [DisplayName("Think Time"), DefaultValue(0), Description("The Think Time to be used seconds. Default is 0.")] 113 [DisplayName("ThinkTime"), DefaultValue(0), Description("The Think Time to be used seconds. Default is 0.")]
114 public int ThinkTime { get; set; } 114 public int ThinkTime { get; set; }
115 [DisplayName("Minimum"), DefaultValue(10), Description("Percentage of ThinkTime to be used as the minimum value")]
116 public int Min { get; set; }
117 [DisplayName("Maximum"), DefaultValue(190), Description("Percentage of ThinkTime to be used as the maximum value")]
118 public int Max { get; set; }
119 [DisplayName("Only on Tests matching"), DefaultValue(""), Description("Regular expression matching only the tests you want this plugin instance to work on. If it does not match the test name, the plugin instance will not set the ThinkTime")]
120 public string RegExTestName { get; set; }
121 [DisplayName("Only on Scenarios matching"), DefaultValue(""), Description("Regular expression matching only the scenarios you want this plugin instance to work on. If it does not match the scenario name, the plugin instance will not set the ThinkTime")]
122 public string RegExScenarioName { get; set; }
115 123
116 //store the load test object. 124 //store the load test object.
117 LoadTest mLoadTest; 125 LoadTest mLoadTest;
118 Random rnd = new Random(); 126 Random rnd = new Random();
127 Regex rxTestName = null;
128 Regex rxScenarioName = null;
119 129
120 public void Initialize(LoadTest loadTest) 130 public void Initialize(LoadTest loadTest)
121 { 131 {
122 mLoadTest = loadTest; 132 mLoadTest = loadTest;
133 if(!String.IsNullOrEmpty(RegExTestName))
134 rxTestName = new Regex(RegExTestName);
135 if (!String.IsNullOrEmpty(RegExScenarioName))
136 rxScenarioName = new Regex(RegExScenarioName);
123 137
124 //connect to the TestStarting event. 138 //connect to the TestStarting event.
125 mLoadTest.TestStarting += new EventHandler<TestStartingEventArgs>(mLoadTest_TestStarting); 139 mLoadTest.TestStarting += new EventHandler<TestStartingEventArgs>(mLoadTest_TestStarting);
...@@ -128,10 +142,16 @@ namespace LIL_VSTT_Plugins ...@@ -128,10 +142,16 @@ namespace LIL_VSTT_Plugins
128 142
129 void mLoadTest_TestStarting(object sender, TestStartingEventArgs e) 143 void mLoadTest_TestStarting(object sender, TestStartingEventArgs e)
130 { 144 {
145 if (rxTestName != null && rxTestName.IsMatch(e.TestName) != true) return;
146 if (rxScenarioName != null && rxScenarioName.IsMatch(e.ScenarioName) != true) return;
147
131 // Set the think time parameter in the tests context to a new value 148 // Set the think time parameter in the tests context to a new value
132 int min = ThinkTime/10; 149 double tt = ThinkTime;
133 int max = ThinkTime*2 - min; 150 double min = Min / 100d;
134 e.TestContextProperties.Add("ThinkTime", rnd.Next(min, max)); 151 min = tt * min;
152 double max = Max / 100d;
153 max = tt * max;
154 e.TestContextProperties.Add("ThinkTime", rnd.Next((int)min, (int)max));
135 } 155 }
136 } 156 }
137 157
......
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <LoadTest Name="LoadTest1" Description="" Owner="" storage="c:\users\wflg\source\repos\vstt-plugins\testproject1\loadtest1.loadtest" Priority="2147483647" Enabled="true" CssProjectStructure="" CssIteration="" DeploymentItemsEditable="" WorkItemIds="" TraceLevel="None" CurrentRunConfig="Run Settings1" Id="0e35c1c4-9214-4fc4-907f-42e11a00845a" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> 2 <LoadTest Name="LoadTest1" Description="" Owner="" storage="d:\git\vstt-plugins\testproject1\loadtest1.loadtest" Priority="2147483647" Enabled="true" CssProjectStructure="" CssIteration="" DeploymentItemsEditable="" WorkItemIds="" TraceLevel="None" CurrentRunConfig="Run Settings1" Id="0e35c1c4-9214-4fc4-907f-42e11a00845a" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
3 <Scenarios> 3 <Scenarios>
4 <Scenario Name="Copy of Scenario1" DelayBetweenIterations="30" PercentNewUsers="0" IPSwitching="true" TestMixType="PercentageOfUsersRunning" ApplyDistributionToPacingDelay="true" MaxTestIterations="0" DisableDuringWarmup="false" DelayStartTime="0" AllowedAgents="">
5 <ThinkProfile Value="0.2" Pattern="Off" />
6 <LoadProfile Pattern="Constant" InitialUsers="2" />
7 <TestMix>
8 <TestProfile Name="WebTest7 - Copy" Path="webtest7 - copy.webtest" Id="da8233d7-4410-4404-b5f9-76bdf9cf36f4" Percentage="50" Type="Microsoft.VisualStudio.TestTools.WebStress.DeclarativeWebTestElement, Microsoft.VisualStudio.QualityTools.LoadTest, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
9 <TestProfile Name="WebTest7" Path="webtest7.webtest" Id="b81f6de6-5ea8-4211-ac7b-3c0272942501" Percentage="50" Type="Microsoft.VisualStudio.TestTools.WebStress.DeclarativeWebTestElement, Microsoft.VisualStudio.QualityTools.LoadTest, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
10 </TestMix>
11 <BrowserMix>
12 <BrowserProfile Percentage="100">
13 <Browser Name="Internet Explorer 11.0" MaxConnections="6">
14 <Headers>
15 <Header Name="User-Agent" Value="Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko" />
16 <Header Name="Accept" Value="*/*" />
17 <Header Name="Accept-Language" Value="{{$IEAcceptLanguage}}" />
18 <Header Name="Accept-Encoding" Value="GZIP" />
19 </Headers>
20 </Browser>
21 </BrowserProfile>
22 </BrowserMix>
23 <NetworkMix>
24 <NetworkProfile Percentage="100">
25 <Network Name="LAN" BandwidthInKbps="1000000" NetworkProfileConfigurationXml="&lt;Emulation&gt;&lt;VirtualChannel name=&quot;defaultChannel&quot;&gt;&lt;FilterList/&gt;&lt;VirtualLink instances=&quot;1&quot; name=&quot;defaultLink&quot;&gt;&lt;LinkRule dir=&quot;upstream&quot;&gt;&lt;Bandwidth&gt;&lt;Speed unit=&quot;kbps&quot;&gt;1000000&lt;/Speed&gt;&lt;/Bandwidth&gt;&lt;/LinkRule&gt;&lt;LinkRule dir=&quot;downstream&quot;&gt;&lt;Bandwidth&gt;&lt;Speed unit=&quot;kbps&quot;&gt;1000000&lt;/Speed&gt;&lt;/Bandwidth&gt;&lt;/LinkRule&gt;&lt;/VirtualLink&gt;&lt;/VirtualChannel&gt;&lt;/Emulation&gt;" />
26 </NetworkProfile>
27 </NetworkMix>
28 </Scenario>
4 <Scenario Name="Scenario1" DelayBetweenIterations="30" PercentNewUsers="0" IPSwitching="true" TestMixType="PercentageOfUsersRunning" ApplyDistributionToPacingDelay="true" MaxTestIterations="0" DisableDuringWarmup="false" DelayStartTime="0" AllowedAgents=""> 29 <Scenario Name="Scenario1" DelayBetweenIterations="30" PercentNewUsers="0" IPSwitching="true" TestMixType="PercentageOfUsersRunning" ApplyDistributionToPacingDelay="true" MaxTestIterations="0" DisableDuringWarmup="false" DelayStartTime="0" AllowedAgents="">
5 <ThinkProfile Value="0.2" Pattern="NormalDistribution" /> 30 <ThinkProfile Value="0.2" Pattern="Off" />
6 <LoadProfile Pattern="Constant" InitialUsers="2" /> 31 <LoadProfile Pattern="Constant" InitialUsers="2" />
7 <TestMix> 32 <TestMix>
8 <TestProfile Name="WebTest8" Path="webtest8.webtest" Id="bac430ba-6ffc-4989-a29b-d9425412a248" Percentage="100" Type="Microsoft.VisualStudio.TestTools.WebStress.DeclarativeWebTestElement, Microsoft.VisualStudio.QualityTools.LoadTest, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 33 <TestProfile Name="WebTest7 - Copy" Path="webtest7 - copy.webtest" Id="da8233d7-4410-4404-b5f9-76bdf9cf36f4" Percentage="50" Type="Microsoft.VisualStudio.TestTools.WebStress.DeclarativeWebTestElement, Microsoft.VisualStudio.QualityTools.LoadTest, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
34 <TestProfile Name="WebTest7" Path="webtest7.webtest" Id="b81f6de6-5ea8-4211-ac7b-3c0272942501" Percentage="50" Type="Microsoft.VisualStudio.TestTools.WebStress.DeclarativeWebTestElement, Microsoft.VisualStudio.QualityTools.LoadTest, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
9 </TestMix> 35 </TestMix>
10 <BrowserMix> 36 <BrowserMix>
11 <BrowserProfile Percentage="100"> 37 <BrowserProfile Percentage="100">
...@@ -416,7 +442,7 @@ ...@@ -416,7 +442,7 @@
416 </CounterSet> 442 </CounterSet>
417 </CounterSets> 443 </CounterSets>
418 <RunConfigurations> 444 <RunConfigurations>
419 <RunConfiguration Name="Run Settings1" Description="" ResultsStoreType="Database" TimingDetailsStorage="AllIndividualDetails" SaveTestLogsOnError="true" SaveTestLogsFrequency="1" MaxErrorDetails="200" MaxErrorsPerType="1000" MaxThresholdViolations="1000" MaxRequestUrlsReported="1000" UseTestIterations="true" RunDuration="600" WarmupTime="0" CoolDownTime="0" TestIterations="8" WebTestConnectionModel="ConnectionPerUser" WebTestConnectionPoolSize="50" SampleRate="5" ValidationLevel="High" SqlTracingConnectString="" SqlTracingConnectStringDisplayValue="" SqlTracingDirectory="" SqlTracingEnabled="false" SqlTracingFileCount="2" SqlTracingRolloverEnabled="true" SqlTracingMinimumDuration="500" RunUnitTestsInAppDomain="true" CoreCount="0" UseMultipleIPs="false" TestAgentConfiguration="Default" AgentDiagnosticsLevel="Warning"> 445 <RunConfiguration Name="Run Settings1" Description="" ResultsStoreType="Database" TimingDetailsStorage="AllIndividualDetails" SaveTestLogsOnError="true" SaveTestLogsFrequency="1" MaxErrorDetails="200" MaxErrorsPerType="1000" MaxThresholdViolations="1000" MaxRequestUrlsReported="1000" UseTestIterations="true" RunDuration="600" WarmupTime="0" CoolDownTime="0" TestIterations="8" WebTestConnectionModel="ConnectionPerUser" WebTestConnectionPoolSize="50" SampleRate="5" ValidationLevel="High" SqlTracingConnectString="" SqlTracingConnectStringDisplayValue="" SqlTracingDirectory="" SqlTracingEnabled="false" SqlTracingFileCount="2" SqlTracingRolloverEnabled="true" SqlTracingMinimumDuration="500" RunUnitTestsInAppDomain="true" CoreCount="0" ResourcesRetentionTimeInMinutes="0" UseMultipleIPs="false" TestAgentConfiguration="Default" AgentDiagnosticsLevel="Warning">
420 <CounterSetMappings> 446 <CounterSetMappings>
421 <CounterSetMapping ComputerName="[CONTROLLER MACHINE]"> 447 <CounterSetMapping ComputerName="[CONTROLLER MACHINE]">
422 <CounterSetReferences> 448 <CounterSetReferences>
...@@ -433,26 +459,13 @@ ...@@ -433,26 +459,13 @@
433 </RunConfiguration> 459 </RunConfiguration>
434 </RunConfigurations> 460 </RunConfigurations>
435 <LoadTestPlugins> 461 <LoadTestPlugins>
436 <LoadTestPlugin Classname="LIL_VSTT_Plugins.SetTestParameter, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Set Test Context Parameters" Description="(C) Copyright 2011 LIGHTS IN LINE AB&#xD;&#xA;Sätter parametrar i testcontextet för tester i mixen hämtat från en CSV fil"> 462 <LoadTestPlugin Classname="LIL_VSTT_Plugins.ThinkTimeEmulator10190, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Think Time Emulator 10/190" Description="Sets a context parameter named ThinkTime in each starting test to a random value between 10%-190% of the specified value.">
437 <RuleParameters> 463 <RuleParameters>
438 <RuleParameter Name="Connection_String" Value="UserdataFew.csv" /> 464 <RuleParameter Name="ThinkTime" Value="35" />
439 <RuleParameter Name="Has_col_name" Value="True" /> 465 <RuleParameter Name="Min" Value="10" />
440 <RuleParameter Name="Autosplit" Value="False" /> 466 <RuleParameter Name="Max" Value="190" />
441 <RuleParameter Name="Parameter_Name" Value="Kolumnnamn" /> 467 <RuleParameter Name="RegExTestName" Value="Copy" />
442 <RuleParameter Name="LogFilePathString" Value="C:\Temp\Fungerande.log" /> 468 <RuleParameter Name="RegExScenarioName" Value="Copy" />
443 <RuleParameter Name="LogFileAppendID" Value="False" />
444 <RuleParameter Name="LogFileAppendName" Value="False" />
445 <RuleParameter Name="Use_Random" Value="False" />
446 <RuleParameter Name="Use_Unique" Value="False" />
447 <RuleParameter Name="Use_UniqueIteration" Value="False" />
448 <RuleParameter Name="Use_Loop" Value="False" />
449 <RuleParameter Name="Log_To_File" Value="False" />
450 <RuleParameter Name="Test_Names" Value="" />
451 <RuleParameter Name="Scenario_Names" Value="" />
452 <RuleParameter Name="Agent_Names" Value="" />
453 <RuleParameter Name="Use_UniqueTestIteration" Value="True" />
454 <RuleParameter Name="IgnoreBlanks" Value="True" />
455 <RuleParameter Name="ThrowException" Value="True" />
456 </RuleParameters> 469 </RuleParameters>
457 </LoadTestPlugin> 470 </LoadTestPlugin>
458 </LoadTestPlugins> 471 </LoadTestPlugins>
......
...@@ -119,6 +119,9 @@ ...@@ -119,6 +119,9 @@
119 <None Include="WebTest1.webtest"> 119 <None Include="WebTest1.webtest">
120 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 120 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
121 </None> 121 </None>
122 <None Include="WebTest7 - Copy.webtest">
123 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
124 </None>
122 <None Include="WebTest7.webtest"> 125 <None Include="WebTest7.webtest">
123 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 126 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
124 </None> 127 </None>
......
1 <?xml version="1.0" encoding="utf-8"?>
2 <WebTest Name="WebTest7 - Copy" Id="da8233d7-4410-4404-b5f9-76bdf9cf36f4" Owner="" Priority="2147483647" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="0" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale="">
3 <Items>
4 <Request Method="GET" Guid="3d1817e4-021d-4bfc-b6d7-dfd8ffa7febf" Version="1.1" Url="https://www.lightsinline.se/" ThinkTime="1" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" />
5 </Items>
6 <WebTestPlugins>
7 <WebTestPlugin Classname="LIL_VSTT_Plugins.SetRequestThinkTime, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Set Request Think Time" Description="Changes the thinktime on requests with a set thinktime over 0 to the value of the ThinkTime context parameter">
8 <RuleParameters>
9 <RuleParameter Name="DebugMode" Value="True" />
10 </RuleParameters>
11 </WebTestPlugin>
12 </WebTestPlugins>
13 </WebTest>
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <WebTest Name="WebTest7" Id="b81f6de6-5ea8-4211-ac7b-3c0272942501" Owner="" Priority="2147483647" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="0" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale=""> 2 <WebTest Name="WebTest7" Id="b81f6de6-5ea8-4211-ac7b-3c0272942501" Owner="" Priority="2147483647" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="0" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale="">
3 <Items> 3 <Items>
4 <Request Method="GET" Guid="3d1817e4-021d-4bfc-b6d7-dfd8ffa7febf" Version="1.1" Url="https://www.lightsinline.se/" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /> 4 <Request Method="GET" Guid="3d1817e4-021d-4bfc-b6d7-dfd8ffa7febf" Version="1.1" Url="https://www.lightsinline.se/" ThinkTime="1" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" />
5 </Items> 5 </Items>
6 <WebTestPlugins>
7 <WebTestPlugin Classname="LIL_VSTT_Plugins.SetRequestThinkTime, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Set Request Think Time" Description="Changes the thinktime on requests with a set thinktime over 0 to the value of the ThinkTime context parameter">
8 <RuleParameters>
9 <RuleParameter Name="DebugMode" Value="True" />
10 </RuleParameters>
11 </WebTestPlugin>
12 </WebTestPlugins>
6 </WebTest> 13 </WebTest>
...\ No newline at end of file ...\ No newline at end of file
......