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 ...@@ -208,6 +208,9 @@ namespace LIL_VSTT_Plugins
208 [DisplayName("File Name"), Description("The file name to use for logging")] 208 [DisplayName("File Name"), Description("The file name to use for logging")]
209 public String Filename { get; set; } 209 public String Filename { get; set; }
210 210
211 [DisplayName("Autogenerate File Name"), Description("Automatically generate a filename using the test name and user id from the load test")]
212 public bool autoFilename { get; set; }
213
211 [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)")] 214 [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)")]
212 public bool useHeader { get; set; } 215 public bool useHeader { get; set; }
213 216
...@@ -221,6 +224,11 @@ namespace LIL_VSTT_Plugins ...@@ -221,6 +224,11 @@ namespace LIL_VSTT_Plugins
221 224
222 public override void PostWebTest(object sender, PostWebTestEventArgs e) 225 public override void PostWebTest(object sender, PostWebTestEventArgs e)
223 { 226 {
227 String completeFileName = Filename + e.WebTest.Context.WebTestUserId + ".log";
228 if (autoFilename)
229 {
230 completeFileName = e.WebTest.Name + e.WebTest.Context.WebTestUserId + ".log";
231 }
224 if ((e.WebTest.Outcome == Outcome.Pass && logPassed) || (e.WebTest.Outcome == Outcome.Fail && logFailed)) { 232 if ((e.WebTest.Outcome == Outcome.Pass && logPassed) || (e.WebTest.Outcome == Outcome.Fail && logFailed)) {
225 string row = ""; 233 string row = "";
226 string hrow = ""; 234 string hrow = "";
...@@ -240,10 +248,10 @@ namespace LIL_VSTT_Plugins ...@@ -240,10 +248,10 @@ namespace LIL_VSTT_Plugins
240 } 248 }
241 if (header && useHeader) 249 if (header && useHeader)
242 { 250 {
243 File.AppendAllText(Filename + e.WebTest.Context.WebTestUserId + ".log", hrow + "\r\n"); 251 File.AppendAllText(completeFileName, hrow + "\r\n");
244 header = false; 252 header = false;
245 } 253 }
246 File.AppendAllText(Filename + e.WebTest.Context.WebTestUserId + ".log", row + "\r\n"); 254 File.AppendAllText(completeFileName, row + "\r\n");
247 base.PostWebTest(sender, e); 255 base.PostWebTest(sender, e);
248 } 256 }
249 } 257 }
......
...@@ -457,6 +457,7 @@ namespace LIL_VSTT_Plugins ...@@ -457,6 +457,7 @@ namespace LIL_VSTT_Plugins
457 string input = null; 457 string input = null;
458 int lineNum = 0; 458 int lineNum = 0;
459 int dataNum = 0; 459 int dataNum = 0;
460 char[] trim = { ' ', '\x00', '\t', '\x20' };
460 while ((input = re.ReadLine()) != null) 461 while ((input = re.ReadLine()) != null)
461 { 462 {
462 // Ignore blank lines and empty lines (just whitespace) or lines with only blank/empty/whitespace columns 463 // Ignore blank lines and empty lines (just whitespace) or lines with only blank/empty/whitespace columns
...@@ -466,7 +467,7 @@ namespace LIL_VSTT_Plugins ...@@ -466,7 +467,7 @@ namespace LIL_VSTT_Plugins
466 if (lineNum == 1 && myHasColName == true) 467 if (lineNum == 1 && myHasColName == true)
467 { 468 {
468 // First line is column names 469 // First line is column names
469 myColNames = input.TrimEnd(); 470 myColNames = input.TrimEnd(trim);
470 } 471 }
471 else 472 else
472 { 473 {
...@@ -477,13 +478,13 @@ namespace LIL_VSTT_Plugins ...@@ -477,13 +478,13 @@ namespace LIL_VSTT_Plugins
477 else ifAgentId = dataNum + 1; 478 else ifAgentId = dataNum + 1;
478 if (ifAgentId == agentId) 479 if (ifAgentId == agentId)
479 { 480 {
480 myParams.Add(input.TrimEnd()); 481 myParams.Add(input.TrimEnd(trim));
481 } 482 }
482 dataNum++; 483 dataNum++;
483 } 484 }
484 else 485 else
485 { 486 {
486 myParams.Add(input.TrimEnd()); 487 myParams.Add(input.TrimEnd(trim));
487 } 488 }
488 } 489 }
489 } 490 }
......
...@@ -234,6 +234,54 @@ namespace LIL_VSTT_Plugins ...@@ -234,6 +234,54 @@ namespace LIL_VSTT_Plugins
234 } 234 }
235 235
236 /// <summary> 236 /// <summary>
237 /// Slå på URL encode på query string parametrar
238 /// </summary>
239 [DisplayName("URL Encode Query String Parameter")]
240 [Description("(C) Copyright 2011 LIGHTS IN LINE AB\r\nTvingar en URL Encode på angiven Query String parameter i alla request")]
241 public class URLEncodeQueryStringParameter : WebTestPlugin
242 {
243 [DisplayName("Query String Parameter Name")]
244 [Description("Name of the query string parameter to URL encode before each request")]
245 public String paramName { get; set; }
246 public override void PreRequest(object sender, PreRequestEventArgs e)
247 {
248 if (e.Request.HasQueryStringParameters)
249 {
250 if (e.Request.QueryStringParameters.Contains(paramName))
251 {
252 foreach (QueryStringParameter qsp in e.Request.QueryStringParameters) {
253 if (qsp.Name.Equals(paramName))
254 {
255 qsp.UrlEncode = true;
256 }
257 }
258 }
259 }
260 }
261 }
262
263 /// <summary>
264 /// Loggar alla transaktioners svarstider som context parametrar
265 /// </summary>
266 [DisplayName("Transaction Response Times to Context")]
267 [Description("(C) Copyright 2016 LIGHTS IN LINE AB\r\nLoggar alla transaktioners svarstider som context parametrar")]
268 public class TransactionsToContext : WebTestPlugin
269 {
270 public override void PostTransaction(object sender, PostTransactionEventArgs e)
271 {
272 base.PostTransaction(sender, e);
273 if (!e.WebTest.Context.ContainsKey(e.TransactionName))
274 {
275 e.WebTest.Context.Add(e.TransactionName, e.Duration.TotalMilliseconds.ToString());
276 }
277 else
278 {
279 e.WebTest.Context[e.TransactionName] = e.Duration.TotalMilliseconds.ToString();
280 }
281 }
282 }
283
284 /// <summary>
237 /// Ignorerar status koder under 500. 285 /// Ignorerar status koder under 500.
238 /// </summary> 286 /// </summary>
239 [DisplayName("Ignore 4xx status codes")] 287 [DisplayName("Ignore 4xx status codes")]
......