示例#1
0
        public void DownloadSpecificCab()
        {
            if (!AtomTestSettings.EnableWinQualCabDownloadTests)
            {
                return;
            }

            AtomFeed atomFeed = new AtomFeed(null, 2, 100000, false, true, null, 11);

            // ATOM LOGIN.
            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            StackHashCab cab    = new StackHashCab(DateTime.Now, DateTime.Now, 1886116627, "CLR20 Managed Crash", "fred.txt", 1188442827, 924210);
            AtomCab      newCab = new AtomCab(cab, AtomCab.MakeLink("CLR20 Managed Crash", 1886116627, 1188442827, 924210));

            String tempFolder = Path.GetTempPath();

            String fileName = atomFeed.DownloadCab(newCab, true, tempFolder);

            try
            {
                Assert.AreEqual(true, File.Exists(fileName));
                FileInfo fileInfo = new FileInfo(fileName);

                Assert.AreEqual(946386, fileInfo.Length);
            }
            finally
            {
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
            }
        }
示例#2
0
        public void GetProducts()
        {
            if (!AtomTestSettings.EnableWinQualProductTests)
            {
                return;
            }

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, true, null, 11);

            // ATOM LOGIN.
            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            try
            {
                AtomProductCollection products = atomFeed.GetProducts();

                Assert.AreEqual(true, products.Count > 0);

                Assert.AreEqual(true, products.DateFeedUpdated < DateTime.Now);
            }
            finally
            {
                try
                {
                    atomFeed.LogOut();
                }
                catch
                {
                }
            }
        }
示例#3
0
        public void UploadMappingFile()
        {
            if (!AtomTestSettings.EnableWinQualUploadFileTests)
            {
                return;
            }

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, true, null, 11);

            // ATOM LOGIN.
            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            try
            {
                atomFeed.UploadFile(@"R:\stackhash\BusinessLogic\BusinessLogic\TestData\MappingFiles\1.0.4511.261.xml");
            }
            finally
            {
                try
                {
                    atomFeed.LogOut();
                }
                catch
                {
                }
            }
        }
示例#4
0
        public void GetFiles()
        {
            if (!AtomTestSettings.EnableWinQualFilesTests)
            {
                return;
            }

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, true, null, 11);

            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));


            try
            {
                // ATOM GetProducts.
                AtomProductCollection atomProducts = atomFeed.GetProducts();

                foreach (AtomProduct atomProduct in atomProducts)
                {
                    AtomFileCollection files = atomFeed.GetFiles(atomProduct);

                    Assert.AreEqual(true, files.Count > 0);
                }
            }
            finally
            {
                try
                {
                    atomFeed.LogOut();
                }
                catch
                {
                }
            }
        }
示例#5
0
        public void GetCabs()
        {
            if (!AtomTestSettings.EnableWinQualCabDownloadTests)
            {
                return;
            }

            DateTime startTime = DateTime.Now.AddDays(-89);

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, true, null, 11);

            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            try
            {
                // ATOM GetProducts.
                AtomProductCollection atomProducts = atomFeed.GetProducts();

                bool foundCab = false;

                foreach (AtomProduct atomProduct in atomProducts)
                {
                    AtomFileCollection atomFiles = atomFeed.GetFiles(atomProduct);

                    foreach (AtomFile atomFile in atomFiles)
                    {
                        AtomEventCollection atomEvents = atomFeed.GetEvents(atomFile, startTime);

                        foreach (AtomEvent atomEvent in atomEvents)
                        {
                            AtomCabCollection eventCabs = atomFeed.GetCabs(atomEvent);

                            foreach (AtomCab eventCab in eventCabs)
                            {
                                Assert.AreEqual(true, eventCab.Cab.DateCreatedLocal < DateTime.Now);
                                foundCab = true;
                            }

                            if (foundCab)
                            {
                                return;
                            }
                        }
                    }
                }

                Assert.AreEqual(true, false); // Should get here.
            }
            finally
            {
                try { atomFeed.LogOut(); }
                catch { }
            }
        }
