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);
        }
예제 #2
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);
        }
예제 #4
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);
            }
        }
        TestInfo LoadTestInfo(CorpDirTestInfo corpDirTestInfo, List <Team> teams)
        {
            loggingService.SendMessage($"Start load test v{corpDirTestInfo.FarmTaskInfo.Repository.Version} {corpDirTestInfo.TestName}.{corpDirTestInfo.ThemeName}");
            TestInfo testInfo = TryCreateTestInfo(corpDirTestInfo, teams ?? TeamConfigsReader.GetAllTeams());

            loggingService.SendMessage($"End load test v{corpDirTestInfo.FarmTaskInfo.Repository.Version} {corpDirTestInfo.TestName}.{corpDirTestInfo.ThemeName}");
            if (testInfo != null)
            {
                UpdateTestStatus(testInfo);
                loadingProgressController.IncreaseProgress(1);
                return(testInfo);
            }
            loadingProgressController.IncreaseProgress(1);
            return(null);
        }
예제 #6
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)));
        }
        static bool TryUpdateThemeAndFolderName(string folderNameAndTheme, CorpDirTestInfo result)
        {
            List <string> allThemes = ServiceLocator.Current.GetInstance <IThemesProvider>().AllThemes.ToList();

            allThemes.Add("Base");
            allThemes.Add("Super");
            allThemes.Sort(new ThemeNameComparer());
            foreach (string theme in allThemes.Where(t => t.Contains("Touch")).Concat(allThemes.Where(t => !t.Contains("Touch"))))
            {
                string themeName = theme.Replace(";", ".");
                if (!folderNameAndTheme.Contains(themeName))
                {
                    continue;
                }
                result.ThemeName          = themeName;
                result.ResourceFolderName = folderNameAndTheme.Replace("." + themeName, "");
                return(true);
            }
            return(false);
        }
        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);
        }
        static TestInfo TryCreateTestInfo(CorpDirTestInfo corpDirTestInfo, List <Team> teams)
        {
            TestInfo testInfo = new TestInfo(corpDirTestInfo.FarmTaskInfo.Repository);

            testInfo.Version            = corpDirTestInfo.FarmTaskInfo.Repository.Version;
            testInfo.Name               = corpDirTestInfo.TestName;
            testInfo.NameWithNamespace  = corpDirTestInfo.TestNameWithNamespace;
            testInfo.ResourceFolderName = corpDirTestInfo.ResourceFolderName;
            if (corpDirTestInfo.TeamName == CorpDirTestInfo.ErrorTeamName)
            {
                testInfo.Valid    = TestState.Error;
                testInfo.TextDiff = "+" + testInfo.Name + Environment.NewLine + Environment.NewLine + corpDirTestInfo.ErrorText;
                testInfo.Theme    = "Error";
                testInfo.Dpi      = 0;
                testInfo.Team     = new Team()
                {
                    Name = CorpDirTestInfo.ErrorTeamName, Version = corpDirTestInfo.FarmTaskInfo.Repository.Version
                };
                return(testInfo);
            }
            TeamInfo info = null;
            Team     team = testInfo.Team = GetTeam(teams, corpDirTestInfo.FarmTaskInfo.Repository.Version, corpDirTestInfo.ServerFolderName, out info);

            if (team == null)
            {
                testInfo.Valid    = TestState.Error;
                testInfo.TextDiff = "+" + testInfo.Name + Environment.NewLine + Environment.NewLine + corpDirTestInfo.ErrorText;
                testInfo.Theme    = "Error";
                testInfo.Dpi      = 0;
                testInfo.Team     = new Team()
                {
                    Name = CorpDirTestInfo.ErrorTeamName, Version = corpDirTestInfo.FarmTaskInfo.Repository.Version
                };
                return(testInfo);
            }
            testInfo.TeamInfo = info;
            testInfo.Dpi      = info.Dpi;
            testInfo.Theme    = corpDirTestInfo.ThemeName;
            if (Convert.ToInt32(testInfo.Version.Split('.')[0]) < 18)
            {
                if (testInfo.TeamInfo.Optimized.HasValue)
                {
                    testInfo.Optimized = !corpDirTestInfo.FarmTaskInfo.Url.Contains("UnoptimizedMode");
                }
            }
            else
            {
                //new version
                if (testInfo.TeamInfo.Optimized.HasValue)
                {
                    testInfo.Optimized = testInfo.TeamInfo.Optimized.Value;
                }
            }
            LoadTextFile(corpDirTestInfo.InstantTextEditPath, s => { testInfo.TextBefore = s; });
            LoadTextFile(corpDirTestInfo.CurrentTextEditPath, s => { testInfo.TextCurrent = s; });
            BuildTextDiff(testInfo);
            LoadImage(corpDirTestInfo.InstantImagePath, s => { testInfo.ImageBeforeArr = s; });
            LoadImage(corpDirTestInfo.CurrentImagePath, s => { testInfo.ImageCurrentArr = s; });
            LoadImage(corpDirTestInfo.ImageDiffPath, s => { testInfo.ImageDiffArr = s; });
            //if(TestValid(testInfo))
            //    testInfo.Valid = true;
            return(testInfo);
        }
