Exemplo n.º 1
0
        /// <summary>
        /// Return all artifacts that are considered to have caused the test to fail
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerable <UnrealRoleArtifacts> GetArtifactsWithFailures()
        {
            if (SessionArtifacts == null)
            {
                Log.Warning("SessionArtifacts was null, unable to check for failures");
                return(new UnrealRoleArtifacts[0] {
                });
            }

            bool DidKillClients = SessionArtifacts.Any(A => A.SessionRole.RoleType.IsClient() && A.AppInstance.WasKilled);

            Dictionary <UnrealRoleArtifacts, int> ErrorCodes = new Dictionary <UnrealRoleArtifacts, int>();

            var FailureList = SessionArtifacts.Where(A =>
            {
                // ignore anything we killed
                if (A.AppInstance.WasKilled)
                {
                    return(false);
                }

                string ExitReason;
                int ExitCode = GetExitCodeAndReason(A, out ExitReason);

                ErrorCodes.Add(A, ExitCode);

                return(ExitCode != 0);
            });

            return(FailureList.OrderByDescending(A =>
            {
                int Score = 0;

                if (A.LogSummary.FatalError != null || (ErrorCodes[A] != 0 && A.AppInstance.WasKilled == false))
                {
                    Score += 100000;
                }

                Score += A.LogSummary.Ensures.Count();
                return Score;
            }).ToList());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses the provided artifacts to determine the cause of an exit and whether it was abnormal
        /// </summary>
        /// <param name="InArtifacts"></param>
        /// <param name="Reason"></param>
        /// <param name="WasAbnormal"></param>
        /// <returns></returns>
        protected virtual int GetExitCodeAndReason(UnrealRoleArtifacts InArtifacts, out string ExitReason)
        {
            UnrealLogParser.LogSummary LogSummary = InArtifacts.LogSummary;

            // Assume failure!
            int ExitCode = -1;

            ExitReason = "Unknown";

            if (LogSummary.FatalError != null)
            {
                ExitReason = "Process encountered fatal error";
            }
            else if (LogSummary.Ensures.Count() > 0 && CachedConfig.FailOnEnsures)
            {
                ExitReason = string.Format("Process encountered {0} Ensures", LogSummary.Ensures.Count());
            }
            else if (InArtifacts.AppInstance.WasKilled)
            {
                ExitReason = "Process was killed";
            }
            else if (LogSummary.HasTestExitCode)
            {
                if (LogSummary.TestExitCode == 0)
                {
                    ExitReason = "Process exited with code 0";
                }
                else
                {
                    ExitReason = string.Format("Process exited with error code {0}", LogSummary.TestExitCode);
                }

                ExitCode = LogSummary.TestExitCode;
            }
            else if (LogSummary.RequestedExit)
            {
                ExitReason = string.Format("Process requested exit with no fatal errors");
                ExitCode   = 0;
            }
            else
            {
                // ok, process appears to have exited for no good reason so try to divine a result...
                if (LogSummary.HasTestExitCode == false &&
                    InArtifacts.SessionRole.CommandLine.ToLower().Contains("-gauntlet"))
                {
                    Log.Verbose("Role {0} had 0 exit code but used Gauntlet and no TestExitCode was found. Assuming failure", InArtifacts.SessionRole.RoleType);
                    ExitCode   = -1;
                    ExitReason = "No test result from Gauntlet controller";
                }
            }

            // Normal exits from server are not ok if we had clients running!
            if (ExitCode == 0 && InArtifacts.SessionRole.RoleType.IsServer())
            {
                bool ClientsKilled = SessionArtifacts.Any(A => A.AppInstance.WasKilled && A.SessionRole.RoleType.IsClient());

                if (ClientsKilled)
                {
                    ExitCode   = -1;
                    ExitReason = "Server exited while clients were running";
                }
            }

            if (ExitCode == -1 && string.IsNullOrEmpty(ExitReason))
            {
                ExitReason = "Process exited with no indication of success";
            }

            return(ExitCode);
        }