示例#6
0
        public void GetEventInfos()
        {
            if (!AtomTestSettings.EnableWinQualEventsTests)
            {
                return;
            }

            DateTime startTime = DateTime.Now.AddMonths(-1);

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, true, null, 11);

            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            try
            {
                // ATOM GetProducts.
                AtomProductCollection atomProducts = atomFeed.GetProducts();

                bool foundAnEventInfo = false;

                foreach (AtomProduct atomProduct in atomProducts)
                {
                    AtomFileCollection atomFiles = atomFeed.GetFiles(atomProduct);

                    foreach (AtomFile atomFile in atomFiles)
                    {
                        AtomEventCollection atomEvents = atomFeed.GetEvents(atomFile, startTime);

                        foreach (AtomEvent atomEvent in atomEvents)
                        {
                            AtomEventInfoCollection eventInfos = atomFeed.GetEventDetails(atomEvent, 89);

                            foreach (AtomEventInfo eventInfo in eventInfos)
                            {
                                Assert.AreEqual(true, eventInfo.EventInfo.DateCreatedLocal < DateTime.Now);
                                foundAnEventInfo = true;
                            }

                            if (foundAnEventInfo)
                            {
                                return;
                            }
                        }
                    }
                }
                Assert.AreEqual(true, false); // Should get here.
            }
            finally
            {
                try { atomFeed.LogOut(); }
                catch { }
            }
        }
示例#7
0
        public void GetProductsCalls24Hours()
        {
            if (!AtomTestSettings.EnableWinQualProductTests)
            {
                return;
            }

            AtomFeed atomFeed = new AtomFeed(null, 10, 100000, false, true, null, 11);

            // ATOM LOGIN.
            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));


            int      count     = 0;
            DateTime startTime = DateTime.Now;

            try
            {
                Console.WriteLine("StartTime = " + startTime.ToString());


                while (true)
                {
                    count++;
                    Console.WriteLine("Count: " + count.ToString());

                    AtomProductCollection products = atomFeed.GetProducts();
                    Assert.AreEqual(true, products.Count > 10);

                    // Wait for 15 mins before retrying.
                    Thread.Sleep(15 * 60 * 1000);
                }
            }
            catch (System.Exception ex)
            {
                DateTime endTime = DateTime.Now;
                Console.WriteLine("Crashed " + ex.ToString());
            }
            finally
            {
                try
                {
                    atomFeed.LogOut();
                }
                catch
                {
                }
            }
        }
示例#8
0
        public void GetEvents()
        {
            if (!AtomTestSettings.EnableWinQualEventsTests)
            {
                return;
            }

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, true, null, 11);

            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));


            try
            {
                AtomProductCollection atomProducts = atomFeed.GetProducts();

                int totalEvents = 0;


                // Just keep going until one set of events has been found.
                foreach (AtomProduct atomProduct in atomProducts)
                {
                    // ATOM GetFiles.
                    AtomFileCollection atomFiles = atomFeed.GetFiles(atomProduct);

                    foreach (AtomFile atomFile in atomFiles)
                    {
                        AtomEventCollection atomEvents = atomFeed.GetEvents(atomFile, DateTime.Now.AddDays(-89));

                        foreach (AtomEvent atomEvent in atomEvents)
                        {
                            Assert.AreEqual(true, atomEvent.Event.Id != 0);
                            totalEvents++;
                        }

                        if (totalEvents > 0)
                        {
                            return;
                        }
                    }
                }
            }
            finally
            {
                try { atomFeed.LogOut(); }
                catch { }
            }
        }
示例#9
0
        public void LogonWithGoodCredentials()
        {
            if (!AtomTestSettings.EnableWinQualLogOnTests)
            {
                return;
            }

            // Define the certificate policy for the application.
            ServicePointManager.ServerCertificateValidationCallback =
                new RemoteCertificateValidationCallback(MyCertificateValidation.ValidateServerCertificate);

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, true, null, 11);

            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            atomFeed.LogOut();
        }
