CorpDirTestInfoContainer LoadFromFarmTaskInfo(IFarmTaskInfo farmTaskInfo, string realUrl)
        {
            CorpDirTestInfoContainer corpDirTestInfoContainer = TestLoader.LoadFromInfo(farmTaskInfo, realUrl);

            loadingProgressController.Enlarge(corpDirTestInfoContainer.FailedTests.Count);
            return(corpDirTestInfoContainer);
        }
        async Task <TestInfoCached> LoadTestsCoreAsync(IFarmTaskInfo farmTaskInfo)
        {
            string realUrl = await CapureRealUrl(farmTaskInfo.Url).ConfigureAwait(false);

            if (RealUrlCache.TryGetValue(farmTaskInfo, out TestInfoCached cache))
            {
                if (cache.RealUrl == realUrl)
                {
                    ActualizeTests(cache.TestList);
                    return(cache);
                }
            }
            List <Task <TestInfo> >  allTasks = new List <Task <TestInfo> >();
            CorpDirTestInfoContainer corpDirTestInfoContainer = LoadFromFarmTaskInfo(farmTaskInfo, realUrl);

            foreach (var corpDirTestInfo in corpDirTestInfoContainer.FailedTests)
            {
                CorpDirTestInfo info = corpDirTestInfo;
                allTasks.Add(Task.Factory.StartNew <TestInfo>(() => LoadTestInfo(info, corpDirTestInfoContainer.Teams)));
            }
            List <TestInfo> result      = (await Task.WhenAll(allTasks.ToArray()).ConfigureAwait(false)).ToList();
            TestInfoCached  cachedValue = new TestInfoCached(farmTaskInfo.Repository, realUrl, result, corpDirTestInfoContainer);

            RealUrlCache[farmTaskInfo] = cachedValue;
            return(cachedValue);
        }
        async Task <ITestInfoContainer> LoadTestsAsync(List <IFarmTaskInfo> farmTasks, INotificationService notificationService)
        {
            loadingProgressController.Flush();
            loadingProgressController.Enlarge(farmTasks.Count);
            loggingService.SendMessage($"Collecting tests information from farm");
            List <Task <TestInfoCached> > allTasks = new List <Task <TestInfoCached> >();

            foreach (IFarmTaskInfo farmTaskInfo in farmTasks)
            {
                if (String.IsNullOrEmpty(farmTaskInfo.Url))
                {
                    notificationService?.DoNotification($"Farm Task Not Found For {farmTaskInfo.Repository.Version}", $"Farm Task {farmTaskInfo.Repository.Version} from path {farmTaskInfo.Repository.Path} does not found. Maybe new branch created, but corresponding farm task missing. It well be added later. Otherwise, contact app owner for details.", System.Windows.MessageBoxImage.Information);
                    continue;
                }
                IFarmTaskInfo info = farmTaskInfo;
                var           task = LoadTestsCoreAsync(info);
                allTasks.Add(task);
            }
            TestInfoContainer result = new TestInfoContainer();

            foreach (TestInfoCached cached in await Task.WhenAll(allTasks.ToArray()).ConfigureAwait(false))
            {
                result.TestList.AddRange(cached.TestList);
                result.UsedFiles[cached.Repository]    = cached.UsedFiles;
                result.ElapsedTimes[cached.Repository] = cached.ElapsedTimes.Cast <IElapsedTimeInfo>().ToList();
                result.Teams[cached.Repository]        = cached.Teams;
            }
            return(result);
        }
示例#4
0
        static void ParseMessagePart(IFarmTaskInfo farmTaskInfo, string testNameAndNamespace, string message, List <CorpDirTestInfo> resultList)
        {
            List <string>   paths       = message.Split(new[] { @"\\corp" }, StringSplitOptions.RemoveEmptyEntries).ToList();
            List <string>   resultPaths = PatchPaths(paths);
            CorpDirTestInfo info        = null;

            if (!CorpDirTestInfo.TryCreate(farmTaskInfo, testNameAndNamespace, resultPaths, out info))
            {
                return;
            }
            resultList.Add(info);
        }
        public static CorpDirTestInfo CreateError(IFarmTaskInfo farmTaskInfo, string testNameAndNamespace, string errorText, string stackTrace)
        {
            CorpDirTestInfo result = new CorpDirTestInfo();

            result.FarmTaskInfo          = farmTaskInfo;
            result.ErrorText             = errorText;
            result.TeamName              = "Error";
            result.StackTrace            = stackTrace;
            result.TestName              = GetTestName(testNameAndNamespace);
            result.TestNameWithNamespace = testNameAndNamespace;
            return(result);
        }
示例#6
0
        public static void ParseMessage(IFarmTaskInfo farmTaskInfo, string testNameAndNamespace, string message, string stackTrace, List <CorpDirTestInfo> resultList)
        {
            if (!message.StartsWith("Exception - NUnit.Framework.AssertionException"))
            {
                resultList.Add(CorpDirTestInfo.CreateError(farmTaskInfo, testNameAndNamespace, message, stackTrace));
                return;
            }
            List <string> themedResultPaths = message.Split(new[] { " - failed:" }, StringSplitOptions.RemoveEmptyEntries).ToList();

            foreach (var part in themedResultPaths)
            {
                ParseMessagePart(farmTaskInfo, testNameAndNamespace, part, resultList);
            }
        }
