public void Conflict2EventsAndEventSameAsSecondDifferentProductAndFile() { StackHashProduct product1 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4"); StackHashFile file1 = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "File1", "1.2.3.4"); StackHashEvent event1 = new StackHashEvent(1, "EventTypeName1"); StackHashEvent event2 = new StackHashEvent(2, "EventTypeName1"); StackHashBugReportData data1 = new StackHashBugReportData(product1, file1, event1, null, null, StackHashReportOptions.IncludeAllObjects); StackHashBugReportData data2 = new StackHashBugReportData(product1, file1, event2, null, null, StackHashReportOptions.IncludeAllObjects); StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection() { data1, data2, }; StackHashProduct product2 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4"); StackHashFile file2 = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "File1", "1.2.3.4"); StackHashBugReportData data3 = new StackHashBugReportData(product2, file2, event2, null, null, StackHashReportOptions.IncludeAllObjects); StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection() { data3 }; Assert.AreEqual(true, allData1.IsConflicting(allData2)); }
public void updateProductStatsNoEvents(IErrorIndex index, int numProducts, int numFiles, int numEvents) { 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 product = new StackHashProduct(creationDateTime, modifiedDateTime, "www.files.com", 25, @"P""r:o?d:u@(XP_2k)", 0, 0, "1:2:3:4"); if (numProducts != 0) { index.AddProduct(product); } int eventId = 2000; for (int i = 0; i < numFiles; i++) { StackHashFile file = new StackHashFile(DateTime.Now, DateTime.Now, i + 1000, DateTime.Now, "FileName", "1.2.3.4"); index.AddFile(product, file); for (int j = 0; j < numEvents; j++) { StackHashEvent theEvent = new StackHashEvent(DateTime.Now, DateTime.Now, "Event type", eventId++, new StackHashEventSignature(), j, i + 1000); theEvent.EventSignature.Parameters = new StackHashParameterCollection(); index.AddEvent(product, file, theEvent); } } product = index.UpdateProductStatistics(product); Assert.AreEqual(numFiles * numEvents, product.TotalStoredEvents); }
private void testAddEventInfoUnknownFile(IErrorIndex index) { try { 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); // Change the file id so it isn't recognised. file.Id++; StackHashEvent theEvent = new StackHashEvent(); StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection(); index.AddEventInfoCollection(product, file, theEvent, eventInfoCollection); } catch (ArgumentException ex) { Assert.AreEqual("file", ex.ParamName); throw; } }
public static StackHashEventCollection GetEventsApi(ref Login login, ApplicationFile file, out List <Event> rawEvents, DateTime startTime) { EventPageReader eventPageReader = file.GetEvents(startTime); // Get all events. StackHashEventCollection apiStackHashEvents = new StackHashEventCollection(); rawEvents = new List <Event>(); // Read each page of new events. while (eventPageReader.Read(ref login) == true) { // Get the events for the page. EventReader events = eventPageReader.Events; while (events.Read() == true) { // Get the event Event dpEvent = events.Event; rawEvents.Add(dpEvent); StackHashEvent stackHashEvent = ObjectConversion.ConvertEvent(dpEvent, file.ID); apiStackHashEvents.Add(stackHashEvent); } } return(apiStackHashEvents); }
private void testAddEventInfoNullEventInfo(IErrorIndex index) { try { 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), 39, new DateTime(102), "filename.dll", "1.2.3.4"); StackHashParameterCollection parameters = new StackHashParameterCollection(); parameters.Add(new StackHashParameter("param1", "param1value")); parameters.Add(new StackHashParameter("param2", "param2value")); StackHashEventSignature signature = new StackHashEventSignature(parameters); StackHashEvent theEvent = new StackHashEvent(new DateTime(102), new DateTime(103), "EventType1", 20000, signature, 99, 2); index.AddProduct(product); index.AddFile(product, file); index.AddEvent(product, file, theEvent); index.AddEventInfoCollection(product, file, theEvent, null); } catch (ArgumentNullException ex) { Assert.AreEqual("eventInfoCollection", ex.ParamName); throw; } }
/// <summary> /// Unpack the cab file if not already unpacked. /// </summary> /// <param name="product">Product to which the cab belongs.</param> /// <param name="file">File to which the cab belongs.</param> /// <param name="theEvent">Event to which the cab belongs.</param> /// <param name="cab">The cab object to unpack.</param> /// <param name="forceUnpack">True - force an unpack even if the cab has already been unpacked.</param> /// <returns></returns> private void unpackCab(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, bool forceUnpack) { String cabFileName = m_TaskParameters.ErrorIndex.GetCabFileName(product, file, theEvent, cab); String cabFileFolder = Path.GetDirectoryName(cabFileName); if (!Cabs.IsUncabbed(cabFileName, cabFileFolder) || forceUnpack) { try { Cabs.ExtractCab(cabFileName, cabFileFolder); } catch (System.Exception ex) { if (ex.Message.Contains("The file is not a cabinet") || ex.Message.Contains("corrupt") || ex.Message.Contains("Corrupt")) { // Set the downloaded flag appropriately if different. StackHashCab loadedCab = m_TaskParameters.ErrorIndex.GetCab(product, file, theEvent, cab.Id); if (loadedCab != null) { if (loadedCab.CabDownloaded) { loadedCab.CabDownloaded = false; m_TaskParameters.ErrorIndex.AddCab(product, file, theEvent, loadedCab, false); } } } throw new StackHashException("Cab file cannot be unpackaged. Try downloading the file from again.", ex, StackHashServiceErrorCode.CabIsCorrupt); } } }
private void checkIndexData(IErrorIndex index) { int numProducts = 100; int cabId = 12345678; int fileId = 2000; int eventId = 1000; for (int productCount = 0; productCount < numProducts; productCount++) { StackHashProduct retrievedProduct = index.GetProduct(productCount + 10); 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, (productCount + 10), "TestProduct1", 20, 30, "2.10.02123.1293"); Assert.AreEqual(0, product1.CompareTo(retrievedProduct)); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, fileId++, creationDateTime, "FileName", "1.2.3.4"); StackHashFile retrievedFile = index.GetFile(product1, file1.Id); Assert.AreEqual(0, file1.CompareTo(retrievedFile)); StackHashEventSignature eventSignature = new StackHashEventSignature(); eventSignature.Parameters = new StackHashParameterCollection(); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234")); eventSignature.InterpretParameters(); StackHashEvent thisEvent = new StackHashEvent(creationDateTime, modifiedDateTime, "CLR20", eventId++, eventSignature, 1, file1.Id); StackHashEvent retrievedEvent = index.GetEvent(product1, file1, thisEvent); Assert.AreEqual(0, thisEvent.CompareTo(retrievedEvent)); StackHashCab cab = new StackHashCab(creationDateTime, modifiedDateTime, thisEvent.Id, thisEvent.EventTypeName, "cab12345_23232.cab", cabId++, 12000); cab.DumpAnalysis = new StackHashDumpAnalysis("2 days, 5 hours, 2 mins", "1 hour, 2 mins", "2.120.222.1121212", "Microsoft Windows Vista X64 6.0.212121212 (Build 2500)", "64 bit windows"); cab.CabDownloaded = true; StackHashCab retrievedCab = index.GetCab(product1, file1, thisEvent, cab.Id); Assert.AreEqual(0, cab.CompareTo(retrievedCab)); String cabFolder = index.GetCabFolder(product1, file1, thisEvent, cab); String cabFileName = index.GetCabFileName(product1, file1, thisEvent, cab); Assert.AreEqual(true, Directory.Exists(cabFolder)); Assert.AreEqual(true, File.Exists(cabFileName)); } }
private void addDataToIndex(IErrorIndex index) { int numProducts = 100; int cabId = 12345678; int fileId = 2000; int eventId = 1000; for (int productCount = 0; productCount < numProducts; productCount++) { 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, (productCount + 10), "TestProduct1", 20, 30, "2.10.02123.1293"); index.AddProduct(product1); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, fileId++, creationDateTime, "FileName", "1.2.3.4"); index.AddFile(product1, file1); StackHashEventSignature eventSignature = new StackHashEventSignature(); eventSignature.Parameters = new StackHashParameterCollection(); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234")); eventSignature.InterpretParameters(); StackHashEvent thisEvent = new StackHashEvent(creationDateTime, modifiedDateTime, "CLR20", eventId++, eventSignature, 1, file1.Id); index.AddEvent(product1, file1, thisEvent); StackHashCab cab = new StackHashCab(creationDateTime, modifiedDateTime, thisEvent.Id, thisEvent.EventTypeName, "cab12345_23232.cab", cabId++, 12000); cab.DumpAnalysis = new StackHashDumpAnalysis("2 days, 5 hours, 2 mins", "1 hour, 2 mins", "2.120.222.1121212", "Microsoft Windows Vista X64 6.0.212121212 (Build 2500)", "64 bit windows"); cab.CabDownloaded = true; index.AddCab(product1, file1, thisEvent, cab, true); String cabFolder = index.GetCabFolder(product1, file1, thisEvent, cab); String cabFileName = index.GetCabFileName(product1, file1, thisEvent, cab); if (!Directory.Exists(cabFolder)) { Directory.CreateDirectory(cabFolder); } File.Copy(TestSettings.TestDataFolder + @"Cabs\1641909485-Crash32bit-0773522646.cab", cabFileName); FileAttributes originalAttributes = File.GetAttributes(cabFileName); File.SetAttributes(cabFileName, originalAttributes & ~FileAttributes.ReadOnly); } }
/// <summary> /// Constructor. /// </summary> /// <param name="progressType">Progress type - e.g. downloading cabs.</param> /// <param name="product">The owning product.</param> /// <param name="file">The owning file.</param> /// <param name="theEvent">The owning event.</param> /// <param name="cab">The cab being downloaded.</param> /// <param name="currentPage">The current page being downloaded.</param> /// <param name="totalPages">Total pages to download.</param> public WinQualProgressEventArgs(WinQualProgressType progressType, StackHashProductInfo product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, int currentPage, int totalPages) { m_ProgressType = progressType; m_Product = product; m_File = file; m_Event = theEvent; m_Cab = cab; m_TotalPages = totalPages; m_CurrentPage = currentPage; }
public bool CabMatchesSearchCriteria(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, StackHashSearchCriteria searchCriteria) { if (product == null) { throw new ArgumentNullException("product"); } if (file == null) { throw new ArgumentNullException("file"); } if (theEvent == null) { throw new ArgumentNullException("theEvent"); } if (cab == null) { throw new ArgumentNullException("cab"); } if (searchCriteria == null) { throw new ArgumentNullException("searchCriteria"); } // Get a list of script result files for this cab. StackHashScriptResultFiles resultFiles = GetResultFiles(product, file, theEvent, cab); if ((resultFiles == null) || (resultFiles.Count == 0)) { return(false); } foreach (StackHashScriptResultFile resultFile in resultFiles) { try { StackHashScriptResult resultFileData = GetResultFileData(product, file, theEvent, cab, resultFile.ScriptName); if (resultFileData.Search(searchCriteria)) { return(true); } } catch (System.Exception ex) { // Don't allow corrupt files to stop the search. DiagnosticsHelper.LogException(DiagSeverity.Warning, "Corrupt or missing results file: " + resultFile.ScriptName + " for cab " + cab.Id.ToString(CultureInfo.InvariantCulture), ex); } } return(false); }
/// <summary> /// Called when an event is found. /// </summary> /// <param name="sender">The task manager reporting the event.</param> /// <param name="e">The event arguments.</param> private void processEvent(Object sender, ErrorIndexParseEventsEventArgs e) { StackHashEvent currentEvent = e.Parser.CurrentEvent; // Which purge options should be used for this event. StackHashPurgeOptions purgeOptions = findPurgeOptions(e.Parser.Product, e.Parser.File, e.Parser.CurrentEvent); if (purgeOptions != null) { // Now purge according to the policy specified. purgeEvent(e.Parser.Product, e.Parser.File, e.Parser.CurrentEvent, purgeOptions); } }
/// <summary> /// Process a cab note table update. This may indicate a new item or the change to an existing item. /// </summary> private bool processCabNoteUpdate(StackHashBugTrackerUpdate update) { // Get the associated product and file information. StackHashProduct product = m_Index.GetProduct((int)update.ProductId); StackHashFile file = m_Index.GetFile(product, (int)update.FileId); StackHashEvent theEvent = m_Index.GetEvent(product, file, new StackHashEvent((int)update.EventId, update.EventTypeName)); StackHashCab cab = m_Index.GetCab(product, file, theEvent, (int)update.CabId); StackHashNoteEntry note = m_Index.GetCabNote((int)update.ChangedObjectId); if ((product == null) || (file == null) || (theEvent == null) || (cab == null) || (note == null)) { DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Cab Note: Inconsistent Update Table Entry"); return(false); } BugTrackerProduct btProduct = new BugTrackerProduct(product.Name, product.Version, product.Id); BugTrackerFile btFile = new BugTrackerFile(file.Name, file.Version, file.Id); NameValueCollection eventSignature = new NameValueCollection(); foreach (StackHashParameter param in theEvent.EventSignature.Parameters) { eventSignature.Add(param.Name, param.Value); } BugTrackerEvent btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, eventSignature); NameValueCollection analysis = new NameValueCollection(); analysis.Add("DotNetVersion", cab.DumpAnalysis.DotNetVersion); analysis.Add("MachineArchitecture", cab.DumpAnalysis.MachineArchitecture); analysis.Add("OSVersion", cab.DumpAnalysis.OSVersion); analysis.Add("ProcessUpTime", cab.DumpAnalysis.ProcessUpTime); analysis.Add("SystemUpTime", cab.DumpAnalysis.SystemUpTime); String cabFileName = m_Index.GetCabFileName(product, file, theEvent, cab); BugTrackerCab btCab = new BugTrackerCab(cab.Id, cab.SizeInBytes, cab.CabDownloaded, cab.Purged, analysis, cabFileName); BugTrackerNote btCabNote = new BugTrackerNote(note.TimeOfEntry, note.Source, note.User, note.Note); String newBugId = null; if (update.TypeOfChange == StackHashChangeType.NewEntry) { newBugId = m_TaskParameters.PlugInContext.CabNoteAdded(null, BugTrackerReportType.Automatic, btProduct, btFile, btEvent, btCab, btCabNote); } setPlugInBugReference(product, file, theEvent, newBugId); return(true); }
// // 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 private void testAddEventInfoNullProduct(IErrorIndex index) { try { index.Activate(); StackHashFile file = new StackHashFile(); StackHashEvent theEvent = new StackHashEvent(); StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection(); index.AddEventInfoCollection(null, file, theEvent, eventInfoCollection); } catch (ArgumentNullException ex) { Assert.AreEqual("product", ex.ParamName); throw; } }
/// <summary> /// Gets the results files for the specified cab. /// </summary> /// <param name="product">Product to which the cab belongs</param> /// <param name="file">File to which the cab belongs</param> /// <param name="theEvent">Event to which the cab belongs</param> /// <param name="cab">Cab to get results for.</param> /// <returns>All script results for specified cab.</returns> public StackHashScriptResultFiles GetResultFiles(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab) { // Unwrap the cab if necessary. String cabFileFolder = m_ErrorIndex.GetCabFolder(product, file, theEvent, cab); cabFileFolder += "\\Analysis"; // Get a list of the results log files. String[] files; if (Directory.Exists(cabFileFolder)) { files = Directory.GetFiles(cabFileFolder, "*.log"); } else { files = new String[0]; } StackHashScriptResultFiles resultFiles = new StackHashScriptResultFiles(); foreach (String fileName in files) { // Need to get whether it is an auto or user script. String fileNameNoExtension = Path.GetFileNameWithoutExtension(fileName); StackHashScriptSettings scriptSettings = m_ScriptManager.LoadScript(fileNameNoExtension, true); StackHashScriptResultFile resultFile = new StackHashScriptResultFile(); resultFile.RunDate = File.GetLastWriteTimeUtc(fileName); resultFile.ScriptName = Path.GetFileNameWithoutExtension(fileName); if ((scriptSettings == null) || (scriptSettings.Owner == StackHashScriptOwner.System)) { resultFile.UserName = "******"; } else { resultFile.UserName = "******"; } resultFiles.Add(resultFile); } return(resultFiles); }
private void testAddNEventInfo(IErrorIndex index, int numEventInfos) { 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), 39, new DateTime(102), "filename.dll", "1.2.3.4"); StackHashParameterCollection parameters = new StackHashParameterCollection(); parameters.Add(new StackHashParameter("param1", "param1value")); parameters.Add(new StackHashParameter("param2", "param2value")); StackHashEventSignature signature = new StackHashEventSignature(parameters); StackHashEvent theEvent = new StackHashEvent(new DateTime(102), new DateTime(103), "EventType1", 20000, signature, -1, 2); index.AddProduct(product); index.AddFile(product, file); index.AddEvent(product, file, theEvent); StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection(); int totalHits = 0; for (int i = 0; i < numEventInfos; i++) { int hitsForThisEvent = (i + 1); totalHits += hitsForThisEvent; StackHashEventInfo eventInfo = new StackHashEventInfo(DateTime.Now.AddDays(i).ToUniversalTime(), DateTime.Now.AddDays(i + 1).ToUniversalTime(), DateTime.Now.AddDays(i + 2).ToUniversalTime(), "English" + i.ToString(), i, "locale" + i.ToString(), "OS" + i.ToString(), "OSVersion" + i.ToString(), hitsForThisEvent); eventInfoCollection.Add(eventInfo); } index.AddEventInfoCollection(product, file, theEvent, eventInfoCollection); // Now get all the event info and make sure it all matches. StackHashEventInfoCollection eventInfoCollection2 = index.LoadEventInfoList(product, file, theEvent); Assert.AreEqual(0, eventInfoCollection.CompareTo(eventInfoCollection2)); StackHashEventPackageCollection eventPackages = index.GetProductEvents(product); Assert.AreEqual(1, eventPackages.Count); Assert.AreEqual(totalHits, eventPackages[0].EventData.TotalHits); }
/// <summary> /// Removes the script data for the specified script. /// </summary> /// <param name="product">Product to which the cab belongs</param> /// <param name="file">File to which the cab belongs</param> /// <param name="theEvent">Event to which the cab belongs</param> /// <param name="cab">Cab to remove the results for.</param> /// <param name="scriptName">The script file to remove.</param> public void RemoveResultFileData(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, String scriptName) { if (scriptName == null) { throw new ArgumentNullException("scriptName"); } String cabFileFolder = m_ErrorIndex.GetCabFolder(product, file, theEvent, cab); String resultsFileName = String.Format(CultureInfo.InvariantCulture, "{0}\\Analysis\\{1}.log", cabFileFolder, scriptName); if (File.Exists(resultsFileName)) { File.Delete(resultsFileName); } }
private bool runAutoScripts(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, StackHashScriptDumpType dumpType) { Collection <AutoScriptBase> autoScripts = m_TaskParameters.TheScriptManager.AutoScripts; ScriptResultsManager scriptRunner = m_TaskParameters.TheScriptResultsManager; bool dumpAnalysisProduced = false; // Analyse the Unmanaged mode autoscripts first - as these determine if the dump is managed or not and hence whether // the managed scripts will be run. The AutoScripts property above returns the autoscripts in the correct order. foreach (AutoScriptBase autoScript in autoScripts) { bool dumpIsManaged = ((cab.DumpAnalysis != null) && (!String.IsNullOrEmpty(cab.DumpAnalysis.DotNetVersion))); if (autoScript.ScriptSettings.DumpType != dumpType) { continue; } if ((autoScript.ScriptSettings.DumpType == StackHashScriptDumpType.ManagedOnly) && (!dumpIsManaged)) { continue; } bool forceAutoScript = false; if ((cab.DumpAnalysis == null) || (cab.DumpAnalysis.MachineArchitecture == null) || (cab.DumpAnalysis.OSVersion == null)) { forceAutoScript = true; } // Run the auto script on the cab if it hasn't already been run. StackHashScriptResult scriptResult = scriptRunner.RunScript(product, file, theEvent, cab, null, autoScript.ScriptName, false, null, forceAutoScript); // Analyze the results. if (scriptResult != null) { cab.DumpAnalysis = autoScript.AnalyzeScriptResults(cab.DumpAnalysis, scriptResult); dumpAnalysisProduced = true; m_ConsecutiveErrors = 0; } } return(dumpAnalysisProduced); }
// // 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 //================================================================================================================================ // GET CAB FOLDER TESTS. //================================================================================================================================ #region AddCabNoteTests private void testAddCabNoteNullProduct(IErrorIndex index) { try { index.Activate(); StackHashFile file = new StackHashFile(); StackHashEvent theEvent = new StackHashEvent(); StackHashCab cab = new StackHashCab(); StackHashNoteEntry note = new StackHashNoteEntry(); index.AddCabNote(null, file, theEvent, cab, note); } catch (ArgumentNullException ex) { Assert.AreEqual("product", ex.ParamName); throw; } }
private void testAddNEventInfoReloadCache(IErrorIndex realIndex, int numEventInfos) { ErrorIndexCache index = new ErrorIndexCache(realIndex); 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), 39, new DateTime(102), "filename.dll", "1.2.3.4"); StackHashParameterCollection parameters = new StackHashParameterCollection(); parameters.Add(new StackHashParameter("param1", "param1value")); parameters.Add(new StackHashParameter("param2", "param2value")); StackHashEventSignature signature = new StackHashEventSignature(parameters); StackHashEvent theEvent = new StackHashEvent(new DateTime(102), new DateTime(103), "EventType1", 20000, signature, 99, 2); index.AddProduct(product); index.AddFile(product, file); index.AddEvent(product, file, theEvent); StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection(); for (int i = 0; i < numEventInfos; i++) { StackHashEventInfo eventInfo = new StackHashEventInfo(DateTime.Now.AddDays(i), DateTime.Now.AddDays(i + 1), DateTime.Now.AddDays(i + 2), "English" + i.ToString(), i, "locale" + i.ToString(), "OS" + i.ToString(), "OSVersion" + i.ToString(), i * 10); eventInfoCollection.Add(eventInfo); } index.AddEventInfoCollection(product, file, theEvent, eventInfoCollection); // Now reconnect a cache to make sure that the data has been stored ok. index = new ErrorIndexCache(realIndex); index.Activate(); // Now get all the event info and make sure it all matches. StackHashEventInfoCollection eventInfoCollection2 = index.LoadEventInfoList(product, file, theEvent); Assert.AreEqual(0, eventInfoCollection.CompareTo(eventInfoCollection2)); }
private void testAddCabNoteProductDoesntExist(IErrorIndex index) { try { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "fileslink", 1, "Name", 10, 11, "version"); StackHashFile file = new StackHashFile(); StackHashEvent theEvent = new StackHashEvent(); StackHashCab cab = new StackHashCab(); StackHashNoteEntry note = new StackHashNoteEntry(); index.AddCabNote(product, file, theEvent, cab, note); } catch (ArgumentException ex) { Assert.AreEqual("product", ex.ParamName); throw; } }
private void testAddEventInfoNullFile(IErrorIndex index) { try { 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); StackHashEvent theEvent = new StackHashEvent(); StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection(); index.AddEventInfoCollection(product, null, theEvent, eventInfoCollection); } catch (ArgumentNullException ex) { Assert.AreEqual("file", ex.ParamName); throw; } }
/// <summary> /// Converts a WinQual Event into a StackHashEvent. /// </summary> /// <param name="thisEvent">WinQual event to convert.</param> /// <param name="fileId">Id of the owning file.</param> /// <returns>Converted event.</returns> public static StackHashEvent ConvertEvent(Event thisEvent, int fileId) { if (thisEvent == null) { throw new ArgumentNullException("thisEvent"); } StackHashEventSignature eventSignature = ConvertEventSignature(thisEvent.Signature); StackHashEvent newEvent = new StackHashEvent( thisEvent.DateCreatedLocal.ToUniversalTime(), thisEvent.DateModifiedLocal.ToUniversalTime(), thisEvent.EventTypeName, thisEvent.ID, eventSignature, thisEvent.TotalHits, fileId); return(newEvent); }
public void getProductEvents(IErrorIndex index, int numProducts, int numFiles, int numEvents) { StackHashProductCollection products = new StackHashProductCollection(); int productId = 0x1234567; int eventsForThisProduct = numEvents; int eventId = 10000; int fileId = 20; for (int productCount = 0; productCount < numProducts; productCount++) { 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 product = new StackHashProduct(creationDateTime, modifiedDateTime, "www.files.com", productId + productCount, @"P""r:o?d:u@(XP_2k)", productCount, productCount + 1, "1:2:3:4"); index.AddProduct(product); products.Add(product); for (int i = 0; i < numFiles; i++) { StackHashFile file = new StackHashFile(DateTime.Now, DateTime.Now, fileId++, DateTime.Now, "FileName", "1.2.3.4"); index.AddFile(product, file); for (int j = 0; j < eventsForThisProduct; j++) { StackHashEvent theEvent = new StackHashEvent(DateTime.Now, DateTime.Now, "Event type", eventId++, new StackHashEventSignature(), j, i + 1000); theEvent.EventSignature.Parameters = new StackHashParameterCollection(); index.AddEvent(product, file, theEvent); } } eventsForThisProduct += 10; } eventsForThisProduct = numEvents; for (int productCount = 0; productCount < numProducts; productCount++) { StackHashEventPackageCollection events = index.GetProductEvents(products[productCount]); Assert.AreEqual(numFiles * eventsForThisProduct, events.Count); eventsForThisProduct += 10; } }
public void Beta5EventUpgradeBugId() { String beta4EventFile = TestSettings.TestDataFolder + @"settings\beta4event.xml"; XmlSerializer m_EventSerializer = new XmlSerializer(typeof(StackHashEvent), new Type[] { typeof(StackHashEvent), typeof(StackHashEventSignature), typeof(StackHashParameterCollection), typeof(StackHashParameter) }); FileStream fileStream = File.Open(beta4EventFile, FileMode.Open, FileAccess.Read); try { StackHashEvent theEvent = m_EventSerializer.Deserialize(fileStream) as StackHashEvent; // Beta 4 fields. Assert.AreEqual(DateTime.Parse("2010-04-19T10:20:00Z").ToUniversalTime(), theEvent.DateCreatedLocal); Assert.AreEqual(DateTime.Parse("2010-04-19T10:20:00Z").ToUniversalTime(), theEvent.DateModifiedLocal); Assert.AreEqual(@"CLR20 Managed Crash", theEvent.EventTypeName); Assert.AreEqual(1099298216, theEvent.Id); Assert.AreEqual(1, theEvent.TotalHits); Assert.AreEqual(4232330, theEvent.FileId); Assert.AreEqual(@"Crashy.exe", theEvent.EventSignature.ApplicationName); Assert.AreEqual(@"1.2.3.4", theEvent.EventSignature.ApplicationVersion); Assert.AreEqual(DateTime.Parse("2010-04-16T22:21:32"), theEvent.EventSignature.ApplicationTimeStamp); Assert.AreEqual(@"Crashy", theEvent.EventSignature.ModuleName); Assert.AreEqual(@"1.2.3.4", theEvent.EventSignature.ModuleVersion); Assert.AreEqual(DateTime.Parse("2010-04-16T22:21:32"), theEvent.EventSignature.ModuleTimeStamp); Assert.AreEqual(152, theEvent.EventSignature.Offset); Assert.AreEqual(0, theEvent.EventSignature.ExceptionCode); // Beta 5 fields. Assert.AreEqual(null, theEvent.BugId); } finally { if (fileStream != null) { fileStream.Close(); } } }
/// <summary> /// Determines if the specified cab should be processed. /// </summary> /// <param name="product">The product to check.</param> /// <param name="file">The file to check.</param> /// <param name="theEvent">The event to check.</param> /// <param name="cab">The product to check.</param> /// <returns>True - process the cab, false - don't process.</returns> private bool shouldProcessCab(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab) { if (product == null) { return(false); } if (file == null) { return(false); } if (theEvent == null) { return(false); } if (cab == null) { return(false); } return(true); }
/// <summary> /// Process an event note table update. This may indicate a new item or the change to an existing item. /// </summary> private bool processEventNoteUpdate(StackHashBugTrackerUpdate update) { // Get the associated product and file information. StackHashProduct product = m_Index.GetProduct((int)update.ProductId); StackHashFile file = m_Index.GetFile(product, (int)update.FileId); StackHashEvent theEvent = m_Index.GetEvent(product, file, new StackHashEvent((int)update.EventId, update.EventTypeName)); StackHashNoteEntry note = m_Index.GetEventNote((int)update.ChangedObjectId); if ((product == null) || (file == null) || (theEvent == null) || (note == null)) { DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Event Note: Inconsistent Update Table Entry"); return(false); } BugTrackerProduct btProduct = new BugTrackerProduct(product.Name, product.Version, product.Id); BugTrackerFile btFile = new BugTrackerFile(file.Name, file.Version, file.Id); NameValueCollection eventSignature = new NameValueCollection(); foreach (StackHashParameter param in theEvent.EventSignature.Parameters) { eventSignature.Add(param.Name, param.Value); } BugTrackerEvent btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, eventSignature); BugTrackerNote btEventNote = new BugTrackerNote(note.TimeOfEntry, note.Source, note.User, note.Note); String newBugId = null; if (update.TypeOfChange == StackHashChangeType.NewEntry) { newBugId = m_TaskParameters.PlugInContext.EventNoteAdded(null, BugTrackerReportType.Automatic, btProduct, btFile, btEvent, btEventNote); } setPlugInBugReference(product, file, theEvent, newBugId); return(true); }
public void ConflictEventAndSameProduct() { StackHashProduct product1 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4"); StackHashBugReportData data1 = new StackHashBugReportData(product1, null, null, null, null, StackHashReportOptions.IncludeAllObjects); StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection() { data1 }; StackHashProduct product2 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4"); StackHashFile file2 = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "File1", "1.2.3.4"); StackHashEvent event2 = new StackHashEvent(1, "EventTypeName1"); StackHashBugReportData data2 = new StackHashBugReportData(product2, file2, event2, null, null, StackHashReportOptions.IncludeAllObjects); StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection() { data2 }; Assert.AreEqual(true, allData2.IsConflicting(allData1)); }
private void testAddCabNoteNullNote(IErrorIndex index) { try { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "fileslink", 1, "Name", 10, 11, "version"); StackHashFile file = new StackHashFile(DateTime.Now, DateTime.Now, 6, DateTime.Now, "FileName", "FileVersion"); StackHashEvent theEvent = new StackHashEvent(DateTime.Now, DateTime.Now, "TypeName", 10, new StackHashEventSignature(), 10, 2); StackHashCab cab = new StackHashCab(); index.AddProduct(product); index.AddFile(product, file); index.AddEvent(product, file, theEvent); index.AddCabNote(product, file, theEvent, cab, null); } catch (ArgumentNullException ex) { Assert.AreEqual("note", ex.ParamName); throw; } }
public StackHashScriptResult GetResultFileData(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, String scriptName) { if (scriptName == null) { throw new ArgumentNullException("scriptName"); } if (cab == null) { throw new ArgumentNullException("cab"); } String cabFileFolder = m_ErrorIndex.GetCabFolder(product, file, theEvent, cab); String resultsFileName = String.Format(CultureInfo.InvariantCulture, "{0}\\Analysis\\{1}.log", cabFileFolder, scriptName); if (!File.Exists(resultsFileName)) { return(null); } StackHashScriptResult result = null; try { result = new StackHashScriptResult(resultsFileName); } catch (System.Exception ex) { // Don't allow corrupt files to stop the search. DiagnosticsHelper.LogException(DiagSeverity.Warning, "Corrupt or missing results file: " + scriptName + " for cab " + cab.Id.ToString(CultureInfo.InvariantCulture), ex); } return(result); }
private void testAddCabNNotes(IErrorIndex index, int numNotes) { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "fileslink", 1, "Name", 10, 11, "version"); StackHashFile file = new StackHashFile(DateTime.Now, DateTime.Now, 6, DateTime.Now, "FileName", "FileVersion"); StackHashEvent theEvent = new StackHashEvent(DateTime.Now, DateTime.Now, "TypeName", 10, new StackHashEventSignature(), 10, 2); StackHashCab cab = new StackHashCab(DateTime.Now, DateTime.Now, 10, "Type", "EventFileName", 10, 100); index.AddProduct(product); index.AddFile(product, file); index.AddEvent(product, file, theEvent); index.AddCab(product, file, theEvent, cab, false); StackHashNotes allNotes = new StackHashNotes(); for (int i = 0; i < numNotes; i++) { StackHashNoteEntry note = new StackHashNoteEntry(new DateTime(i), "Source" + i.ToString(), "User" + i.ToString(), "Notes...." + i.ToString()); allNotes.Add(note); index.AddCabNote(product, file, theEvent, cab, note); } // Get the list back. StackHashNotes notes = index.GetCabNotes(product, file, theEvent, cab); Assert.AreEqual(numNotes, notes.Count); for (int i = 0; i < numNotes; i++) { Assert.AreEqual(allNotes[i].TimeOfEntry, notes[i].TimeOfEntry); Assert.AreEqual(allNotes[i].Source, notes[i].Source); Assert.AreEqual(allNotes[i].User, notes[i].User); Assert.AreEqual(allNotes[i].Note, notes[i].Note); } }