示例#10
0
        public void CallFailsSoRetry()
        {
            AtomFeed atomFeed = new AtomFeed(null, 2, 100000, false, false, null, 11);

            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));
            String url = "https://winqual.microsoft.com/Services/wer/user/eventdetails.aspx?eventid=102983&eventtypename=Crash 32bit";

            try
            {
                atomFeed.WinQualCallWithRetry(url, RequestType.Get, null, null);
            }
            catch (StackHashException ex)
            {
                Assert.AreEqual(StackHashServiceErrorCode.AccessDenied, ex.ServiceErrorCode);
            }

            Assert.AreEqual(2, atomFeed.LastCallRetryCount);
        }
示例#11
0
        public void LogonWithBadCredentials()
        {
            if (!AtomTestSettings.EnableWinQualLogOnTests)
            {
                return;
            }

            // Define the certificate policy for the application.
            ServicePointManager.ServerCertificateValidationCallback =
                new RemoteCertificateValidationCallback(MyCertificateValidation.ValidateServerCertificate);
            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, true, null, 11);

            try
            {
                Assert.AreEqual(false, atomFeed.Login("Username", "Password"));
            }
            catch (StackHashException ex)
            {
                Assert.AreEqual(true,
                                ex.Message.Contains("Please check that your Windows live id username and password are correct"));
            }
        }
示例#12
0
        public void DownloadSingleCab()
        {
            if (!AtomTestSettings.EnableWinQualCabDownloadTests)
            {
                return;
            }

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, false, null, 11);

            // ATOM LOGIN.
            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            // ATOM GetProducts.
            AtomProductCollection atomProducts = atomFeed.GetProducts();


            // WERAPI Login.
            Login login = new Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword);

            login.Validate();

            foreach (AtomProduct atomProduct in atomProducts)
            {
                Console.WriteLine("Processing product " + atomProduct.Product.Name + " " + atomProduct.Product.Id.ToString());

                // ATOM GetFiles.
                AtomFileCollection atomFiles = atomFeed.GetFiles(atomProduct);

                foreach (AtomFile atomFile in atomFiles)
                {
                    Console.WriteLine("Processing file " + atomFile.File.Name + " " + atomFile.File.Id.ToString());
                    // ATOM GetEvents.
                    AtomEventCollection atomEvents = atomFeed.GetEvents(atomFile);

                    foreach (AtomEvent atomEvent in atomEvents)
                    {
                        Console.WriteLine("Processing event " + atomEvent.Event.Id.ToString());

                        // ATOM GetCabs.
                        AtomCabCollection atomCabs = atomFeed.GetCabs(atomEvent);

                        if (atomCabs.Count != 0)
                        {
                            StackHashCab cab = atomCabs[0].Cab;

                            // Convert back to an AtomCab.
                            AtomCab newCab = new AtomCab(cab, AtomCab.MakeLink(atomEvent.Event.EventTypeName, atomEvent.Event.Id, cab.Id, cab.SizeInBytes));

                            Console.WriteLine("Downloading cab " + cab.Id.ToString());

                            String tempFolder = Path.GetTempPath();

                            String fileName = atomFeed.DownloadCab(newCab, true, tempFolder);

                            try
                            {
                                Assert.AreEqual(true, File.Exists(fileName));
                                FileInfo fileInfo = new FileInfo(fileName);

                                Assert.AreEqual(cab.SizeInBytes, fileInfo.Length);
                            }
                            finally
                            {
                                if (File.Exists(fileName))
                                {
                                    File.Delete(fileName);
                                }
                            }

                            // 1 is enough.
                            return;
                        }
                    }
                }
            }
        }