示例#7
0
        public static CorpDirTestInfoContainer LoadFromInfo(IFarmTaskInfo taskInfo, string realUrl)
        {
            List <CorpDirTestInfo> failedTests = new List <CorpDirTestInfo>();

            if (realUrl == null || !realUrl.Contains("ViewBuildReport.aspx"))
            {
                throw new NotSupportedException("Contact Petr Zinovyev, please.");
            }
            XmlDocument myXmlDocument = new XmlDocument();

            myXmlDocument.Load(realUrl.Replace("ViewBuildReport.aspx", "XmlBuildLog.xml"));
            List <Task <List <CorpDirTestInfo> > > failedTestsTasks = new List <Task <List <CorpDirTestInfo> > >();

            if (!IsSuccessBuild(myXmlDocument))
            {
                foreach (XmlElement testCaseXml in FindFailedTests(myXmlDocument))
                {
                    string  testNameAndNamespace = testCaseXml.GetAttribute("name");
                    XmlNode failureNode          = testCaseXml.FindByName("failure");
                    failedTestsTasks.Add(Task.Factory.StartNew <List <CorpDirTestInfo> >(() => {
                        XmlNode resultNode              = failureNode.FindByName("message");
                        XmlNode stackTraceNode          = failureNode.FindByName("stack-trace");
                        List <CorpDirTestInfo> localRes = new List <CorpDirTestInfo>();
                        ParseMessage(taskInfo, testNameAndNamespace, resultNode.InnerText, stackTraceNode.InnerText, localRes);
                        return(localRes);
                    }));
                }
                if (failedTestsTasks.Count > 0)
                {
                    Task.WaitAll(failedTestsTasks.ToArray());
                    failedTestsTasks.ForEach(t => failedTests.AddRange(t.Result));
                }
                else
                {
                    if (!taskInfo.Success)
                    {
                        failedTests.Add(CorpDirTestInfo.CreateError(taskInfo, "BuildError", "BuildError", "BuildError"));
                    }
                }
            }
            return(new CorpDirTestInfoContainer(failedTests, FindUsedFiles(myXmlDocument).ToList(), FindElapsedTimes(myXmlDocument), FindTeams(taskInfo.Repository.Version, myXmlDocument)));
        }
        public static bool TryCreate(IFarmTaskInfo farmTaskInfo, string testNameAndNamespace, List <string> corpPaths, out CorpDirTestInfo result)
        {
            result = null;
            CorpDirTestInfo temp = new CorpDirTestInfo();

            temp.FarmTaskInfo          = farmTaskInfo;
            temp.TestName              = GetTestName(testNameAndNamespace);
            temp.TestNameWithNamespace = testNameAndNamespace;
            foreach (var path in corpPaths)
            {
                if (path.EndsWith("CurrentTextEdit.xml"))
                {
                    temp.CurrentTextEditPath = path;
                    continue;
                }
                if (path.EndsWith("InstantTextEdit.xml"))
                {
                    temp.InstantTextEditPath = path;
                    continue;
                }
                if (path.EndsWith("CurrentBitmap.png"))
                {
                    temp.CurrentImagePath = path;
                    continue;
                }
                if (path.EndsWith("InstantBitmap.png"))
                {
                    temp.InstantImagePath = path;
                    continue;
                }
                if (path.EndsWith("BitmapDif.png"))
                {
                    temp.ImageDiffPath = path;
                    continue;
                }
            }
            if (temp.CurrentTextEditPath != null && temp.CurrentImagePath != null) // && temp.ImageDiffPath != null
                                                                                   //&& temp.InstantTextEditPath != null && temp.InstantImagePath != null
            {
                temp.ServerFolderName = temp.CurrentTextEditPath.Split(new string[] { @"\\corp\builds\testbuilds\" }, StringSplitOptions.RemoveEmptyEntries).First().Split('\\').First();
                if (temp.ServerFolderName.Contains("_dpi_"))
                {
                    var nameAndDpi = temp.ServerFolderName.Split(new[] { "_dpi_" }, StringSplitOptions.RemoveEmptyEntries);
                    temp.TeamName = nameAndDpi[0];
                    temp.Dpi      = Int32.Parse(nameAndDpi[1]);
                }
                else
                {
                    temp.TeamName = temp.ServerFolderName;
                }
                string folderNameAndTheme = Path.GetDirectoryName(temp.CurrentTextEditPath).Split('\\').Last();
                if (!TryUpdateThemeAndFolderName(folderNameAndTheme, temp))
                {
                    return(false);
                }
                //string[] testNameAndTheme = Path.GetDirectoryName(temp.CurrentTextEditPath).Split('\\').Last().Split('.');
                //temp.TestName = testNameAndTheme[0];
                //temp.ThemeName = testNameAndTheme[1];
                //if(temp.InstantTextEditPath == null || temp.InstantImagePath == null) {
                //    temp.PossibleNewTest = true;
                //}
                //if(testNameAndTheme.Length > 2)
                //    temp.ThemeName += '.' + testNameAndTheme[2];
                result = temp;
                return(true);
            }
            return(false);
        }