Example #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new SkylineNightly());
                return;
            }

            var  nightly = new Nightly();
            bool hasPerftests;

            switch (args[0].ToLower())
            {
            case SCHEDULED_PERFTESTS_ARG:
                nightly.Run(true);      // Include perf tests
                hasPerftests = nightly.Parse();
                if (!hasPerftests)
                {
                    throw new InvalidDataException("Unexpected lack of perf tests in perftest scheduled run");     // Not L10N
                }
                nightly.Post(true);
                break;

            case SCHEDULED_ARG:
                nightly.Run(false);     // No perf tests
                hasPerftests = nightly.Parse();
                if (hasPerftests)
                {
                    throw new InvalidDataException("Unexpected perf tests in non-perftest scheduled run");     // Not L10N
                }
                nightly.Post(false);
                break;

            case PARSE_ARG:
                hasPerftests = nightly.Parse();
                nightly.Post(hasPerftests);
                break;

            case POST_ARG:
                hasPerftests = nightly.Parse(null, true);
                nightly.Post(hasPerftests);
                break;

            default:
                var extension = Path.GetExtension(args[0]).ToLower();
                if (extension == ".log")                   // Not L10N
                {
                    hasPerftests = nightly.Parse(args[0]); // Create the xml for this log file
                }
                else
                {
                    hasPerftests = nightly.Parse(Path.ChangeExtension(args[0], ".log"), true); // Scan the log file for this XML // Not L10N
                }
                nightly.Post(hasPerftests, Path.ChangeExtension(args[0], ".xml"));             // Not L10N
                break;
            }
        }
Example #2
0
        private static void PerformTests(Nightly.RunMode runMode, string arg, string decorateSrcDirName = null)
        {
            var nightly    = new Nightly(runMode, decorateSrcDirName);
            var errMessage = nightly.RunAndPost();
            var message    = string.Format("Completed {0}", arg); // Not L10N

            nightly.Finish(message, errMessage);
        }
Example #3
0
        private static bool PerformTests(Nightly.RunMode runMode, string arg, string decorateSrcDirName = null)
        {
            var nightly    = new Nightly(runMode, decorateSrcDirName);
            var errMessage = nightly.RunAndPost();
            var message    = string.Format(@"Completed {0}", arg);

            nightly.Finish(message, errMessage);
            return(string.IsNullOrEmpty(errMessage));
        }
Example #4
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new SkylineNightly());
                return;
            }

            var nightly = new Nightly();
            bool hasPerftests;

            switch (args[0].ToLower())
            {
                case SCHEDULED_PERFTESTS_ARG:
                    nightly.Run(true);  // Include perf tests
                    hasPerftests = nightly.Parse();
                    if (!hasPerftests)
                        throw new InvalidDataException("Unexpected lack of perf tests in perftest scheduled run"); // Not L10N
                    nightly.Post(true);
                    break;

                case SCHEDULED_ARG:
                    nightly.Run(false); // No perf tests
                    hasPerftests = nightly.Parse();
                    if (hasPerftests)
                        throw new InvalidDataException("Unexpected perf tests in non-perftest scheduled run"); // Not L10N
                    nightly.Post(false);
                    break;

                case PARSE_ARG:
                    hasPerftests = nightly.Parse();
                    nightly.Post(hasPerftests);
                    break;

                case POST_ARG:
                    hasPerftests = nightly.Parse(null, true);
                    nightly.Post(hasPerftests);
                    break;

                default:
                    var extension = Path.GetExtension(args[0]).ToLower();
                    if (extension == ".log") // Not L10N
                        hasPerftests = nightly.Parse(args[0]); // Create the xml for this log file
                    else
                        hasPerftests = nightly.Parse(Path.ChangeExtension(args[0], ".log"), true); // Scan the log file for this XML // Not L10N
                    nightly.Post(hasPerftests, Path.ChangeExtension(args[0], ".xml")); // Not L10N
                    break;
            }
        }