示例#13
0
        public void DownloadCab()
        {
            if (!AtomTestSettings.EnableWinQualCabDownloadTests)
            {
                return;
            }

            DateTime startTime = DateTime.Now.AddDays(-89);

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, true, null, 11);

            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            try
            {
                // ATOM GetProducts.
                AtomProductCollection atomProducts = atomFeed.GetProducts();

                bool foundCab = false;

                foreach (AtomProduct atomProduct in atomProducts)
                {
                    AtomFileCollection atomFiles = atomFeed.GetFiles(atomProduct);

                    foreach (AtomFile atomFile in atomFiles)
                    {
                        AtomEventCollection atomEvents = atomFeed.GetEvents(atomFile, startTime);

                        foreach (AtomEvent atomEvent in atomEvents)
                        {
                            AtomCabCollection atomCabs = atomFeed.GetCabs(atomEvent);

                            foreach (AtomCab atomCab in atomCabs)
                            {
                                Assert.AreEqual(true, atomCab.Cab.DateCreatedLocal < DateTime.Now);

                                String tempFolder = Path.GetTempPath();

                                String fileName = atomFeed.DownloadCab(atomCab, true, tempFolder);

                                try
                                {
                                    Assert.AreEqual(true, File.Exists(fileName));
                                    FileInfo fileInfo = new FileInfo(fileName);

                                    Assert.AreEqual(atomCab.Cab.SizeInBytes, fileInfo.Length);
                                }
                                finally
                                {
                                    if (File.Exists(fileName))
                                    {
                                        File.Delete(fileName);
                                    }
                                }

                                foundCab = true;
                            }

                            if (foundCab)
                            {
                                return;
                            }
                        }
                    }
                }

                Assert.AreEqual(true, false); // Should get here.
            }
            finally
            {
                try { atomFeed.LogOut(); }
                catch { }
            }
        }
示例#14
0
        public void GetEventsStartDate()
        {
            DateTime startTime = DateTime.Now.AddMonths(-1);

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, false, null, 11);

            // ATOM LOGIN.
            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            // ATOM GetProducts.
            AtomProductCollection atomProducts = atomFeed.GetProducts();


            // WERAPI Login.
            Login login = new Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword);

            login.Validate();

            // WERAPI GetProducts.
            ProductCollection apiProducts = Product.GetProducts(ref login);

            Assert.AreEqual(atomProducts.Count, apiProducts.Count);

            bool eventListsDifferent = false;

            foreach (AtomProduct atomProduct in atomProducts)
            {
                // ATOM GetFiles.
                AtomFileCollection atomFiles = atomFeed.GetFiles(atomProduct);

                // API GetFiles
                Product apiProduct = Utils.FindProduct(apiProducts, atomProduct.Product.Id);
                ApplicationFileCollection apiFiles = apiProduct.GetApplicationFiles(ref login);

                Assert.AreEqual(atomFiles.Count, apiFiles.Count);

                foreach (AtomFile atomFile in atomFiles)
                {
                    ApplicationFile apiFile = Utils.FindFile(apiFiles, atomFile.File.Id);

                    // ATOM GetEvents.
                    StackHashEventCollection atomStackHashEvents       = Utils.GetEventsAtom(atomFeed, atomFile, startTime);
                    StackHashEventCollection atomStackHashEventsNoTime = Utils.GetEventsAtom(atomFeed, atomFile);

                    if (atomStackHashEvents.Count != atomStackHashEventsNoTime.Count)
                    {
                        eventListsDifferent = true;
                    }

                    // WERAPI GetEvents.
                    List <Event>             rawApiEvents;
                    StackHashEventCollection apiStackHashEvents = Utils.GetEventsApi(ref login, apiFile, out rawApiEvents, startTime);

                    Assert.AreEqual(apiStackHashEvents.Count, atomStackHashEvents.Count);

                    foreach (StackHashEvent stackHashEvent in atomStackHashEvents)
                    {
                        // Find the equivalent event in the api file list.
                        StackHashEvent apiEvent = apiStackHashEvents.FindEvent(stackHashEvent.Id, stackHashEvent.EventTypeName);

                        Assert.AreNotEqual(null, apiEvent);

                        Assert.AreEqual(true, stackHashEvent.CompareTo(apiEvent) == 0);
                    }
                }
            }

            Assert.AreEqual(true, eventListsDifferent);
        }
