public void GetFilesForProduct2FilesOnly1ForSelectedProduct() { m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder); m_Index.DeleteIndex(); m_Index.Activate(); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashProduct product2 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 2, "TestProduct1", 21, 31, "2.10.02123.1293"); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5"); StackHashFile file2 = new StackHashFile(creationDateTime, modifiedDateTime, 21, creationDateTime, "File2.dll", "2.3.4.5"); m_Index.AddProduct(product1); m_Index.AddProduct(product2); m_Index.AddFile(product1, file1); m_Index.AddFile(product2, file2); StackHashFileCollection files = m_Index.LoadFileList(product1); Assert.AreNotEqual(null, files); Assert.AreEqual(1, files.Count); Assert.AreEqual(0, file1.CompareTo(files[0])); files = m_Index.LoadFileList(product2); Assert.AreNotEqual(null, files); Assert.AreEqual(1, files.Count); Assert.AreEqual(0, file2.CompareTo(files[0])); }
/// <summary> /// Processes a specific product. /// </summary> private void processProduct(StackHashBugReportData request, StackHashProduct product) { if (this.CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins"); } BugTrackerProduct btProduct = new BugTrackerProduct(product.Name, product.Version, product.Id); if (((request.Options & StackHashReportOptions.IncludeProducts) != 0) || ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0)) { m_TaskParameters.PlugInContext.ProductAdded(m_PlugIns, m_ReportType, btProduct); checkPlugInStatus(m_PlugIns); } if (request.File == null) { StackHashFileCollection allFiles = m_Index.LoadFileList(product); foreach (StackHashFile file in allFiles) { processFile(request, product, file); } } else { StackHashFile file = m_Index.GetFile(product, request.File.Id); if (file != null) { processFile(request, product, file); } } }
// Add the same file twice with different data - should replace. // A file is the same if its ID, filename and version are the same. public void testAddSameFileTwice(IErrorIndex index) { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), 1, new DateTime(102), "filename.dll", "1.2.3.4"); index.AddProduct(product); index.AddFile(product, file); // Use same ID - should replace existing file data. file = new StackHashFile(new DateTime(200), new DateTime(201), 1, new DateTime(101), "filename.dll", "1.2.3.4"); index.AddFile(product, file); StackHashFileCollection files = index.LoadFileList(product); Assert.AreEqual(1, files.Count); Assert.AreEqual(file.DateCreatedLocal, files[0].DateCreatedLocal); Assert.AreEqual(file.DateModifiedLocal, files[0].DateModifiedLocal); Assert.AreEqual(file.Id, files[0].Id); Assert.AreEqual(file.LinkDateLocal, files[0].LinkDateLocal); Assert.AreEqual(file.Name, files[0].Name); Assert.AreEqual(file.Version, files[0].Version); }
private void testAdd1FileOk(IErrorIndex index) { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), 1, new DateTime(102), "filename.dll", "1.2.3.4"); index.AddProduct(product); index.AddFile(product, file); StackHashFileCollection files = index.LoadFileList(product); Assert.AreEqual(1, files.Count); Assert.AreEqual(file.DateCreatedLocal, files[0].DateCreatedLocal); Assert.AreEqual(file.DateModifiedLocal, files[0].DateModifiedLocal); Assert.AreEqual(file.Id, files[0].Id); Assert.AreEqual(file.LinkDateLocal, files[0].LinkDateLocal); Assert.AreEqual(file.Name, files[0].Name); Assert.AreEqual(file.Version, files[0].Version); // Also test the GetFile interface. StackHashFile gotFile = index.GetFile(product, file.Id); Assert.AreNotEqual(null, gotFile); Assert.AreEqual(file.DateCreatedLocal, gotFile.DateCreatedLocal); Assert.AreEqual(file.DateModifiedLocal, gotFile.DateModifiedLocal); Assert.AreEqual(file.Id, gotFile.Id); Assert.AreEqual(file.LinkDateLocal, gotFile.LinkDateLocal); Assert.AreEqual(file.Name, gotFile.Name); Assert.AreEqual(file.Version, gotFile.Version); }
// A single File object which hasn't been initialised. Should reject. private void testAdd1FileDefaultData(IErrorIndex index) { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); // Default file data - should fail. StackHashFile file = new StackHashFile(); index.AddProduct(product); try { index.AddFile(product, file); } catch (ArgumentException ex) { Assert.AreEqual("file", ex.ParamName); throw; } // Should be no files. StackHashFileCollection files = index.LoadFileList(product); Assert.AreEqual(0, files.Count); // Check that the dates are stored in UTC. Assert.AreEqual(true, files[0].DateCreatedLocal.Kind == DateTimeKind.Utc); Assert.AreEqual(true, files[0].DateModifiedLocal.Kind == DateTimeKind.Utc); }
public static StackHashFileCollection GetFilesApi(ref Login login, Product product) { ApplicationFileCollection apiFiles = product.GetApplicationFiles(ref login); StackHashFileCollection apiStackHashFiles = new StackHashFileCollection(); foreach (ApplicationFile file in apiFiles) { StackHashFile stackHashFile = ObjectConversion.ConvertFile(file); apiStackHashFiles.Add(stackHashFile); } return(apiStackHashFiles); }
private void testLoadFileListEmpty(IErrorIndex index) { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); index.AddProduct(product); StackHashFileCollection files = index.LoadFileList(product); Assert.AreNotEqual(null, files); Assert.AreEqual(0, files.Count); }
public static StackHashFileCollection GetFilesAtom(AtomFeed feed, AtomProduct product) { // Get the list of files. AtomFileCollection atomFiles = feed.GetFiles(product); // Convert to a StackHashFileCollection. StackHashFileCollection atomStackHashFiles = new StackHashFileCollection(); foreach (AtomFile atomFile in atomFiles) { atomStackHashFiles.Add(atomFile.File); } return(atomStackHashFiles); }
/// <summary> /// Make sure notification only comes back to the one client. /// Username and password are incorrect so should just fail to login. /// </summary> public void adminReportShouldBeSentToIndividualClient(ErrorIndexType indexType) { m_Utils.RegisterForNotifications(true, Guid.NewGuid()); m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid); m_Utils.RegisterForNotifications(true, Guid.NewGuid()); m_Utils.CreateAndSetNewContext(indexType); m_Utils.ActivateContext(0); StackHashTestIndexData indexData = new StackHashTestIndexData(); indexData.NumberOfProducts = 1; indexData.NumberOfFiles = 1; indexData.NumberOfEvents = 1; indexData.NumberOfCabs = 1; indexData.NumberOfEventInfos = 1; m_Utils.CreateTestIndex(0, indexData); try { StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products; StackHashFileCollection files = m_Utils.GetFiles(0, products[0].Product).Files; StackHashEventPackageCollection events = m_Utils.GetProductEventPackages(0, products[0].Product).EventPackages; StackHashCabPackageCollection cabs = events[0].Cabs; DownloadCabResponse resp = m_Utils.DownloadCab(0, products[0].Product, files[0], events[0].EventData, events[0].Cabs[0].Cab, 30000); StackHashAdminReport adminReport = m_Utils.DownloadCabAdminReport; Assert.AreNotEqual(null, adminReport); Assert.AreEqual(m_Utils.LastClientData.ApplicationGuid, adminReport.ClientData.ApplicationGuid); Assert.AreEqual(m_Utils.LastClientData.ClientId, adminReport.ClientData.ClientId); Assert.AreEqual(m_Utils.LastClientData.ClientName, adminReport.ClientData.ClientName); Assert.AreEqual(m_Utils.LastClientData.ClientRequestId, adminReport.ClientData.ClientRequestId); Assert.AreEqual(0, adminReport.ContextId); Assert.AreNotEqual(null, adminReport.LastException); Assert.AreEqual(true, adminReport.LastException.Contains("username and password")); Assert.AreEqual(StackHashAdminOperation.DownloadCabCompleted, adminReport.Operation); Assert.AreEqual(StackHashAsyncOperationResult.Failed, adminReport.ResultData); // Should receive 3 admin register + download started + download completed. Assert.AreEqual(5, m_Utils.AllReports.Count); } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }
private void testAdd1FileInSecondOfTwoProducts(IErrorIndex index) { index.Activate(); int product1Id = 1000; int product2Id = 1001; int fileId = 100; StackHashProduct product1 = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", product1Id, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashProduct product2 = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", product2Id, "TestProduct2", 20, 30, "2.10.02123.1293"); StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), fileId, new DateTime(102), "filename.dll", "1.2.3.4"); index.AddProduct(product1); index.AddProduct(product2); index.AddFile(product2, file); // Product 1 doesn't have any files. StackHashFileCollection files = index.LoadFileList(product1); Assert.AreEqual(0, files.Count); // Product 2 should have 1 file. files = index.LoadFileList(product2); Assert.AreEqual(1, files.Count); Assert.AreEqual(files[0].DateCreatedLocal, files[0].DateCreatedLocal); Assert.AreEqual(files[0].DateModifiedLocal, files[0].DateModifiedLocal); Assert.AreEqual(files[0].Id, files[0].Id); Assert.AreEqual(files[0].LinkDateLocal, files[0].LinkDateLocal); Assert.AreEqual(files[0].Name, files[0].Name); Assert.AreEqual(files[0].Version, files[0].Version); StackHashFile thisFile = index.GetFile(product1, fileId); Assert.AreEqual(null, thisFile); thisFile = index.GetFile(product2, fileId); Assert.AreEqual(file.DateCreatedLocal, files[0].DateCreatedLocal); Assert.AreEqual(file.DateModifiedLocal, files[0].DateModifiedLocal); Assert.AreEqual(file.Id, files[0].Id); Assert.AreEqual(file.LinkDateLocal, files[0].LinkDateLocal); Assert.AreEqual(file.Name, files[0].Name); Assert.AreEqual(file.Version, files[0].Version); }
// Add N files to a single product. public void testAddNFiles(IErrorIndex index, int numFiles) { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); List <StackHashFile> allFiles = new List <StackHashFile>(); index.AddProduct(product); for (int i = 0; i < numFiles; i++) { StackHashFile file = new StackHashFile(new DateTime(100 + i), new DateTime(101 + i), 1 + i, new DateTime(102 + i), "filename.dll" + i.ToString(), "1.2.3.4"); allFiles.Add(file); index.AddFile(product, file); } // Now make sure all files appear in the database list. StackHashFileCollection files = index.LoadFileList(product); Assert.AreEqual(numFiles, files.Count); // Note this only works because the files are in alphabetical order. for (int i = 0; i < numFiles; i++) { StackHashFile thisFile = index.GetFile(product, 1 + i); Assert.AreEqual(allFiles[i].DateCreatedLocal, thisFile.DateCreatedLocal); Assert.AreEqual(allFiles[i].DateModifiedLocal, thisFile.DateModifiedLocal); Assert.AreEqual(allFiles[i].Id, thisFile.Id); Assert.AreEqual(allFiles[i].LinkDateLocal, thisFile.LinkDateLocal); Assert.AreEqual(allFiles[i].Name, thisFile.Name); Assert.AreEqual(allFiles[i].Version, thisFile.Version); thisFile = files.FindFile(allFiles[i].Id); Assert.AreNotEqual(null, thisFile); Assert.AreEqual(allFiles[i].DateCreatedLocal, thisFile.DateCreatedLocal); Assert.AreEqual(allFiles[i].DateModifiedLocal, thisFile.DateModifiedLocal); Assert.AreEqual(allFiles[i].Id, thisFile.Id); Assert.AreEqual(allFiles[i].LinkDateLocal, thisFile.LinkDateLocal); Assert.AreEqual(allFiles[i].Name, thisFile.Name); Assert.AreEqual(allFiles[i].Version, thisFile.Version); } }
/// <summary> /// Gets the File data associated with a particular Product. /// </summary> /// <returns>Response result code.</returns> public GetFilesResponse GetFiles(GetFilesRequest requestData) { if (requestData == null) { throw new ArgumentNullException("requestData"); } GetFilesResponse resp = new GetFilesResponse(); StackHashFileCollection files = StaticObjects.TheStaticObjects.TheController.GetFiles( requestData.ContextId, requestData.Product); resp.Files = files; resp.ResultData = new StackHashServiceResultData( StackHashServiceResult.Success, s_OperationSuccessful, null); return(resp); }
/// <summary> /// Copies all files for the specified product from the source index to the destination index. /// </summary> /// <param name="product">The product whose files are to be copied.</param> private void copyFiles(StackHashProduct product) { StackHashFileCollection files = m_SourceIndex.LoadFileList(product); foreach (StackHashFile file in files) { if (this.CurrentTaskState.AbortRequested) { throw new StackHashException("Index file copy aborted", StackHashServiceErrorCode.Aborted); } if (!m_DestinationIndex.FileExists(product, file)) { m_DestinationIndex.AddFile(product, file); } // Copy all events associated with the specified file. copyEvents(product, file); } }
/// <summary> /// Product doesn't exist. /// </summary> public void downloadCabProductDoesntExist(ErrorIndexType indexType) { m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid); m_Utils.CreateAndSetNewContext(indexType); m_Utils.ActivateContext(0); StackHashTestIndexData indexData = new StackHashTestIndexData(); indexData.NumberOfProducts = 1; indexData.NumberOfFiles = 1; indexData.NumberOfEvents = 1; indexData.NumberOfCabs = 1; indexData.NumberOfEventInfos = 1; m_Utils.CreateTestIndex(0, indexData); try { try { StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products; StackHashFileCollection files = m_Utils.GetFiles(0, products[0].Product).Files; StackHashEventPackageCollection events = m_Utils.GetProductEventPackages(0, products[0].Product).EventPackages; StackHashCabPackageCollection cabs = events[0].Cabs; products[0].Product.Id++; // Wrong ID. DownloadCabResponse resp = m_Utils.DownloadCab(0, products[0].Product, files[0], events[0].EventData, events[0].Cabs[0].Cab, 30000); } catch (FaultException <ReceiverFaultDetail> ex) { Assert.AreEqual(true, ex.Message.Contains("Product does not exist")); } } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }
public void Add100Files() { m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder); m_Index.DeleteIndex(); m_Index.Activate(); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293"); int numFiles = 100; m_Index.AddProduct(product1); List <StackHashFile> addedFiles = new List <StackHashFile>(); for (int i = 0; i < numFiles; i++) { StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, 20 + i, creationDateTime, "File1.dll", "2.3.4.5"); m_Index.AddFile(product1, file1); addedFiles.Add(file1); StackHashFileCollection files = m_Index.LoadFileList(product1); Assert.AreNotEqual(null, files); Assert.AreEqual(i + 1, files.Count); for (int j = 0; j < i; j++) { Assert.AreEqual(0, addedFiles[j].CompareTo(files[j])); } } }
/// <summary> /// Parses the database looking for cabs to unwrap. /// </summary> private void analyzeAllCabs() { IErrorIndex index = m_TaskParameters.ErrorIndex; // Get a list of products. StackHashProductCollection products = index.LoadProductList(); foreach (StackHashProduct product in products) { if (CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Task aborted"); } if (!shouldProcessProduct(product)) { continue; } // Get the file list. StackHashFileCollection files = index.LoadFileList(product); foreach (StackHashFile file in files) { if (CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Task aborted"); } if (!shouldProcessFile(product, file)) { continue; } // Get the event data. StackHashEventCollection events = index.LoadEventList(product, file); foreach (StackHashEvent theEvent in events) { if (CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Task aborted"); } if (!shouldProcessEvent(product, file, theEvent)) { continue; } StackHashCabCollection cabs = index.LoadCabList(product, file, theEvent); // Process each cab. foreach (StackHashCab cab in cabs) { if (CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Task aborted"); } if (!shouldProcessCab(product, file, theEvent, cab)) { continue; } processCab(product, file, theEvent, cab); } } } } }
public void runAnalyzeJustAutoScripts(ErrorIndexType indexType, int numberOfProducts, int numberOfFiles, int numberOfEvents, int numberOfCabs, int numberOfAutoUnmanagedAndManagedScripts, int numberOfManualUnmanagedAndManagedScripts, bool useUnmanagedCabs, int numberOfAutoManagedScripts, int numberOfManualManagedScripts, int numberOfAutoUnmanagedScripts, int numberOfManualUnmanagedScripts) { int numberOfEventInfos = 1; // Use the dummy winqual. StackHashTestData testData = new StackHashTestData(); testData.DummyWinQualSettings = new StackHashTestDummyWinQualSettings(); testData.DummyWinQualSettings.UseDummyWinQual = true; testData.DummyWinQualSettings.ObjectsToCreate = new StackHashTestIndexData(); testData.DummyWinQualSettings.ObjectsToCreate.UseLargeCab = false; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfProducts = numberOfProducts; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfFiles = numberOfFiles; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfEvents = numberOfEvents; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfEventInfos = numberOfEventInfos; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfCabs = numberOfCabs; testData.DummyWinQualSettings.ObjectsToCreate.UseUnmanagedCab = useUnmanagedCabs; m_Utils.SetTestData(testData); m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid); m_Utils.CreateNewContext(indexType); // Set the username and password to something valid. GetStackHashPropertiesResponse settings = m_Utils.GetContextSettings(); String testPath = "c:\\stackhashunittest\\testindex\\"; settings.Settings.ContextCollection[0].ErrorIndexSettings.Folder = testPath; settings.Settings.ContextCollection[0].ErrorIndexSettings.Name = "TestIndex"; settings.Settings.ContextCollection[0].WinQualSettings.UserName = m_UserName; settings.Settings.ContextCollection[0].WinQualSettings.Password = m_Password; m_Utils.SetContextSettings(settings.Settings.ContextCollection[0]); // Make sure the index starts off empty. m_Utils.DeleteIndex(0); m_Utils.ActivateContext(0); for (int i = 0; i < numberOfAutoUnmanagedAndManagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i, true, StackHashScriptDumpType.UnmanagedAndManaged, true); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfManualUnmanagedAndManagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 100, true, StackHashScriptDumpType.UnmanagedAndManaged, false); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfAutoManagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 200, true, StackHashScriptDumpType.ManagedOnly, true); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfManualManagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 300, true, StackHashScriptDumpType.ManagedOnly, false); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfAutoUnmanagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 400, true, StackHashScriptDumpType.UnmanagedOnly, true); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfManualUnmanagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 500, true, StackHashScriptDumpType.UnmanagedOnly, false); m_Utils.AddDebuggerScript(scriptSettings, false); } try { // Synchronize so we have a copy of just the product list. StartSynchronizationResponse resp = m_Utils.StartSynchronization(0, 60000); StackHashClientData clientData = m_Utils.LastClientData; StackHashWinQualSyncCompleteAdminReport adminReport = m_Utils.WinQualSyncAdminReport as StackHashWinQualSyncCompleteAdminReport; Assert.AreNotEqual(null, adminReport); Assert.AreEqual(clientData.ApplicationGuid, adminReport.ClientData.ApplicationGuid); Assert.AreEqual(clientData.ClientId, adminReport.ClientData.ClientId); Assert.AreEqual(clientData.ClientName, adminReport.ClientData.ClientName); Assert.AreEqual(clientData.ClientRequestId, adminReport.ClientData.ClientRequestId); Assert.AreEqual(0, adminReport.ContextId); Assert.AreEqual(null, adminReport.LastException); Assert.AreEqual(StackHashAdminOperation.WinQualSyncCompleted, adminReport.Operation); Assert.AreEqual(StackHashAsyncOperationResult.Success, adminReport.ResultData); Assert.AreEqual(numberOfProducts, adminReport.ErrorIndexStatistics.Products); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Files); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Events); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Cabs); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.EventInfos); // Enable sync for all the products. GetProductsResponse getProducts = m_Utils.GetProducts(0); foreach (StackHashProductInfo productInfo in getProducts.Products) { Assert.AreEqual(false, productInfo.SynchronizeEnabled); m_Utils.SetProductSynchronizationState(0, productInfo.Product.Id, true); // Make sure there are no files for this product yet. GetFilesResponse getFiles = m_Utils.GetFiles(0, productInfo.Product); Assert.AreEqual(0, getFiles.Files.Count); } // Start the sync and wait for the sync and analyze to complete. resp = m_Utils.StartSynchronization(0, 120000, false, false, null); clientData = m_Utils.LastClientData; adminReport = m_Utils.WinQualSyncAdminReport as StackHashWinQualSyncCompleteAdminReport; Assert.AreNotEqual(null, adminReport); Assert.AreEqual(clientData.ApplicationGuid, adminReport.ClientData.ApplicationGuid); Assert.AreEqual(clientData.ClientId, adminReport.ClientData.ClientId); Assert.AreEqual(clientData.ClientName, adminReport.ClientData.ClientName); Assert.AreEqual(clientData.ClientRequestId, adminReport.ClientData.ClientRequestId); Assert.AreEqual(0, adminReport.ContextId); Assert.AreEqual(null, adminReport.LastException); Assert.AreEqual(StackHashAdminOperation.WinQualSyncCompleted, adminReport.Operation); Assert.AreEqual(StackHashAsyncOperationResult.Success, adminReport.ResultData); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Products); // Should have already added the product. Assert.AreEqual(numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.Files); Assert.AreEqual(numberOfEvents * numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.Events); Assert.AreEqual(numberOfCabs * numberOfEvents * numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.Cabs); Assert.AreEqual(numberOfEventInfos * numberOfEvents * numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.EventInfos); // Make sure the task is no longer running. GetStackHashServiceStatusResponse statusResp = m_Utils.GetServiceStatus(); Assert.AreEqual(false, m_Utils.IsTaskRunning(statusResp.Status.ContextStatusCollection[0].TaskStatusCollection, StackHashTaskType.WinQualSynchronizeTask)); Assert.AreEqual(false, m_Utils.IsTaskRunning(statusResp.Status.ContextStatusCollection[0].TaskStatusCollection, StackHashTaskType.AnalyzeTask)); // Check that the scripts have been run ok. Both auto scripts should be run. StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products; foreach (StackHashProductInfo product in products) { StackHashFileCollection files = m_Utils.GetFiles(0, product.Product).Files; foreach (StackHashFile file in files) { StackHashEventCollection events = m_Utils.GetEvents(0, product.Product, file).Events; foreach (StackHashEvent currentEvent in events) { StackHashEventPackage eventPackage = m_Utils.GetEventPackage(0, product.Product, file, currentEvent).EventPackage; foreach (StackHashCabPackage cab in eventPackage.Cabs) { StackHashScriptResultFiles scriptResults = m_Utils.GetDebugResultFiles(0, product.Product, file, currentEvent, cab.Cab).ResultFiles; int numberOfAutoScripts = 2; int expectedResults = numberOfAutoScripts + numberOfAutoUnmanagedAndManagedScripts; if (!useUnmanagedCabs) { expectedResults += numberOfAutoManagedScripts; } else { expectedResults += numberOfAutoUnmanagedScripts; } Assert.AreEqual(expectedResults, scriptResults.Count); } } } } } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }
public void RunBugReportSpecificEvent() { m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid); m_Utils.CreateAndSetNewContext(ErrorIndexType.SqlExpress); GetContextBugTrackerPlugInSettingsResponse resp = m_Utils.GetContextBugTrackerPlugInSettings(0); Assert.AreNotEqual(null, resp.BugTrackerPlugInSettings); Assert.AreNotEqual(null, resp.BugTrackerPlugInSettings.PlugInSettings); Assert.AreEqual(0, resp.BugTrackerPlugInSettings.PlugInSettings.Count); resp.BugTrackerPlugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn()); resp.BugTrackerPlugInSettings.PlugInSettings[0].Enabled = true; resp.BugTrackerPlugInSettings.PlugInSettings[0].Name = "TestPlugIn"; resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties = new StackHashNameValueCollection(); resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties.Add(new StackHashNameValuePair() { Name = "TestParam1", Value = "TestValue1" }); resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties.Add(new StackHashNameValuePair() { Name = "TestParam2", Value = "TestValue2" }); m_Utils.SetContextBugTrackerPlugInSettings(0, resp.BugTrackerPlugInSettings); m_Utils.RestartService(); m_Utils.ActivateContext(0); StackHashTestIndexData indexData = new StackHashTestIndexData(); indexData.NumberOfProducts = 1; indexData.NumberOfFiles = 1; indexData.NumberOfEvents = 1; indexData.NumberOfCabs = 1; indexData.NumberOfEventInfos = 1; m_Utils.CreateTestIndex(0, indexData); try { StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products; StackHashFileCollection files = m_Utils.GetFiles(0, products[0].Product).Files; StackHashEventPackageCollection events = m_Utils.GetProductEventPackages(0, products[0].Product).EventPackages; StackHashCabPackageCollection cabs = events[0].Cabs; StackHashBugReportDataCollection bugReportDataCollection = new StackHashBugReportDataCollection(); bugReportDataCollection.Add(new StackHashBugReportData() { Product = products[0].Product, File = files[0], TheEvent = events[0].EventData, Cab = null, ScriptName = null, Options = StackHashReportOptions.IncludeAllObjects }); m_Utils.RunBugReportTask(0, bugReportDataCollection, 30000, true); } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }
public void RunBugReportSpecificFileProgressCheckManyEventsAbortTest() { m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid); m_Utils.CreateAndSetNewContext(ErrorIndexType.SqlExpress); GetContextBugTrackerPlugInSettingsResponse resp = m_Utils.GetContextBugTrackerPlugInSettings(0); Assert.AreNotEqual(null, resp.BugTrackerPlugInSettings); Assert.AreNotEqual(null, resp.BugTrackerPlugInSettings.PlugInSettings); Assert.AreEqual(0, resp.BugTrackerPlugInSettings.PlugInSettings.Count); resp.BugTrackerPlugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn()); resp.BugTrackerPlugInSettings.PlugInSettings[0].Enabled = true; resp.BugTrackerPlugInSettings.PlugInSettings[0].Name = "TestPlugIn"; resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties = new StackHashNameValueCollection(); resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties.Add(new StackHashNameValuePair() { Name = "TestParam1", Value = "TestValue1" }); resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties.Add(new StackHashNameValuePair() { Name = "TestParam2", Value = "TestValue2" }); m_Utils.SetContextBugTrackerPlugInSettings(0, resp.BugTrackerPlugInSettings); m_Utils.RestartService(); m_Utils.ActivateContext(0); StackHashTestIndexData indexData = new StackHashTestIndexData(); indexData.NumberOfProducts = 1; indexData.NumberOfFiles = 1; indexData.NumberOfEvents = 200; indexData.NumberOfCabs = 1; indexData.NumberOfEventInfos = 1; m_Utils.CreateTestIndex(0, indexData); try { StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products; StackHashFileCollection files = m_Utils.GetFiles(0, products[0].Product).Files; StackHashEventPackageCollection events = m_Utils.GetProductEventPackages(0, products[0].Product).EventPackages; StackHashCabPackageCollection cabs = events[0].Cabs; StackHashBugReportDataCollection bugReportDataCollection = new StackHashBugReportDataCollection(); bugReportDataCollection.Add(new StackHashBugReportData() { Product = products[0].Product, File = files[0], TheEvent = null, Cab = null, ScriptName = null, Options = StackHashReportOptions.IncludeAllObjects }); m_Utils.RunBugReportTask(0, bugReportDataCollection, 0, false); // Don't wait. m_Utils.WaitForBugReportProgress(30000); m_Utils.AbortTask(0, StackHashTaskType.BugReportTask); m_Utils.WaitForBugReportTaskCompleted(30000); // Check the progress reports. Assert.AreEqual(true, m_Utils.BugReportProgressReports.Count < 100); long lastProgress = -1; foreach (StackHashAdminReport report in m_Utils.BugReportProgressReports) { StackHashBugReportProgressAdminReport progress = report as StackHashBugReportProgressAdminReport; Assert.AreEqual(true, progress.CurrentEvent > lastProgress); Assert.AreEqual(true, progress.CurrentEvent < progress.TotalEvents); lastProgress = progress.CurrentEvent; } } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }
public override void EntryPoint() { try { IErrorIndex errorIndex = m_TaskParameters.ErrorIndex; SetTaskStarted(m_TaskParameters.ErrorIndex); StackHashUtilities.SystemInformation.DisableSleep(); ErrorIndexEventParser parser = new ErrorIndexEventParser(); parser.ParseEvent += new EventHandler <ErrorIndexParseEventsEventArgs>(this.processEvent); DateTime purgeDate = DateTime.Now.ToUniversalTime().AddDays(-1 * m_TaskParameters.PurgeOptions.FindMostRecentPurgeAge()); try { // Get the list of products. StackHashProductCollection products = errorIndex.LoadProductList(); foreach (StackHashProduct product in products) { if (this.CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Purging product"); } // Get the files associated with this product. StackHashFileCollection files = errorIndex.LoadFileList(product); foreach (StackHashFile file in files) { if (this.CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Purging file"); } // Now parse the events one at a time. Instead of getting a list of all the events - use a // callback to analyze each event. Note this allows for an abort by returning false // from the callback. parser.Product = product; parser.File = file; parser.SearchCriteriaCollection = new StackHashSearchCriteriaCollection() { new StackHashSearchCriteria( new StackHashSearchOptionCollection() { new IntSearchOption(StackHashObjectType.Product, "Id", StackHashSearchOptionType.Equal, product.Id, 0), new IntSearchOption(StackHashObjectType.File, "Id", StackHashSearchOptionType.Equal, file.Id, 0), new DateTimeSearchOption(StackHashObjectType.CabInfo, "DateCreatedLocal", StackHashSearchOptionType.LessThanOrEqual, purgeDate, purgeDate), new IntSearchOption(StackHashObjectType.CabInfo, "Purged", StackHashSearchOptionType.Equal, 0, 0), // 0 is false. new IntSearchOption(StackHashObjectType.CabInfo, "CabDownloaded", StackHashSearchOptionType.Equal, 1, 0), // 1 is true. }) }; if (!errorIndex.ParseEvents(product, file, parser)) { throw new OperationCanceledException("Aborted while purging events"); } } } } finally { parser.ParseEvent -= new EventHandler <ErrorIndexParseEventsEventArgs>(this.processEvent); } } catch (Exception ex) { DiagnosticsHelper.LogException(DiagSeverity.Information, "Purge task failed", ex); LastException = ex; } finally { StackHashUtilities.SystemInformation.EnableSleep(); SetTaskCompleted(m_TaskParameters.ErrorIndex); } }
// // You can use the following additional attributes as you write your tests: // // Use ClassInitialize to run code before running the first test in the class // [ClassInitialize()] // public static void MyClassInitialize(TestContext testContext) { } // // Use ClassCleanup to run code after all tests in a class have run // [ClassCleanup()] // public static void MyClassCleanup() { } // // Use TestInitialize to run code before running each test // [TestInitialize()] // public void MyTestInitialize() { } // // Use TestCleanup to run code after each test has run // [TestCleanup()] // public void MyTestCleanup() { } // #endregion public void addRemoveEventNotes(int numberOfNotes) { StackHashTestIndexData testIndexData = new StackHashTestIndexData(); testIndexData.NumberOfProducts = 1; testIndexData.NumberOfFiles = 1; testIndexData.NumberOfEvents = 1; testIndexData.NumberOfEventInfos = 0; testIndexData.NumberOfCabs = 0; // Add a context. CreateNewStackHashContextResponse resp = m_Utils.CreateNewContext(ErrorIndexType.SqlExpress); String testPath = "c:\\stackhashunittests\\testindex\\"; resp.Settings.ErrorIndexSettings.Folder = testPath; resp.Settings.ErrorIndexSettings.Name = "TestIndex"; resp.Settings.ErrorIndexSettings.Type = ErrorIndexType.SqlExpress; m_Utils.SetContextSettings(resp.Settings); m_Utils.DeleteIndex(0); m_Utils.ActivateContext(0); m_Utils.CreateTestIndex(0, testIndexData); try { // Enable all products so that they appear in searchs. StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products; StackHashProduct product = products[0].Product; StackHashFileCollection files = m_Utils.GetFiles(0, product).Files; StackHashEventCollection events = m_Utils.GetEvents(0, product, files[0]).Events; // Add the specified number of event notes. for (int eventCount = 0; eventCount < numberOfNotes; eventCount++) { StackHashNoteEntry note = new StackHashNoteEntry(); note.Note = "Note" + (eventCount + 1).ToString(); note.Source = "USER"; note.User = "******"; note.TimeOfEntry = DateTime.Now.AddDays(-1); m_Utils.AddEventNote(0, product, files[0], events[0], note); StackHashNotes notes = m_Utils.GetEventNotes(0, product, files[0], events[0]).Notes; Assert.AreEqual(eventCount + 1, notes.Count); bool found = false; foreach (StackHashNoteEntry noteEntry in notes) { if (noteEntry.NoteId == eventCount + 1) { Assert.AreEqual(note.Note, noteEntry.Note); Assert.AreEqual(note.Source, noteEntry.Source); Assert.AreEqual(note.User, noteEntry.User); Assert.AreEqual(DateTime.UtcNow.Date, noteEntry.TimeOfEntry.Date); found = true; break; } } Assert.AreEqual(true, found); } // Now delete the event notes. int expectedEventNotes = numberOfNotes; for (int eventCount = 0; eventCount < numberOfNotes; eventCount++) { m_Utils.DeleteEventNote(0, product, files[0], events[0], eventCount + 1); expectedEventNotes--; StackHashNotes notes = m_Utils.GetEventNotes(0, product, files[0], events[0]).Notes; Assert.AreEqual(expectedEventNotes, notes.Count); bool found = false; foreach (StackHashNoteEntry noteEntry in notes) { if (noteEntry.NoteId == eventCount + 1) { found = true; break; } } Assert.AreEqual(false, found); } } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }
public void AutoScriptOnOneCabAlreadyRunButNewerVersion() { // If the auto task sees the AutoScript.log file exists and has the same // version as the current AutoScript.xml then it shouldn't run it again. // Determine this by checking the file time after a second run. // Create an index with 1 cab file. XmlErrorIndex errorIndex = new XmlErrorIndex(m_TempPath, "ErrorIndex"); errorIndex.Activate(); StackHashTestIndexData testData = new StackHashTestIndexData(); testData.NumberOfProducts = 1; testData.NumberOfFiles = 1; testData.NumberOfEvents = 1; testData.NumberOfEventInfos = 1; testData.NumberOfCabs = 1; testData.UseLargeCab = false; TestManager.CreateTestIndex(errorIndex, testData); ScriptManager scriptManager = new ScriptManager(m_TempPath + "Scripts"); Assert.AreEqual(scriptManager.NumberOfAutoScripts, scriptManager.ScriptNames.Count); ScriptResultsManager scriptResultsManager = new ScriptResultsManager(errorIndex, scriptManager, m_Debugger, m_DebuggerSettings); // Set up parameters for the task. AnalyzeTaskParameters analyzeParams = new AnalyzeTaskParameters(); // Standard task parameters. analyzeParams.IsBackgroundTask = true; analyzeParams.Name = "TestRunOneTask"; analyzeParams.RunInParallel = false; analyzeParams.UseSeparateThread = true; analyzeParams.AnalysisSettings = new StackHashAnalysisSettings(); analyzeParams.AnalysisSettings.ForceRerun = true; analyzeParams.ContextId = 0; analyzeParams.ClientData = new StackHashClientData(Guid.NewGuid(), "MarkJ", 1); analyzeParams.Debugger = m_Debugger; analyzeParams.DebuggerSettings = m_DebuggerSettings; analyzeParams.TheScriptManager = scriptManager; analyzeParams.TheScriptResultsManager = scriptResultsManager; int productId = 1; analyzeParams.ProductsToSynchronize = new StackHashProductSyncDataCollection(); analyzeParams.ProductsToSynchronize.Add(new StackHashProductSyncData(productId)); analyzeParams.ErrorIndex = errorIndex; // Create the task and run it. AnalyzeTask analyzeTask = new AnalyzeTask(analyzeParams); TaskManager taskManager = new TaskManager("Test"); taskManager.Enqueue(analyzeTask); taskManager.WaitForTaskCompletion(analyzeTask, s_TaskTimeout); StackHashProductCollection products = errorIndex.LoadProductList(); StackHashFileCollection files = errorIndex.LoadFileList(products[0]); StackHashEventCollection events = errorIndex.LoadEventList(products[0], files[0]); StackHashCabCollection cabs = errorIndex.LoadCabList(products[0], files[0], events[0]); StackHashScriptResult script1 = scriptResultsManager.GetResultFileData(products[0], files[0], events[0], cabs[0], "AutoScript"); // Wait for 1 second - so file time granularity exceeded. Thread.Sleep(1000); // Change the version on the autoscript. StackHashScriptSettings settings = scriptManager.LoadScript("AutoScript"); settings.LastModifiedDate = DateTime.Now; scriptManager.AddScript(settings, true, true); // Now run the task again. analyzeTask = new AnalyzeTask(analyzeParams); taskManager.Enqueue(analyzeTask); taskManager.WaitForTaskCompletion(analyzeTask, s_TaskTimeout); Assert.AreEqual(true, analyzeTask.CurrentTaskState.TaskCompleted); // Refresh the cab list data. cabs = errorIndex.LoadCabList(products[0], files[0], events[0]); StackHashDumpAnalysis analysis = cabs[0].DumpAnalysis; Assert.AreEqual("not available", analysis.SystemUpTime); Assert.AreEqual("0 days 0:00:15.000", analysis.ProcessUpTime); Assert.AreEqual("2.0.50727.3603", analysis.DotNetVersion); StackHashScriptResult script2 = scriptResultsManager.GetResultFileData(products[0], files[0], events[0], cabs[0], "AutoScript"); Assert.AreEqual(true, script2.RunDate > script1.RunDate); }
public void AutoScriptOnOneCabProductNotEnabled() { // Create an index with 1 cab file. XmlErrorIndex errorIndex = new XmlErrorIndex(m_TempPath, "ErrorIndex"); errorIndex.Activate(); StackHashTestIndexData testData = new StackHashTestIndexData(); testData.NumberOfProducts = 1; testData.NumberOfFiles = 1; testData.NumberOfEvents = 1; testData.NumberOfEventInfos = 1; testData.NumberOfCabs = 1; testData.UseLargeCab = false; TestManager.CreateTestIndex(errorIndex, testData); ScriptManager scriptManager = new ScriptManager(m_TempPath + "Scripts"); Assert.AreEqual(scriptManager.NumberOfAutoScripts, scriptManager.ScriptNames.Count); ScriptResultsManager scriptResultsManager = new ScriptResultsManager(errorIndex, scriptManager, m_Debugger, m_DebuggerSettings); // Set up parameters for the task. AnalyzeTaskParameters analyzeParams = new AnalyzeTaskParameters(); // Standard task parameters. analyzeParams.IsBackgroundTask = true; analyzeParams.Name = "TestRunOneTask"; analyzeParams.RunInParallel = false; analyzeParams.UseSeparateThread = true; analyzeParams.AnalysisSettings = new StackHashAnalysisSettings(); analyzeParams.AnalysisSettings.ForceRerun = true; analyzeParams.ContextId = 0; analyzeParams.ClientData = new StackHashClientData(Guid.NewGuid(), "MarkJ", 1); analyzeParams.Debugger = m_Debugger; analyzeParams.DebuggerSettings = m_DebuggerSettings; analyzeParams.TheScriptManager = scriptManager; analyzeParams.TheScriptResultsManager = scriptResultsManager; analyzeParams.ProductsToSynchronize = new StackHashProductSyncDataCollection(); analyzeParams.ErrorIndex = errorIndex; // Create the task and run it. AnalyzeTask analyzeTask = new AnalyzeTask(analyzeParams); TaskManager taskManager = new TaskManager("Test"); taskManager.Enqueue(analyzeTask); taskManager.WaitForTaskCompletion(analyzeTask, s_TaskTimeout); Assert.AreEqual(true, analyzeTask.CurrentTaskState.TaskCompleted); StackHashProductCollection products = errorIndex.LoadProductList(); StackHashFileCollection files = errorIndex.LoadFileList(products[0]); StackHashEventCollection events = errorIndex.LoadEventList(products[0], files[0]); StackHashCabCollection cabs = errorIndex.LoadCabList(products[0], files[0], events[0]); StackHashDumpAnalysis analysis = cabs[0].DumpAnalysis; Assert.AreEqual(null, analysis.DotNetVersion); Assert.AreEqual(null, analysis.MachineArchitecture); Assert.AreEqual(null, analysis.OSVersion); Assert.AreEqual(null, analysis.ProcessUpTime); Assert.AreEqual(null, analysis.SystemUpTime); }