Commit 5846546c 5846546c1884c1bc91d5660481395a92df4a3647 by Christian Gerdes

Bättre trim på SetTestContextParameter som nu även ignorerar null, nya webtest p…

…lugins som slår på url encode samt loggar transactioners svarstider till context,  samt bättre loggning av conext parametrar till fil.
1 parent 6b3488a7
......@@ -208,6 +208,9 @@ namespace LIL_VSTT_Plugins
[DisplayName("File Name"), Description("The file name to use for logging")]
public String Filename { get; set; }
[DisplayName("Autogenerate File Name"), Description("Automatically generate a filename using the test name and user id from the load test")]
public bool autoFilename { get; set; }
[DisplayName("Write header"), DefaultValue(false), Description("Writes the parameter names as a header. Will write a new header for each user (dont use in loadtest)")]
public bool useHeader { get; set; }
......@@ -221,6 +224,11 @@ namespace LIL_VSTT_Plugins
public override void PostWebTest(object sender, PostWebTestEventArgs e)
{
String completeFileName = Filename + e.WebTest.Context.WebTestUserId + ".log";
if (autoFilename)
{
completeFileName = e.WebTest.Name + e.WebTest.Context.WebTestUserId + ".log";
}
if ((e.WebTest.Outcome == Outcome.Pass && logPassed) || (e.WebTest.Outcome == Outcome.Fail && logFailed)) {
string row = "";
string hrow = "";
......@@ -240,10 +248,10 @@ namespace LIL_VSTT_Plugins
}
if (header && useHeader)
{
File.AppendAllText(Filename + e.WebTest.Context.WebTestUserId + ".log", hrow + "\r\n");
File.AppendAllText(completeFileName, hrow + "\r\n");
header = false;
}
File.AppendAllText(Filename + e.WebTest.Context.WebTestUserId + ".log", row + "\r\n");
File.AppendAllText(completeFileName, row + "\r\n");
base.PostWebTest(sender, e);
}
}
......
......@@ -457,6 +457,7 @@ namespace LIL_VSTT_Plugins
string input = null;
int lineNum = 0;
int dataNum = 0;
char[] trim = { ' ', '\x00', '\t', '\x20' };
while ((input = re.ReadLine()) != null)
{
// Ignore blank lines and empty lines (just whitespace) or lines with only blank/empty/whitespace columns
......@@ -466,7 +467,7 @@ namespace LIL_VSTT_Plugins
if (lineNum == 1 && myHasColName == true)
{
// First line is column names
myColNames = input.TrimEnd();
myColNames = input.TrimEnd(trim);
}
else
{
......@@ -477,13 +478,13 @@ namespace LIL_VSTT_Plugins
else ifAgentId = dataNum + 1;
if (ifAgentId == agentId)
{
myParams.Add(input.TrimEnd());
myParams.Add(input.TrimEnd(trim));
}
dataNum++;
}
else
{
myParams.Add(input.TrimEnd());
myParams.Add(input.TrimEnd(trim));
}
}
}
......
......@@ -234,6 +234,54 @@ namespace LIL_VSTT_Plugins
}
/// <summary>
/// Slå på URL encode på query string parametrar
/// </summary>
[DisplayName("URL Encode Query String Parameter")]
[Description("(C) Copyright 2011 LIGHTS IN LINE AB\r\nTvingar en URL Encode på angiven Query String parameter i alla request")]
public class URLEncodeQueryStringParameter : WebTestPlugin
{
[DisplayName("Query String Parameter Name")]
[Description("Name of the query string parameter to URL encode before each request")]
public String paramName { get; set; }
public override void PreRequest(object sender, PreRequestEventArgs e)
{
if (e.Request.HasQueryStringParameters)
{
if (e.Request.QueryStringParameters.Contains(paramName))
{
foreach (QueryStringParameter qsp in e.Request.QueryStringParameters) {
if (qsp.Name.Equals(paramName))
{
qsp.UrlEncode = true;
}
}
}
}
}
}
/// <summary>
/// Loggar alla transaktioners svarstider som context parametrar
/// </summary>
[DisplayName("Transaction Response Times to Context")]
[Description("(C) Copyright 2016 LIGHTS IN LINE AB\r\nLoggar alla transaktioners svarstider som context parametrar")]
public class TransactionsToContext : WebTestPlugin
{
public override void PostTransaction(object sender, PostTransactionEventArgs e)
{
base.PostTransaction(sender, e);
if (!e.WebTest.Context.ContainsKey(e.TransactionName))
{
e.WebTest.Context.Add(e.TransactionName, e.Duration.TotalMilliseconds.ToString());
}
else
{
e.WebTest.Context[e.TransactionName] = e.Duration.TotalMilliseconds.ToString();
}
}
}
/// <summary>
/// Ignorerar status koder under 500.
/// </summary>
[DisplayName("Ignore 4xx status codes")]
......