示例#15
0
        static void Go(ProgramArguments programArguments)
        {
            LogManager logger = new LogManager();

            logger.StartLogging();
            bool noCabs = false;

            try
            {
                StackHashUtilities.SystemInformation.DisableSleep();

                AtomFeed atomFeed = new AtomFeed(programArguments.ProxySettings, 5, 300000, programArguments.LogXml, true, programArguments.IPAddress, 11);

                if (!atomFeed.Login(programArguments.UserName, programArguments.Password))
                {
                    DiagnosticsHelper.LogMessage(DiagSeverity.Information, "Failed to logon - check your username and password");
                    return;
                }
                else
                {
                    DiagnosticsHelper.LogMessage(DiagSeverity.Information, "Logged on successfully.");
                }

                // ATOM GetProducts.
                AtomProductCollection atomProducts = atomFeed.GetProducts();

                foreach (AtomProduct atomProduct in atomProducts)
                {
                }

                foreach (AtomProduct atomProduct in atomProducts)
                {
                    DiagnosticsHelper.LogMessage(DiagSeverity.Information, atomProduct.Product.ToString());

                    // ATOM GetFiles.
                    AtomFileCollection atomFiles = atomFeed.GetFiles(atomProduct);
                    int totalEvents = 0;

                    foreach (AtomFile atomFile in atomFiles)
                    {
                        //                       String eventsLink = @"https://winqual.microsoft.com/Services/wer/user/events.aspx?fileid=" + fileId.ToString();
                        //                       AtomFile atomFile = new AtomFile(new StackHashFile(), eventsLink);

                        DiagnosticsHelper.LogMessage(DiagSeverity.Information, atomFile.File.ToString());

                        // ATOM GetEvents.
                        AtomEventCollection atomEvents = atomFeed.GetEvents(atomFile);

                        foreach (AtomEvent atomEvent in atomEvents)
                        {
                            totalEvents++;
                            DiagnosticsHelper.LogMessage(DiagSeverity.Information, atomEvent.Event.ToString());

                            // ATOM events.
                            StackHashEventInfoCollection eventInfos = GetEventInfoAtom(atomFeed, atomEvent, 90);

                            StackHashEventInfoCollection normalizedEventInfos = new StackHashEventInfoCollection();

                            bool stop = false;
                            foreach (StackHashEventInfo eventInfo in eventInfos)
                            {
                                DiagnosticsHelper.LogMessage(DiagSeverity.Information, eventInfo.ToString());
                                if (eventInfos.GetEventInfoMatchCount(eventInfo) != 1)
                                {
                                    DiagnosticsHelper.LogMessage(DiagSeverity.Information, "*** DUPLICATE HIT");
                                    DiagnosticsHelper.LogMessage(DiagSeverity.Information, eventInfo.ToString());
                                    stop = true;
                                }
                                StackHashEventInfo normalizedEventInfo = eventInfo.Normalize();
                                DiagnosticsHelper.LogMessage(DiagSeverity.Information, "N: " + normalizedEventInfo.ToString());
                                normalizedEventInfos.Add(normalizedEventInfo);
                                if (normalizedEventInfos.GetEventInfoMatchCount(normalizedEventInfo) != 1)
                                {
                                    DiagnosticsHelper.LogMessage(DiagSeverity.Information, "*** NORMALIZATION ERROR");
                                    DiagnosticsHelper.LogMessage(DiagSeverity.Information, normalizedEventInfo.ToString());
                                    stop = true;
                                }
                            }

                            if (stop)
                            {
                                return;
                            }


                            if (!noCabs)
                            {
                                // ATOM GetCabs.
                                StackHashCabCollection atomCabs = GetCabInfoAtom(atomFeed, atomEvent);

                                foreach (StackHashCab cab in atomCabs)
                                {
                                    DiagnosticsHelper.LogMessage(DiagSeverity.Information, cab.ToString());
                                }
                            }
                        }
                    }

                    DiagnosticsHelper.LogMessage(DiagSeverity.Information, String.Format("TOTAL EVENTS: {0}", totalEvents));
                }
            }
            catch (System.Exception ex)
            {
                DiagnosticsHelper.LogMessage(DiagSeverity.Information, "Error: " + ex.ToString());
            }
            finally
            {
                StackHashUtilities.SystemInformation.EnableSleep();
                logger.StopLogging();
            }
        }