Example #5
0
 public LogFileMonitor(string logDir, string nightlyLog, Nightly.RunMode runMode)
 {
     _oldLog              = Nightly.GetLatestLog(logDir);
     _logDir              = logDir;
     _nightlyLog          = nightlyLog;
     _runMode             = runMode;
     _testerLog           = null;
     _lock                = new object();
     _fileStream          = null;
     _lastReportedHang    = new DateTime();
     _buffer              = new byte[8192];
     _builder             = new StringBuilder();
     _logTail             = "";
     _logChecker          = new Timer(10000); // check log file every 10 seconds
     _logChecker.Elapsed += IntervalElapsed;
 }
Example #6
0
        private static bool PerformTests(Nightly.RunMode runMode, string arg, string decorateSrcDirName = null)
        {
            var nightly     = new Nightly(runMode, decorateSrcDirName);
            var nightlyTask = Nightly.NightlyTask;

            if (nightlyTask != null && DateTime.UtcNow.Add(nightly.TargetDuration).ToLocalTime() > nightlyTask.NextRunTime)
            {
                // Don't run, because the projected end time is after the start of the next scheduled start
                return(false);
            }
            var errMessage = nightly.RunAndPost();
            var message    = string.Format(@"Completed {0}", arg);

            nightly.Finish(message, errMessage);
            return(string.IsNullOrEmpty(errMessage));
        }
Example #7
0
 private static void SendEmailNotification(string subject, string message)
 {
     Nightly.SendEmailNotification(null, subject, message);
 }
Example #8
0
 private void Log(string message)
 {
     Nightly.Log(_nightlyLog, message);
 }