예제 #10
0
        public static bool TryCreate(Repository repository,
                                     string fullName,
                                     string displayName,
                                     List <string> corpPaths,
                                     List <string> shaList,
                                     string category,
                                     string testResourcesFolder,
                                     List <TestProperty> properties,
                                     int?diffCount,
                                     out CorpDirTestInfo result)
        {
            result = null;
            var temp = new CorpDirTestInfo();

            temp.Repository            = repository;
            temp.Version               = repository.Version;
            temp.TestName              = displayName;
            temp.TestNameWithNamespace = fullName;
            temp.DiffCount             = diffCount;
            foreach (var path in corpPaths)
            {
                if (path.EndsWith("CurrentTextEdit.xml.sha"))
                {
                    temp.CurrentTextEditSHAPath = path;
                    continue;
                }

                if (path.EndsWith("CurrentTextEdit.xml"))
                {
                    temp.CurrentTextEditPath = path;
                    continue;
                }

                if (path.EndsWith("InstantTextEdit.xml.sha"))
                {
                    temp.InstantTextEditSHAPath = path;
                    continue;
                }

                if (path.EndsWith("InstantTextEdit.xml"))
                {
                    temp.InstantTextEditPath = path;
                    continue;
                }

                if (path.EndsWith("CurrentBitmap.png.sha"))
                {
                    temp.CurrentImageSHAPath = path;
                    continue;
                }

                if (path.EndsWith("CurrentBitmap.png"))
                {
                    temp.CurrentImagePath = path;
                    continue;
                }

                if (path.EndsWith("InstantBitmap.png.sha"))
                {
                    temp.InstantImageSHAPath = path;
                    continue;
                }

                if (path.EndsWith("InstantBitmap.png"))
                {
                    temp.InstantImagePath = path;
                    continue;
                }

                if (path.EndsWith("BitmapDif.png"))
                {
                    temp.ImageDiffPath = path;
                }
            }

            foreach (var sha in shaList)
            {
                if (sha.StartsWith("xml_current"))
                {
                    temp.CurrentTextEditSHA = ExtractSHA(sha);
                    continue;
                }

                if (sha.StartsWith("xml_instant"))
                {
                    temp.InstantTextEditSHA = ExtractSHA(sha);
                    continue;
                }

                if (sha.StartsWith("png_current"))
                {
                    temp.CurrentImageSHA = ExtractSHA(sha);
                    continue;
                }

                if (sha.StartsWith("png_instant"))
                {
                    temp.InstantImageSHA = ExtractSHA(sha);
                }
            }

            if (temp.CurrentTextEditPath == null || temp.CurrentImagePath == null)
            {
                return(false);
            }

            temp.TeamName = category;

            temp.ServerFolderName     = temp.CurrentTextEditPath.Split(new[] { @"\\corp\builds\testbuilds\" }, StringSplitOptions.RemoveEmptyEntries).First().Split('\\').First();
            temp.AdditionalParameters = properties;
            temp.ThemeName            = properties.FirstOrDefault(p => p.Name == "ThemeName")?.Value ?? ErrorName;
            temp.ResourcesFullPath    = Path.Combine(repository.Path, testResourcesFolder.Replace(@"C:\builds\", string.Empty));

            result = temp;
            return(true);
        }