Commit a80b5e4b a80b5e4bc57d28856624f5aa66b17950c2a759a7 by Christian Gerdes

FIFO additional features for auto wash (beta)

1 parent e6e2f325
......@@ -263,6 +263,15 @@ namespace LIL_VSTT_Plugins
private bool myIgnoreBlanks = true;
private bool myDebug = false;
private bool myFifoTrackFailed = false;
private Dictionary<string, int> failTable = new Dictionary<string, int>();
private string myFifoLogFileString = "";
private string myFifoDumpFileString = "";
private bool myFifoLogToFile = false;
private int myFifoFailedLimit = 5;
private bool myFifoDoNotResetOnPassed = false;
private bool myFifoDumpWorkingTestDataOnFinish = false;
private bool stop = false;
private int timeWait = 0;
......@@ -493,6 +502,76 @@ namespace LIL_VSTT_Plugins
set { myAgentNames = value; }
}
[Category("FIFO")]
[DisplayName("Auto Wash")]
[Description("Sluta använda rader av testdata som leder till att tester slutar i status Failed.")]
[DefaultValue(false)]
public bool FifoAutoExclude
{
get { return myFifoTrackFailed; }
set { myFifoTrackFailed = value; }
}
[Category("FIFO")]
[DisplayName("Nollställ ej efter lyckat test")]
[Description("Nollställ inte räknaren för antal felaktiga tester (Failed) i rad när ett test går bra (Passsed)")]
[DefaultValue(false)]
public bool FifoDoNotResetOnPassed
{
get { return myFifoDoNotResetOnPassed; }
set { myFifoDoNotResetOnPassed = value; }
}
[Category("FIFO")]
[DisplayName("Dumpa fungerande testdata efter avslutat loadtest")]
[Description("Dumpa fungerande testdatarader efter att loadtestet avslutats")]
[DefaultValue(false)]
public bool FifoDumpWorkingTestDataOnFinish
{
get { return myFifoDumpWorkingTestDataOnFinish; }
set { myFifoDumpWorkingTestDataOnFinish = value; }
}
[Category("FIFO")]
[DisplayName("Tröskelvärde")]
[Description("Sluta använda rader efter detta antal fel i rad.")]
[DefaultValue(5)]
public int FifoFailLimit
{
get { return myFifoFailedLimit; }
set { myFifoFailedLimit = value; }
}
[Category("FIFO")]
[DisplayName("Logga statistik")]
[Description("Loggar statistik efter loadtestets slut med antalet gånger som en testdatarad har slutat ett test i status Failed")]
[DefaultValue(false)]
public bool FifoLogToFile
{
get { return myFifoLogToFile; }
set { myFifoLogToFile = value; }
}
[Category("FIFO")]
[DisplayName("Loggfilens namn")]
[Description("Ange den fullständiga sökvägen till logg filen. Om filen finns kommer den inte skrivas över utan läggas till i slutet.")]
[DefaultValue("C:\\Temp\\Fifo.log")]
public string FifoLogFilePathString
{
get { return myFifoLogFileString; }
set { myFifoLogFileString = value; }
}
[Category("FIFO")]
[DisplayName("Dumpfilens namn")]
[Description("Ange den fullständiga sökvägen till logg filen. Om filen finns kommer den inte skrivas över utan läggas till i slutet.")]
[DefaultValue("C:\\Temp\\FifoDump.log")]
public string FifoDumpFilePathString
{
get { return myFifoDumpFileString; }
set { myFifoDumpFileString = value; }
}
#endregion
public void Initialize(LoadTest loadTest)
......@@ -522,6 +601,10 @@ namespace LIL_VSTT_Plugins
else
m_loadTest.TestStarting += new EventHandler<TestStartingEventArgs>(loadTestStartingSeq);
}
if(myFifoTrackFailed)
{
m_loadTest.LoadTestFinished += new EventHandler(loadTestFinished);
}
if (myLogToFile)
{
m_loadTest.TestFinished += new EventHandler<TestFinishedEventArgs>(loadTestEndLogger);
......@@ -529,6 +612,24 @@ namespace LIL_VSTT_Plugins
m_loadTest.Heartbeat += new EventHandler<HeartbeatEventArgs>(loadTestHeartBeat);
}
void loadTestFinished(object sender, EventArgs e)
{
if(myFifoLogToFile)
{
foreach (KeyValuePair<string,int> kv in failTable)
{
File.AppendAllText(myFifoLogFileString, kv.Key + ":" + kv.Value + "\r\n");
}
}
if(myFifoDumpWorkingTestDataOnFinish)
{
foreach (string row in myUnUsedQueue)
{
File.AppendAllText(myFifoDumpFileString, row + "\r\n");
}
}
}
void loadTestHeartBeat(object sender, HeartbeatEventArgs e)
{
if (stop)
......@@ -604,9 +705,35 @@ namespace LIL_VSTT_Plugins
{
String queueVal = (String)e.UserContext["QueueVal"];
if (queueVal != null)
lock (myUnUsedQueue)
if (myFifoTrackFailed)
{
myUnUsedQueue.Enqueue(queueVal);
if(e.Result.Passed)
{
lock (myUnUsedQueue)
{
if(myFifoDoNotResetOnPassed == false) failTable[queueVal] = 0;
myUnUsedQueue.Enqueue(queueVal);
}
} else
{
lock (myUnUsedQueue)
{
if(failTable.ContainsKey(queueVal))
failTable[queueVal] += 1;
else
failTable[queueVal] = 1;
if(failTable[queueVal] < myFifoFailedLimit)
myUnUsedQueue.Enqueue(queueVal);
}
}
}
else
{
lock (myUnUsedQueue)
{
myUnUsedQueue.Enqueue(queueVal);
}
}
if (myDebug) lock (myDebugLogFile) { File.AppendAllText(myDebugLogFile, DateTime.Now.ToLocalTime() + " File: " + myConnectionString + " Test: " + e.TestName + " VU: " + e.UserContext.UserId + " Value: \"" + queueVal + "\" PUSH\r\n"); }
}
......