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
[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.")]
public class ThinkTimeEmulator10190 : ILoadTestPlugin
{
[DisplayName("Think Time"), DefaultValue(0), Description("The Think Time to be used seconds. Default is 0.")]
[DisplayName("ThinkTime"), DefaultValue(0), Description("The Think Time to be used seconds. Default is 0.")]
public int ThinkTime { get; set; }
[DisplayName("Minimum"), DefaultValue(10), Description("Percentage of ThinkTime to be used as the minimum value")]
public int Min { get; set; }
[DisplayName("Maximum"), DefaultValue(190), Description("Percentage of ThinkTime to be used as the maximum value")]
public int Max { get; set; }
[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")]
public string RegExTestName { get; set; }
[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")]
public string RegExScenarioName { get; set; }
//store the load test object.
LoadTest mLoadTest;
Random rnd = new Random();
Regex rxTestName = null;
Regex rxScenarioName = null;
public void Initialize(LoadTest loadTest)
{
mLoadTest = loadTest;
if(!String.IsNullOrEmpty(RegExTestName))
rxTestName = new Regex(RegExTestName);
if (!String.IsNullOrEmpty(RegExScenarioName))
rxScenarioName = new Regex(RegExScenarioName);
//connect to the TestStarting event.
mLoadTest.TestStarting += new EventHandler<TestStartingEventArgs>(mLoadTest_TestStarting);
......@@ -128,10 +142,16 @@ namespace LIL_VSTT_Plugins
void mLoadTest_TestStarting(object sender, TestStartingEventArgs e)
{
if (rxTestName != null && rxTestName.IsMatch(e.TestName) != true) return;
if (rxScenarioName != null && rxScenarioName.IsMatch(e.ScenarioName) != true) return;
// Set the think time parameter in the tests context to a new value
int min = ThinkTime/10;
int max = ThinkTime*2 - min;
e.TestContextProperties.Add("ThinkTime", rnd.Next(min, max));
double tt = ThinkTime;
double min = Min / 100d;
min = tt * min;
double max = Max / 100d;
max = tt * max;
e.TestContextProperties.Add("ThinkTime", rnd.Next((int)min, (int)max));
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<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">
<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">
<Scenarios>
<Scenario Name="Copy of Scenario1" DelayBetweenIterations="30" PercentNewUsers="0" IPSwitching="true" TestMixType="PercentageOfUsersRunning" ApplyDistributionToPacingDelay="true" MaxTestIterations="0" DisableDuringWarmup="false" DelayStartTime="0" AllowedAgents="">
<ThinkProfile Value="0.2" Pattern="Off" />
<LoadProfile Pattern="Constant" InitialUsers="2" />
<TestMix>
<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" />
<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" />
</TestMix>
<BrowserMix>
<BrowserProfile Percentage="100">
<Browser Name="Internet Explorer 11.0" MaxConnections="6">
<Headers>
<Header Name="User-Agent" Value="Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko" />
<Header Name="Accept" Value="*/*" />
<Header Name="Accept-Language" Value="{{$IEAcceptLanguage}}" />
<Header Name="Accept-Encoding" Value="GZIP" />
</Headers>
</Browser>
</BrowserProfile>
</BrowserMix>
<NetworkMix>
<NetworkProfile Percentage="100">
<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;" />
</NetworkProfile>
</NetworkMix>
</Scenario>
<Scenario Name="Scenario1" DelayBetweenIterations="30" PercentNewUsers="0" IPSwitching="true" TestMixType="PercentageOfUsersRunning" ApplyDistributionToPacingDelay="true" MaxTestIterations="0" DisableDuringWarmup="false" DelayStartTime="0" AllowedAgents="">
<ThinkProfile Value="0.2" Pattern="NormalDistribution" />
<ThinkProfile Value="0.2" Pattern="Off" />
<LoadProfile Pattern="Constant" InitialUsers="2" />
<TestMix>
<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" />
<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" />
<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" />
</TestMix>
<BrowserMix>
<BrowserProfile Percentage="100">
......@@ -416,7 +442,7 @@
</CounterSet>
</CounterSets>
<RunConfigurations>
<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">
<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">
<CounterSetMappings>
<CounterSetMapping ComputerName="[CONTROLLER MACHINE]">
<CounterSetReferences>
......@@ -433,26 +459,13 @@
</RunConfiguration>
</RunConfigurations>
<LoadTestPlugins>
<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">
<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.">
<RuleParameters>
<RuleParameter Name="Connection_String" Value="UserdataFew.csv" />
<RuleParameter Name="Has_col_name" Value="True" />
<RuleParameter Name="Autosplit" Value="False" />
<RuleParameter Name="Parameter_Name" Value="Kolumnnamn" />
<RuleParameter Name="LogFilePathString" Value="C:\Temp\Fungerande.log" />
<RuleParameter Name="LogFileAppendID" Value="False" />
<RuleParameter Name="LogFileAppendName" Value="False" />
<RuleParameter Name="Use_Random" Value="False" />
<RuleParameter Name="Use_Unique" Value="False" />
<RuleParameter Name="Use_UniqueIteration" Value="False" />
<RuleParameter Name="Use_Loop" Value="False" />
<RuleParameter Name="Log_To_File" Value="False" />
<RuleParameter Name="Test_Names" Value="" />
<RuleParameter Name="Scenario_Names" Value="" />
<RuleParameter Name="Agent_Names" Value="" />
<RuleParameter Name="Use_UniqueTestIteration" Value="True" />
<RuleParameter Name="IgnoreBlanks" Value="True" />
<RuleParameter Name="ThrowException" Value="True" />
<RuleParameter Name="ThinkTime" Value="35" />
<RuleParameter Name="Min" Value="10" />
<RuleParameter Name="Max" Value="190" />
<RuleParameter Name="RegExTestName" Value="Copy" />
<RuleParameter Name="RegExScenarioName" Value="Copy" />
</RuleParameters>
</LoadTestPlugin>
</LoadTestPlugins>
......
......@@ -119,6 +119,9 @@
<None Include="WebTest1.webtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WebTest7 - Copy.webtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WebTest7.webtest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
<?xml version="1.0" encoding="utf-8"?>
<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="">
<Items>
<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" />
</Items>
<WebTestPlugins>
<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">
<RuleParameters>
<RuleParameter Name="DebugMode" Value="True" />
</RuleParameters>
</WebTestPlugin>
</WebTestPlugins>
</WebTest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<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="">
<Items>
<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" />
<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" />
</Items>
<WebTestPlugins>
<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">
<RuleParameters>
<RuleParameter Name="DebugMode" Value="True" />
</RuleParameters>
</WebTestPlugin>
</WebTestPlugins>
</WebTest>
\ No newline at end of file
......