예제 #1
0
        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);
        }
예제 #2
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);
        }
예제 #3
0
        public void RunScriptOnCorruptCab()
        {
            // 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);

            // Delete the cab file.
            StackHashProduct product = errorIndex.GetProduct(1);
            StackHashFile    file    = errorIndex.GetFile(product, 1);
            StackHashEventPackageCollection events = errorIndex.GetProductEvents(product);

            String cabFileName = errorIndex.GetCabFileName(product, file, events[0].EventData, events[0].Cabs[0].Cab);

            if (File.Exists(cabFileName))
            {
                FileStream fileStream = File.Open(cabFileName, FileMode.Open, FileAccess.ReadWrite);

                try
                {
                    fileStream.SetLength(100);
                }
                finally
                {
                    fileStream.Close();
                }
            }


            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.
            DebugScriptTaskParameters runScriptParams = new DebugScriptTaskParameters();

            // Standard task parameters.
            runScriptParams.IsBackgroundTask        = true;
            runScriptParams.Name                    = "TestRunOneTask";
            runScriptParams.RunInParallel           = false;
            runScriptParams.UseSeparateThread       = true;
            runScriptParams.ContextId               = 0;
            runScriptParams.ClientData              = new StackHashClientData(Guid.NewGuid(), "MarkJ", 1);
            runScriptParams.Debugger                = m_Debugger;
            runScriptParams.TheScriptManager        = scriptManager;
            runScriptParams.TheScriptResultsManager = scriptResultsManager;
            runScriptParams.Product                 = product;
            runScriptParams.File                    = file;
            runScriptParams.TheEvent                = events[0].EventData;
            runScriptParams.Cab        = events[0].Cabs[0].Cab;
            runScriptParams.ErrorIndex = errorIndex;

            // Create the task and run it.
            DebugScriptTask debugScriptTask = new DebugScriptTask(runScriptParams);
            TaskManager     taskManager     = new TaskManager("Test");

            taskManager.Enqueue(debugScriptTask);

            taskManager.WaitForTaskCompletion(debugScriptTask, s_TaskTimeout);

            Assert.AreEqual(true, debugScriptTask.CurrentTaskState.TaskCompleted);

            Assert.AreNotEqual(null, debugScriptTask.LastException);
            Assert.AreEqual(true, debugScriptTask.LastException is StackHashException);

            StackHashException ex = debugScriptTask.LastException as StackHashException;

            Assert.AreEqual(StackHashServiceErrorCode.CabIsCorrupt, ex.ServiceErrorCode);

            StackHashCabCollection cabs     = errorIndex.LoadCabList(product, file, events[0].EventData);
            StackHashDumpAnalysis  analysis = cabs[0].DumpAnalysis;
        }