Fixed a couple bugs in test code that handles log reading

This commit is contained in:
Darren Gehring 2021-04-01 21:05:37 -07:00
Родитель 5414b48a44
Коммит 3cc565bf65
3 изменённых файлов: 17 добавлений и 16 удалений

Просмотреть файл

@ -1211,8 +1211,8 @@ namespace AmbrosiaTest
// really reliable. As long as they get through whole thing, that is what counts.
// Verify ImmCoord has the string to show it is primary for both server and client
pass = MyUtils.WaitForProcessToFinish(logOutputFileName_ImmCoord2_Restarted, newPrimary, 5, false, testName, true);
pass = MyUtils.WaitForProcessToFinish(logOutputFileName_ImmCoord5_Restarted, newPrimary, 5, false, testName, true);
pass = MyUtils.WaitForProcessToFinish(logOutputFileName_ImmCoord2_Restarted, newPrimary, 5, false, testName, true,false);
pass = MyUtils.WaitForProcessToFinish(logOutputFileName_ImmCoord5_Restarted, newPrimary, 5, false, testName, true,false);
// Verify integrity of Ambrosia logs by replaying
MyUtils.VerifyAmbrosiaLogFile(testName, Convert.ToInt64(byteSize), true, true, AMB1.AMB_Version);

Просмотреть файл

@ -1153,14 +1153,12 @@ namespace AmbrosiaTest
//Delay until server upgrade is done
pass = MyUtils.WaitForProcessToFinish(logOutputFileName_Server_upgraded, byteSize, 30, false, testName, true);
pass = MyUtils.WaitForProcessToFinish(logOutputFileName_Server_upgraded, newUpgradedPrimary, 5, false, testName, true, false);
// Stop things so file is freed up and can be opened in verify
MyUtils.KillProcess(clientJobProcessID);
MyUtils.KillProcess(serverProcessID_upgraded);
// Also verify upgraded server showing new upgraded primary
pass = MyUtils.WaitForProcessToFinish(logOutputFileName_Server_upgraded, newUpgradedPrimary, 5, false, testName, true,false);
// Verify Client
MyUtils.VerifyTestOutputFileToCmpFile(logOutputFileName_ClientJob);

Просмотреть файл

@ -107,7 +107,6 @@ namespace AmbrosiaTest
try
{
// Start cmd.exe process that launches proper exe
Process process = Process.Start(startInfo);
if (waitForExit)
@ -159,16 +158,14 @@ namespace AmbrosiaTest
}
// timing mechanism to see when a process finishes. It uses a trigger string ("DONE") and will delay until that string
// is hit or until maxDelay (mins) is hit
// After the doneString is found it also determines if the extraStringToFind is part of it as well.
// ASSUMPTION: done string is always after the extra string - so if extra string is not found by time it hits DONE, then know it isn't in output
// is hit or until maxDelay (mins) is hit it also can determine if the extraStringToFind is part of it as well.
public bool WaitForProcessToFinish(string logFile, string extraStringToFind, int maxDelay, bool truncateAmbrosiaLogs, string testName, bool assertOnFalseReturn, bool checkForDoneString = true)
{
int timeCheckInterval = 10000; // 10 seconds
int maxTimeLoops = (maxDelay * 60000) / timeCheckInterval;
string doneString = "DONE";
bool foundExtraString = false;
bool foundDoneString = false;
logFile = ConfigurationManager.AppSettings["TestLogOutputDirectory"] + "\\" + logFile;
for (int i = 0; i < maxTimeLoops; i++)
@ -181,11 +178,19 @@ namespace AmbrosiaTest
while (!logFileReader.EndOfStream)
{
string line = logFileReader.ReadLine();
// Looking for "DONE"
if (line.Contains(doneString))
{
foundDoneString = true;
}
// Looking for extra string (usually byte size or some extra message in output)
if (line.Contains(extraStringToFind))
{
foundExtraString = true;
// since not looking for done, need to close things down here
// since not looking for done, can close things down here
if (checkForDoneString == false)
{
logFileReader.Close();
@ -194,13 +199,12 @@ namespace AmbrosiaTest
}
}
if (line.Contains(doneString))
// kick out because had success only if doneString is found AND the extra string is found
if ((foundDoneString) && (foundExtraString))
{
logFileReader.Close();
logFileStream.Close();
if (foundExtraString)
return true; // kick out because had success only if doneString is found AND the extra string is found
return true;
}
}
@ -225,7 +229,6 @@ namespace AmbrosiaTest
FailureSupport(testName);
// If times out without string hit - then pop exception
if (checkForDoneString)
{
Assert.Fail("<WaitForProcessToFinish> Failure! Looking for '" + doneString + "' string AND the extra string:" + extraStringToFind + " in log file:" + logFile + " but did not find one or both after waiting:" + maxDelay.ToString() + " minutes.");