[Harness] When on device, check if we got a tcp exception on a crash. (#8015)

Some crashes are reported as tcp connection issues because they happen
before the app had the chance to write anything in the log. In that
case, we checked for the presence of the file, and if not present we
decided it was a tcp issue when it is not the case.

In this commit, we check for the tcp erorr message in the main_log so
that we are certain that the issue was with the connection and not
anyother.

Testingis simple, ran tests without the phone being part of the same
network and test with a branch that has a crash. For example the one in
https://github.com/xamarin/xamarin-macios/pull/8009 hash 83240612e8
This commit is contained in:
Manuel de la Pena 2020-02-29 08:45:48 -05:00 коммит произвёл GitHub
Родитель 9a538f13db
Коммит 8664a96f72
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 14 добавлений и 3 удалений

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

@ -887,10 +887,21 @@ namespace xharness
FailureMessage = $"Launch failure";
if (Harness.InCI)
XmlResultParser.GenerateFailure (Logs, "launch", appName, Variation, $"AppLaunch on {device_name}", $"{FailureMessage} on {device_name}", main_log.FullPath, XmlResultJargon.NUnitV3);
} else if (crashed && (!File.Exists (listener_log.FullPath) || string.IsNullOrEmpty (crash_reason)) && Harness.InCI) {
} else if (!isSimulator && crashed && string.IsNullOrEmpty (crash_reason) && Harness.InCI) {
// this happens more that what we would like on devices, the main reason most of the time is that we have had netwoking problems and the
// tcp connection could not be stablished. We are going to report it as an error since we have not parsed the logs, evne when the app might have
// not crashed.
// not crashed. We need to check the main_log to see if we do have an tcp issue or not
var isTcp = false;
using (var reader = new StreamReader (main_log.FullPath)) {
string line;
while ((line = reader.ReadLine ()) != null) {
if (line.Contains ("Couldn't establish a TCP connection with any of the hostnames")) {
isTcp = true;
break;
}
}
}
if (isTcp)
XmlResultParser.GenerateFailure (Logs, "tcp-connection", appName, Variation, $"TcpConnection on {device_name}", $"Device {device_name} could not reach the host over tcp.", main_log.FullPath, Harness.XmlJargon);
} else if (timed_out && Harness.InCI) {
XmlResultParser.GenerateFailure (Logs, "timeout", appName, Variation, "AppTimeout", $"Test run timed out after {timeout.TotalMinutes} minute(s).", main_log.FullPath, Harness.XmlJargon);