Example #9
0
        private void IntervalElapsed(object source, ElapsedEventArgs e)
        {
            if (!Monitor.TryEnter(_lock))
            {
                return;
            }

            try
            {
                if (_fileStream == null)
                {
                    var log = Nightly.GetLatestLog(_logDir);
                    if (Equals(log, _oldLog))
                    {
                        return;
                    }
                    _testerLog  = log;
                    _fileStream = new FileStream(log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                }

                if (HangThreshold > 0)
                {
                    var lastWrite = File.GetLastWriteTime(_testerLog);
                    if (lastWrite.AddMinutes(HangThreshold) <= e.SignalTime)
                    {
                        if (lastWrite > _lastReportedHang)
                        {
                            _lastReportedHang = lastWrite;
                            Log("Hang detected, posting to " + Nightly.LABKEY_EMAIL_NOTIFICATION_URL);
                            var message = new StringBuilder();
                            message.AppendFormat("{0} ({1})", Environment.MachineName, RunModeName);
                            message.AppendLine();
                            message.AppendLine("Hang detected");
                            message.AppendLine();
                            message.AppendFormat("Current time: {0} {1}" + Environment.NewLine, e.SignalTime.ToShortDateString(), e.SignalTime.ToShortTimeString());
                            message.AppendFormat("Log last modified: {0} {1}" + Environment.NewLine, lastWrite.ToShortDateString(), lastWrite.ToShortTimeString());
                            message.AppendLine();
                            message.AppendLine("----------------------------------------");
                            message.AppendLine("...");
                            message.Append(_logTail);
                            message.AppendLine();
                            SendEmailNotification(string.Format("[{0} ({1})] !!! TestResults alert", Environment.MachineName, RunModeName), message.ToString());
                        }
                        return;
                    }
                }

                var totalN = 0;
                for (var n = _fileStream.Read(_buffer, 0, _buffer.Length); n > 0; n = _fileStream.Read(_buffer, 0, _buffer.Length))
                {
                    totalN += n;
                    _builder.Append(Encoding.UTF8.GetString(_buffer, 0, n));
                    if (n < _buffer.Length)
                    {
                        break;
                    }
                }

                if (totalN == 0)
                {
                    return;
                }

                var s = _builder.ToString();

                _logTail += s.Substring(s.Length - totalN);
                const int tailLineCount = 20;
                var       tailLines     = _logTail.Split('\n');
                _logTail = string.Join("\n", tailLines.Length > tailLineCount ? tailLines.Skip(tailLines.Length - tailLineCount) : tailLines);

                var lastBreak = s.LastIndexOf('\n');
                if (lastBreak < 0)
                {
                    return;
                }

                _builder.Remove(0, lastBreak + 1);
                foreach (var line in s.Substring(0, lastBreak).Split(new[] { "\r", "\n", "\r\n" }, StringSplitOptions.None))
                {
                    // process lines
                }
            }
            catch
            {
                // ignored
            }
            finally
            {
                Monitor.Exit(_lock);
            }
        }
Example #10
0
        static void Main(string[] args)
        {
            if (Settings.Default.SettingsUpgradeRequired)
            {
                Settings.Default.Upgrade();
                Settings.Default.SettingsUpgradeRequired = false;
                Settings.Default.Save();
            }

            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new SkylineNightly());
                return;
            }

            try
            {
                var command = args[0].ToLower();

                Nightly.RunMode runMode;

                string  message;
                string  errMessage = string.Empty;
                Nightly nightly;

                switch (command)
                {
                case @"run":
                {
                    switch (args.Length)
                    {
                    case 2:
                    {
                        PerformTests((Nightly.RunMode)Enum.Parse(typeof(Nightly.RunMode), args[1]), args[1]);
                        break;
                    }

                    case 3:
                    {
                        PerformTests((Nightly.RunMode)Enum.Parse(typeof(Nightly.RunMode), args[1]),
                                     (Nightly.RunMode)Enum.Parse(typeof(Nightly.RunMode), args[2]),
                                     args[1] + @" then " + args[2]);
                        break;
                    }

                    default: throw new Exception(@"Wrong number of run modes specified, has to be 1 or 2");
                    }

                    break;
                }

                case "indefinitely":
                {
                    while (PerformTests((Nightly.RunMode)Enum.Parse(typeof(Nightly.RunMode), args[1]), args[1]))
                    {
                    }

                    break;
                }

                case @"/?":
                {
                    nightly = new Nightly(Nightly.RunMode.trunk);
                    string commands = string.Join(@" | ",
                                                  SkylineNightly.RunModes.Select(r => r.ToString()).ToArray());
                    message = string.Format(@"Usage: SkylineNightly run [{0}] [{1}]", commands, commands);
                    nightly.Finish(message, errMessage);
                    break;
                }

                case @"parse":
                {
                    nightly = new Nightly(Nightly.RunMode.parse);
                    message = string.Format(@"Parse and post log {0}", nightly.GetLatestLog());
                    nightly.StartLog(Nightly.RunMode.parse);
                    runMode    = nightly.Parse();
                    message   += string.Format(@" as runmode {0}", runMode);
                    errMessage = nightly.Post(runMode);
                    nightly.Finish(message, errMessage);
                    break;
                }

                case @"post":
                {
                    nightly = new Nightly(Nightly.RunMode.post);
                    message = string.Format(@"Post existing XML for {0}", nightly.GetLatestLog());
                    nightly.StartLog(Nightly.RunMode.post);
                    runMode    = nightly.Parse(null, true);  // "true" means skip XML generation, just parse to figure out mode
                    message   += string.Format(@" as runmode {0}", runMode);
                    errMessage = nightly.Post(runMode);
                    nightly.Finish(message, errMessage);
                    break;
                }

                default:
                {
                    var extension = Path.GetExtension(args[0]).ToLower();
                    if (extension == @".log")
                    {
                        nightly = new Nightly(Nightly.RunMode.parse);
                        nightly.StartLog(Nightly.RunMode.parse);
                        message = string.Format(@"Parse and post log {0}", args[0]);
                        runMode = nightly.Parse(args[0]);     // Create the xml for this log file
                    }
                    else
                    {
                        nightly = new Nightly(Nightly.RunMode.post);
                        nightly.StartLog(Nightly.RunMode.post);
                        message = string.Format(@"Post existing XML {0}", args[0]);
                        runMode = nightly.Parse(Path.ChangeExtension(args[0], @".log"), true);     // Scan the log file for this XML
                    }
                    message   += string.Format(@" as runmode {0}", runMode);
                    errMessage = nightly.Post(runMode, Path.ChangeExtension(args[0], @".xml"));
                    nightly.Finish(message, errMessage);
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(@"Exception Caught: " + ex.Message, @"SkylineNightly.exe");
            }
        }
Example #11
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new SkylineNightly());
                return;
            }

            Nightly.RunMode runMode;

            // ReSharper disable LocalizableElement
            string  arg = args[0].ToLower();
            string  message;
            string  errMessage = string.Empty;
            Nightly nightly;

            switch (arg)
            {
            case HELP_ARG:
                nightly = new Nightly(Nightly.RunMode.trunk);
                message = string.Format("Usage: SkylineNightly [" + string.Join(" | ", ARG_NAMES) + "]");     // Not L10N
                nightly.Finish(message, errMessage);
                break;

            // Run the current integration branch
            case SCHEDULED_INTEGRATION_ARG:
                PerformTests(Nightly.RunMode.integration, string.Format("Completed {0}", arg));     // Not L10N
                break;

            // For machines that can test all day and all night:
            // Run current integration branch, then normal
            case SCHEDULED_INTEGRATION_TRUNK_ARG:
                PerformTests(Nightly.RunMode.integration, Nightly.RunMode.trunk, arg);
                break;

            // For machines that can test all day and all night:
            // Run normal mode, then perftests
            case SCHEDULED_PERFTEST_AND_TRUNK_ARG:
                PerformTests(Nightly.RunMode.trunk, Nightly.RunMode.perf, arg);
                break;

            // For machines that can test all day and all night:
            // Run normal mode, then run it again
            case SCHEDULED_TRUNK_AND_TRUNK_ARG:
                PerformTests(Nightly.RunMode.trunk, Nightly.RunMode.trunk, arg);
                break;

            case SCHEDULED_PERFTESTS_ARG:
                PerformTests(Nightly.RunMode.perf, arg);     // Not L10N
                break;

            case SCHEDULED_STRESSTESTS_ARG:
                PerformTests(Nightly.RunMode.stress, arg);     // Not L10N
                break;

            case SCHEDULED_RELEASE_BRANCH_ARG:
                PerformTests(Nightly.RunMode.release, arg);     // Not L10N
                break;

            case SCHEDULED_ARG:
                PerformTests(Nightly.RunMode.trunk, arg);     // Not L10N
                break;

            // Reparse and post the most recent log
            case PARSE_ARG:
                nightly = new Nightly(Nightly.RunMode.parse);
                message = string.Format("Parse and post log {0}", nightly.GetLatestLog());     // Not L10N
                nightly.StartLog(Nightly.RunMode.parse);
                runMode    = nightly.Parse();
                message   += string.Format(" as runmode {0}", runMode);   // Not L10N
                errMessage = nightly.Post(runMode);
                nightly.Finish(message, errMessage);
                break;

            // Post the XML for the latest log without regenerating it
            case POST_ARG:
                nightly = new Nightly(Nightly.RunMode.post);
                message = string.Format("Post existing XML for {0}", nightly.GetLatestLog()); // Not L10N
                nightly.StartLog(Nightly.RunMode.post);
                runMode    = nightly.Parse(null, true);                                       // "true" means skip XML generation, just parse to figure out mode
                message   += string.Format(" as runmode {0}", runMode);                       // Not L10N
                errMessage = nightly.Post(runMode);
                nightly.Finish(message, errMessage);
                break;

            default:
                var extension = Path.GetExtension(arg).ToLower();
                if (extension == ".log")     // Not L10N
                {
                    nightly = new Nightly(Nightly.RunMode.parse);
                    nightly.StartLog(Nightly.RunMode.parse);
                    message = string.Format("Parse and post log {0}", arg); // Not L10N
                    runMode = nightly.Parse(arg);                           // Create the xml for this log file
                }
                else
                {
                    nightly = new Nightly(Nightly.RunMode.post);
                    nightly.StartLog(Nightly.RunMode.post);
                    message = string.Format("Post existing XML {0}", arg);             // Not L10N
                    runMode = nightly.Parse(Path.ChangeExtension(arg, ".log"), true);  // Scan the log file for this XML // Not L10N
                }
                message   += string.Format(" as runmode {0}", runMode);                // Not L10N
                errMessage = nightly.Post(runMode, Path.ChangeExtension(arg, ".xml")); // Not L10N
                nightly.Finish(message, errMessage);
                break;
            }
        }