Esempio n. 1
0
        private void ValidateData(ProcessedDataPackage data, ValidationResultsPackage resultsList)
        {
            lock (runningLock)
            {
                if (OnValidationStarted != null)
                {
                    OnValidationStarted(this);
                }

                IValidationResults vr = null;

                lock (this.validators)
                {
                    foreach (IDataValidator dv in this.validators)
                    {
                        try
                        {
                            vr = dv.Validate(data);
                            if (null == vr)
                            {
                                if (log.IsWarnEnabled)
                                {
                                    log.WarnFormat("Validation results from \"{0}\" were null.", dv);
                                }
                                continue;
                            }
                        }
                        catch (Exception ex)
                        {
                            if (log.IsErrorEnabled)
                            {
                                log.ErrorFormat("Exception while processing results with \"{0}\"", dv);
                                log.Error(ex);
                            }

                            continue;
                        }

                        vr.Validator = dv;
                        vr.GroupName = dv.GroupName;
                        if (vr != null && resultsList != null)
                        {
                            resultsList.AddLast(vr);
                        }

                        if (this.OnValidatorProgress != null)
                        {
                            this.OnValidatorProgress(this, dv, vr, vr != null);
                        }
                    }
                }

                IsRunning = false;

                if (OnValidationEnded != null)
                {
                    OnValidationEnded(this);
                }
            }
        }
Esempio n. 2
0
        private void ShowOutcome(String graphResults, ValidationResultsPackage validationResults, ProcessedDataPackage package)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new showOutcome(this.ShowOutcome), new object[] { graphResults, validationResults, package });
                return;
            }

            this.currentPackage = package;

            if (String.IsNullOrEmpty(graphResults) == false)
            {
                this.saveCollectionBtn.Enabled = true;
                ShowGraphPanel();
            }
            else if (validationResults != null && validationResults.Count > 0)
            {
                this.saveCollectionBtn.Enabled = true;
                ShowValidationResultsPanel();
            }
            else
            {
                MessageBox.Show("No results found!");
            }

            this.pageGraphBtn.Enabled         = String.IsNullOrEmpty(graphResults) == false;
            this.validationResultsBtn.Enabled = (validationResults != null && validationResults.Count > 0);

            this.graphViewPanel.SetResults(graphResults, package);
            this.validationResultsViewPanel.SetResults(validationResults);
        }
Esempio n. 3
0
        private static void SaveValidation(ValidationResultsPackage rsults, String outfolder)
        {
            XmlDocument xml = null;

            if ((xml = rsults.Serialize()) == null)
            {
                System.Console.Error.Write("Error while serializing validation results!");
                return;
            }

            xml.Save(outfolder + "/validationResults.xml");

            System.Console.WriteLine("Validation saved to:");
            System.Console.WriteLine("  " + outfolder + "/validationResults.xml");
        }
Esempio n. 4
0
        public ValidationResultsPackage ValidateBlocking(ProcessedDataPackage metaData)
        {
            lock (runningLock)
            {
                if (IsRunning)
                {
                    throw new Exception("Validator already running");
                }

                IsRunning = true;
                ValidationResultsPackage vr = new ValidationResultsPackage();
                ValidateData(metaData, vr);
                return(vr);
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            String p = @"C:\Data\Development\MySpace\Performance\Tracker\Reports.Performance\bin\Debug\";
            ProcessedDataPackage package1 = null;

            try
            {
                package1 = ProcessedDataCollector.CollectAll(p, 53595);
            }
            catch (DirectoryNotFoundException)
            {
                System.Console.Error.Write("Invalid input folder!");
                return;
            }



            return;



            CommandLineArguments cla = new CommandLineArguments(args);

            if (cla.IsValid() == false)
            {
                CommandLineArguments.PrintUsage(System.Console.Error);
                return;
            }

            String outfolder = Directory.GetCurrentDirectory().ToString().Replace("\\", "/");
            String confolder = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Program)).Location) + "\\conf\\";

            if (String.IsNullOrEmpty(confolder) ||
                String.IsNullOrEmpty(outfolder) ||
                Directory.Exists(confolder) == false ||
                Directory.Exists(outfolder) == false ||
                File.Exists(confolder + "DefaultPageValidation.xml") == false)
            {
                System.Console.Error.Write("Invalid Configuration!");
                return;
            }

            ProcessedDataPackage package = null;

            try
            {
                package = ProcessedDataCollector.CollectAll(cla.Path, cla.CollectionId);
            }
            catch (DirectoryNotFoundException)
            {
                System.Console.Error.Write("Invalid input folder!");
                return;
            }

            if (package == null || package.Count == 0)
            {
                System.Console.Error.Write("Error while processing data!");
                return;
            }

            ValidationRunner vr = new ValidationRunner();

            vr.LoadFromFile(confolder + "DefaultPageValidation.xml");

            ValidationResultsPackage rsults = vr.ValidateBlocking(package);


            if (rsults == null || rsults.Count == 0)
            {
                System.Console.Error.Write("Error while validating results!");
                return;
            }

            if ("xml".Equals(cla.SaveType))
            {
                SavePackage(new XMLImportExportManager(), package, outfolder);
            }
            else if ("msf".Equals(cla.SaveType))
            {
                SavePackage(new MSFImportExportsManager(), package, outfolder);
            }
            else if ("har".Equals(cla.SaveType))
            {
                SavePackage(new HARImportExportsManager(), package, outfolder);
            }

            SaveValidation(rsults, outfolder);
        }
Esempio n. 6
0
        private void ProcessResults(ProcessedDataPackage package)
        {
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");

            if (getter == null)
            {
                SetTestRunning(false);
                SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.InvalidConfiguration, -1);
            }

            #region Collected Data

            String graphResults = null;

            if (getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_GRAPH))
            {
                if (package.ContainsKey(typeof(DownloadData)) != false ||
                    package.ContainsKey(typeof(RenderData)) != false ||
                    package.ContainsKey(typeof(PerformanceData)) != false)
                {
                    SerializedResultsFilesInfo srfi = new SerializedResultsFilesInfo(package);

                    if (String.IsNullOrEmpty(srfi.GetFolderNameAndCheckIfValid()))
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.InvalidConfiguration, -1);
                        return;
                    }

                    package.ThumbnailsRoot = "file://" + srfi.GetFolderNameAndCheckIfValid();

                    XmlDocument x = package.Serialize();

                    if (x == null)
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.Unknown, -1);
                        return;
                    }

                    try
                    {
                        x.Save(srfi.GetFullPath());
                        graphResults = srfi.GetFullPath();
                    }
                    catch
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.Unknown, -1);
                        return;
                    }
                }
            }
            #endregion

            #region Validation

            ValidationResultsPackage validationResults = null;

            if (getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_VALIDATION))
            {
                if (validationRunner == null)
                {
                    CreateValidationRunner();
                }

                if (validationRunner != null)
                {
                    validationResults = validationRunner.ValidateBlocking(package);
                }
            }

            #endregion

            SetTestRunning(false);
            SetTestStatus(TestEventType.TestEnded, true);

            ShowOutcome(graphResults, validationResults, package);
        }