Commit e385b4dc e385b4dc3ee06b2c09d3de087bfcf3987183cafb by Christian Gerdes

New Plugin: Set Test Info As Header

1 parent bc8d1a03
...@@ -282,6 +282,58 @@ namespace LIL_VSTT_Plugins ...@@ -282,6 +282,58 @@ namespace LIL_VSTT_Plugins
282 } 282 }
283 283
284 /// <summary> 284 /// <summary>
285 /// Loggar alla transaktioners svarstider som context parametrar
286 /// </summary>
287 [DisplayName("Set Test Info As Header")]
288 [Description("(C) Copyright 2017 LIGHTS IN LINE AB\r\nAdds name information from transactions, pages, tests into a header in requests so that it can be used to group upon in tools like AppDynamics, DynaTrace, etc.")]
289 public class SetTestInfoAsHeader : WebTestPlugin
290 {
291 [DisplayName("Header Prefix")]
292 [Description("Prefix of the header to be added on requests")]
293 [DefaultValue("X-Sipoz")]
294 public String HeaderName { get; set; }
295
296 [DisplayName("Tests")]
297 [Description("Add the Test name as a header with <prefix>-TestName")]
298 [DefaultValue(true)]
299 public bool onTransaction { get; set; }
300
301 [DisplayName("Transactions")]
302 [Description("Add the transaction name as a header with <prefix>-TransactionName")]
303 [DefaultValue(true)]
304 public bool onTest { get; set; }
305
306 List<String> transactionPath = new List<string>();
307
308 public override void PreRequest(object sender, PreRequestEventArgs e)
309 {
310 base.PreRequest(sender, e);
311 if (onTest) e.Request.Headers.Add(HeaderName + "-TestName", e.WebTest.Name);
312 if (onTransaction && transactionPath.Count > 0)
313 {
314 String value = String.Empty;
315 foreach (string trans in transactionPath) {
316 if (value.Equals(String.Empty)) value = trans;
317 else value += "." + trans;
318 }
319 e.Request.Headers.Add(HeaderName + "-TransactionName", value);
320 }
321 }
322
323 public override void PreTransaction(object sender, PreTransactionEventArgs e)
324 {
325 base.PreTransaction(sender, e);
326 transactionPath.Add(e.TransactionName);
327 }
328
329 public override void PostTransaction(object sender, PostTransactionEventArgs e)
330 {
331 base.PostTransaction(sender, e);
332 transactionPath.Remove(e.TransactionName);
333 }
334 }
335
336 /// <summary>
285 /// Ignorerar status koder under 500. 337 /// Ignorerar status koder under 500.
286 /// </summary> 338 /// </summary>
287 [DisplayName("Ignore 4xx status codes")] 339 [DisplayName("Ignore 4xx status codes")]
......
...@@ -2,7 +2,21 @@ ...@@ -2,7 +2,21 @@
2 <WebTest Name="WebTest6" Id="122acb09-9cc2-4809-903b-a7fee7f1e5c3" 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="WebTest5.10d2bf93-1ab4-4a60-b4ff-f80b74d5d7e4.rec.webtestresult" ResultsLocale=""> 2 <WebTest Name="WebTest6" Id="122acb09-9cc2-4809-903b-a7fee7f1e5c3" 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="WebTest5.10d2bf93-1ab4-4a60-b4ff-f80b74d5d7e4.rec.webtestresult" ResultsLocale="">
3 <Items> 3 <Items>
4 <Request Method="GET" Guid="57c5c6f4-6ec7-461e-85f2-5ff56e9a7a5f" Version="1.1" Url="https://ssokpr.rsv.se/" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="False" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /> 4 <Request Method="GET" Guid="57c5c6f4-6ec7-461e-85f2-5ff56e9a7a5f" Version="1.1" Url="https://ssokpr.rsv.se/" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="False" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" />
5 <Request Method="GET" Guid="69c1e190-3d37-4759-a340-83bdcf7457a7" Version="1.1" Url="https://ppmk2s2.pp.kap.rsv.se:17001/" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /> 5 <TransactionTimer Name="Transaction1">
6 <Items>
7 <Request Method="GET" Guid="57c5c6f4-6ec7-461e-85f2-5ff56e9a7a5f" Version="1.1" Url="https://ssokpr.rsv.se/" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="False" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" />
8 </Items>
9 </TransactionTimer>
10 <TransactionTimer Name="Transaction2">
11 <Items>
12 <Request Method="GET" Guid="57c5c6f4-6ec7-461e-85f2-5ff56e9a7a5f" Version="1.1" Url="https://ssokpr.rsv.se/" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="False" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" />
13 <TransactionTimer Name="Transaction3">
14 <Items>
15 <Request Method="GET" Guid="57c5c6f4-6ec7-461e-85f2-5ff56e9a7a5f" Version="1.1" Url="https://ssokpr.rsv.se/" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="False" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" />
16 </Items>
17 </TransactionTimer>
18 </Items>
19 </TransactionTimer>
6 </Items> 20 </Items>
7 <ValidationRules> 21 <ValidationRules>
8 <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL. QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" /> 22 <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL. QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" />
...@@ -21,9 +35,16 @@ ...@@ -21,9 +35,16 @@
21 <RuleParameter Name="timeOut" Value="5000" /> 35 <RuleParameter Name="timeOut" Value="5000" />
22 <RuleParameter Name="interVal" Value="1000" /> 36 <RuleParameter Name="interVal" Value="1000" />
23 <RuleParameter Name="useNagle" Value="False" /> 37 <RuleParameter Name="useNagle" Value="False" />
24 <RuleParameter Name="useTls12" Value="False" /> 38 <RuleParameter Name="useTls12" Value="True" />
25 <RuleParameter Name="proxyOverride" Value="True" /> 39 <RuleParameter Name="proxyOverride" Value="True" />
26 </RuleParameters> 40 </RuleParameters>
27 </WebTestPlugin> 41 </WebTestPlugin>
42 <WebTestPlugin Classname="LIL_VSTT_Plugins.SetTestInfoAsHeader, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Set Test Info As Header" Description="(C) Copyright 2017 LIGHTS IN LINE AB&#xD;&#xA;Adds name information from transactions, pages, tests into a header in requests so that it can be used to group upon in tools like AppDynamics, DynaTrace, etc.">
43 <RuleParameters>
44 <RuleParameter Name="HeaderName" Value="X-Sipoz" />
45 <RuleParameter Name="onTransaction" Value="True" />
46 <RuleParameter Name="onTest" Value="True" />
47 </RuleParameters>
48 </WebTestPlugin>
28 </WebTestPlugins> 49 </WebTestPlugins>
29 </WebTest> 50 </WebTest>
...\ No newline at end of file ...\ No newline at end of file
......