Commit e385b4dc e385b4dc3ee06b2c09d3de087bfcf3987183cafb by Christian Gerdes

New Plugin: Set Test Info As Header

1 parent bc8d1a03
......@@ -282,6 +282,58 @@ namespace LIL_VSTT_Plugins
}
/// <summary>
/// Loggar alla transaktioners svarstider som context parametrar
/// </summary>
[DisplayName("Set Test Info As Header")]
[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.")]
public class SetTestInfoAsHeader : WebTestPlugin
{
[DisplayName("Header Prefix")]
[Description("Prefix of the header to be added on requests")]
[DefaultValue("X-Sipoz")]
public String HeaderName { get; set; }
[DisplayName("Tests")]
[Description("Add the Test name as a header with <prefix>-TestName")]
[DefaultValue(true)]
public bool onTransaction { get; set; }
[DisplayName("Transactions")]
[Description("Add the transaction name as a header with <prefix>-TransactionName")]
[DefaultValue(true)]
public bool onTest { get; set; }
List<String> transactionPath = new List<string>();
public override void PreRequest(object sender, PreRequestEventArgs e)
{
base.PreRequest(sender, e);
if (onTest) e.Request.Headers.Add(HeaderName + "-TestName", e.WebTest.Name);
if (onTransaction && transactionPath.Count > 0)
{
String value = String.Empty;
foreach (string trans in transactionPath) {
if (value.Equals(String.Empty)) value = trans;
else value += "." + trans;
}
e.Request.Headers.Add(HeaderName + "-TransactionName", value);
}
}
public override void PreTransaction(object sender, PreTransactionEventArgs e)
{
base.PreTransaction(sender, e);
transactionPath.Add(e.TransactionName);
}
public override void PostTransaction(object sender, PostTransactionEventArgs e)
{
base.PostTransaction(sender, e);
transactionPath.Remove(e.TransactionName);
}
}
/// <summary>
/// Ignorerar status koder under 500.
/// </summary>
[DisplayName("Ignore 4xx status codes")]
......
......@@ -2,7 +2,21 @@
<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="">
<Items>
<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" />
<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" />
<TransactionTimer Name="Transaction1">
<Items>
<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" />
</Items>
</TransactionTimer>
<TransactionTimer Name="Transaction2">
<Items>
<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" />
<TransactionTimer Name="Transaction3">
<Items>
<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" />
</Items>
</TransactionTimer>
</Items>
</TransactionTimer>
</Items>
<ValidationRules>
<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 @@
<RuleParameter Name="timeOut" Value="5000" />
<RuleParameter Name="interVal" Value="1000" />
<RuleParameter Name="useNagle" Value="False" />
<RuleParameter Name="useTls12" Value="False" />
<RuleParameter Name="useTls12" Value="True" />
<RuleParameter Name="proxyOverride" Value="True" />
</RuleParameters>
</WebTestPlugin>
<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.">
<RuleParameters>
<RuleParameter Name="HeaderName" Value="X-Sipoz" />
<RuleParameter Name="onTransaction" Value="True" />
<RuleParameter Name="onTest" Value="True" />
</RuleParameters>
</WebTestPlugin>
</WebTestPlugins>
</WebTest>
\ No newline at end of file
......