Ejemplo n.º 1
0
        public void MoveErrorIndexBeforeCreation()
        {
            m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);

            CreateNewStackHashContextResponse newContextResp = m_Utils.CreateNewContext();

            Assert.AreEqual(ErrorIndexStatus.NotCreated, newContextResp.Settings.ErrorIndexSettings.Status);

            String originalIndexPath = newContextResp.Settings.ErrorIndexSettings.Folder;

            Assert.AreEqual(false, Directory.Exists(originalIndexPath));

            String testPath  = "c:\\stackhashunittests\\testindex\\";
            String indexName = "ShouldNeverExist";


            m_Utils.MoveIndex(0, testPath, indexName, 10000, newContextResp.Settings.SqlSettings);

            // Read them back and make sure they have changed.
            GetStackHashPropertiesResponse resp = m_Utils.GetContextSettings();

            Assert.AreEqual(1, resp.Settings.ContextCollection.Count);
            Assert.AreEqual(false, resp.Settings.ContextCollection[0].IsActive);

            Assert.AreEqual(testPath.ToUpperInvariant(),
                            resp.Settings.ContextCollection[0].ErrorIndexSettings.Folder.ToUpperInvariant());
            Assert.AreEqual(indexName.ToUpperInvariant(),
                            resp.Settings.ContextCollection[0].ErrorIndexSettings.Name.ToUpperInvariant());

            Assert.AreEqual(ErrorIndexStatus.NotCreated, newContextResp.Settings.ErrorIndexSettings.Status);
            Assert.AreEqual(false, Directory.Exists(Path.Combine(testPath, indexName)));
        }
Ejemplo n.º 2
0
        public void MoveEmptyIndex()
        {
            try
            {
                m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);
                SetStackHashPropertiesResponse newContextResp = m_Utils.CreateAndSetNewContext(); // Create a context and give it a non-default name.
                m_Utils.DeleteIndex(0);

                GetStackHashPropertiesResponse getResp = m_Utils.GetContextSettings();
                Assert.AreEqual(ErrorIndexStatus.NotCreated, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);

                m_Utils.ActivateContext(0); // Create the index.

                getResp = m_Utils.GetContextSettings();
                Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);

                String originalIndexPath = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder;
                String originalIndexName = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name;


                String indexName = "NewIndexName";
                String testPath  = "c:\\stackhashunittests\\testindex\\";

                // Make sure the destination folder does not exist.
                String fullDestPath = Path.Combine(testPath, indexName);

                if (Directory.Exists(fullDestPath))
                {
                    PathUtils.DeleteDirectory(fullDestPath, true);
                }

                m_Utils.DeactivateContext(0); // Must be inactive before the move.
                m_Utils.MoveIndex(0, testPath, indexName, 20000, newContextResp.Settings.ContextCollection[0].SqlSettings);

                Assert.AreEqual(false, Directory.Exists(Path.Combine(originalIndexPath, originalIndexName)));
                Assert.AreEqual(true, Directory.Exists(Path.Combine(testPath, indexName)));

                Assert.AreEqual(null, m_Utils.MoveCompleteAdminReport.LastException);
                Assert.AreEqual(StackHashAsyncOperationResult.Success, m_Utils.MoveCompleteAdminReport.ResultData);


                getResp = m_Utils.GetContextSettings();
                Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);
                Assert.AreEqual(testPath.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder.ToUpperInvariant());
                Assert.AreEqual(indexName.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name.ToUpperInvariant());
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Ejemplo n.º 3
0
        public void MoveCannotWhenProfileActive()
        {
            try
            {
                m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);
                SetStackHashPropertiesResponse newContextResp = m_Utils.CreateAndSetNewContext(); // Create a context and give it a non-default name.

                GetStackHashPropertiesResponse getResp = m_Utils.GetContextSettings();
                Assert.AreEqual(ErrorIndexStatus.NotCreated, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);

                m_Utils.ActivateContext(0); // Create the index.

                getResp = m_Utils.GetContextSettings();

                String originalIndexPath = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder;
                String originalIndexName = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name;

                Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);

                String indexName = "NewIndexName";
                String testPath  = "c:\\stackhashunittests\\testindex\\";

                String destinationFolder = Path.Combine(testPath, indexName);

                // Make sure the test directory doesn't exist.
                if (Directory.Exists(destinationFolder))
                {
                    PathUtils.DeleteDirectory(destinationFolder, true);
                }

                bool exceptionOccurred = false;
                try
                {
                    m_Utils.MoveIndex(0, testPath, indexName, 20000, newContextResp.Settings.ContextCollection[0].SqlSettings);
                }
                catch (FaultException <ReceiverFaultDetail> ex)
                {
                    exceptionOccurred = true;
                    Assert.AreEqual(true, ex.Message.Contains("Context must be inactive"));
                }

                Assert.AreEqual(true, exceptionOccurred);

                Assert.AreEqual(true, Directory.Exists(Path.Combine(originalIndexPath, originalIndexName)));
                Assert.AreEqual(false, Directory.Exists(destinationFolder));
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Ejemplo n.º 4
0
        public void MyTestInitialize()
        {
            m_Utils = new Utils();

            GetStackHashPropertiesResponse getResp = m_Utils.GetContextSettings();

            foreach (StackHashContextSettings settings in getResp.Settings.ContextCollection)
            {
                m_Utils.DeactivateContext(settings.Id);
                m_Utils.DeleteIndex(settings.Id);
                m_Utils.RemoveContext(settings.Id);
            }
            m_Utils.RestartService();

            tidyTest();
        }
Ejemplo n.º 5
0
        // Set the workflow status.
        public void getDefaultWorkFlowStatus(ErrorIndexType indexType, bool resetService)
        {
            // Add a context.
            CreateNewStackHashContextResponse resp = m_Utils.CreateNewContext(indexType);

            Assert.AreEqual(null, resp.Settings.WorkFlowMappings);

            String testPath = "c:\\stackhashunittests\\testindex\\";

            resp.Settings.ErrorIndexSettings.Folder = testPath;
            resp.Settings.ErrorIndexSettings.Name   = "TestIndex";
            m_Utils.SetContextSettings(resp.Settings);
            m_Utils.DeleteIndex(0); // Make sure it is empty.

            // Workflow should still be null.
            GetStackHashPropertiesResponse getSettingsResp = m_Utils.GetContextSettings();

            Assert.AreEqual(null, resp.Settings.WorkFlowMappings);

            m_Utils.ActivateContext(0);

            // Workflow should now be set.
            getSettingsResp = m_Utils.GetContextSettings();
            Assert.AreNotEqual(null, getSettingsResp.Settings.ContextCollection[0].WorkFlowMappings);
            Assert.AreEqual(16, getSettingsResp.Settings.ContextCollection[0].WorkFlowMappings.Count);

            if (resetService)
            {
                m_Utils.RestartService();
            }

            // Workflow should now be set.
            getSettingsResp = m_Utils.GetContextSettings();
            Assert.AreNotEqual(null, getSettingsResp.Settings.ContextCollection[0].WorkFlowMappings);
            Assert.AreEqual(16, getSettingsResp.Settings.ContextCollection[0].WorkFlowMappings.Count);

            m_Utils.DeactivateContext(0);

            // Workflow should still be set when deactivated.
            getSettingsResp = m_Utils.GetContextSettings();
            Assert.AreNotEqual(null, getSettingsResp.Settings.ContextCollection[0].WorkFlowMappings);
            Assert.AreEqual(16, getSettingsResp.Settings.ContextCollection[0].WorkFlowMappings.Count);

            m_Utils.DeleteIndex(0);
        }
Ejemplo n.º 6
0
        public void MyTestCleanup()
        {
            GetStackHashPropertiesResponse getResp = m_Utils.GetContextSettings();

            foreach (StackHashContextSettings settings in getResp.Settings.ContextCollection)
            {
                m_Utils.DeactivateContext(settings.Id);
                m_Utils.DeleteIndex(settings.Id);
                m_Utils.RemoveContext(settings.Id);
            }
            tidyTest();

            if (m_Utils != null)
            {
                m_Utils.Dispose();
                m_Utils = null;
            }
        }
Ejemplo n.º 7
0
        public void SetIndexSettingsBeforeCreation()
        {
            CreateNewStackHashContextResponse newContextResp = m_Utils.CreateNewContext();

            Assert.AreEqual(ErrorIndexStatus.NotCreated, newContextResp.Settings.ErrorIndexSettings.Status);

            String originalIndexPath = newContextResp.Settings.ErrorIndexSettings.Folder;

            Assert.AreEqual(false, Directory.Exists(originalIndexPath));

            String indexName = "ShouldNeverExist";
            String testPath  = "c:\\stackhashunittests\\testindex\\";

            m_Utils.DeleteIndex(0);

            // Make sure the destination folder does not exist.
            String fullDestPath = Path.Combine(testPath, indexName);

            if (Directory.Exists(fullDestPath))
            {
                PathUtils.DeleteDirectory(fullDestPath, true);
            }

            newContextResp.Settings.ErrorIndexSettings.Folder = testPath;
            newContextResp.Settings.ErrorIndexSettings.Name   = indexName;

            m_Utils.SetContextSettings(newContextResp.Settings);

            // Read them back and make sure they have changed.
            GetStackHashPropertiesResponse resp = m_Utils.GetContextSettings();

            Assert.AreEqual(1, resp.Settings.ContextCollection.Count);
            Assert.AreEqual(false, resp.Settings.ContextCollection[0].IsActive);

            Assert.AreEqual(newContextResp.Settings.ErrorIndexSettings.Folder,
                            resp.Settings.ContextCollection[0].ErrorIndexSettings.Folder);
            Assert.AreEqual(newContextResp.Settings.ErrorIndexSettings.Name,
                            resp.Settings.ContextCollection[0].ErrorIndexSettings.Name);
            Assert.AreEqual(ErrorIndexStatus.NotCreated, newContextResp.Settings.ErrorIndexSettings.Status);
            Assert.AreEqual(false, Directory.Exists(Path.Combine(testPath, indexName)));
        }
Ejemplo n.º 8
0
        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);
            }
        }
Ejemplo n.º 9
0
        public void MoveNonEmptyIndex()
        {
            try
            {
                m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);
                SetStackHashPropertiesResponse newContextResp = m_Utils.CreateAndSetNewContext(); // Create a context and give it a non-default name.


                GetStackHashPropertiesResponse getResp = m_Utils.GetContextSettings();
                Assert.AreEqual(ErrorIndexStatus.NotCreated, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);

                m_Utils.ActivateContext(0); // Create the index.

                getResp = m_Utils.GetContextSettings();
                Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);

                // Create a small error index.
                StackHashTestIndexData testIndexData = new StackHashTestIndexData();
                testIndexData.NumberOfProducts   = 1;
                testIndexData.NumberOfFiles      = 1;
                testIndexData.NumberOfEvents     = 1;
                testIndexData.NumberOfEventInfos = 1;
                testIndexData.NumberOfCabs       = 1;
                m_Utils.CreateTestIndex(0, testIndexData);

                String originalIndexPath = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder;
                String originalIndexName = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name;


                String indexName = "NewIndexName";
                String testPath  = "c:\\stackhashunittests\\testindex\\";

                // TODO: This won't work if testing across machines.

                // Make sure the destination folder does not exist.
                String fullDestPath = Path.Combine(testPath, indexName);

                if (Directory.Exists(fullDestPath))
                {
                    PathUtils.DeleteDirectory(fullDestPath, true);
                }

                m_Utils.DeactivateContext(0); // Must be inactive before the move.
                m_Utils.MoveIndex(0, testPath, indexName, 20000, newContextResp.Settings.ContextCollection[0].SqlSettings);
                m_Utils.ActivateContext(0);   // Must be inactive before the move.

                Assert.AreEqual(false, Directory.Exists(Path.Combine(originalIndexPath, originalIndexName)));
                Assert.AreEqual(true, Directory.Exists(Path.Combine(testPath, indexName)));

                Assert.AreEqual(null, m_Utils.MoveCompleteAdminReport.LastException);
                Assert.AreEqual(StackHashAsyncOperationResult.Success, m_Utils.MoveCompleteAdminReport.ResultData);


                getResp = m_Utils.GetContextSettings();
                Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);
                Assert.AreEqual(testPath.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder.ToUpperInvariant());
                Assert.AreEqual(indexName.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name.ToUpperInvariant());

                // Check that the products etc.. have been moved.
                GetProductsResponse products = m_Utils.GetProducts(0);
                Assert.AreEqual(1, products.Products.Count);

                foreach (StackHashProductInfo productInfo in products.Products)
                {
                    StackHashProduct product = productInfo.Product;

                    GetFilesResponse files = m_Utils.GetFiles(0, product);
                    Assert.AreEqual(1, files.Files.Count);

                    foreach (StackHashFile file in files.Files)
                    {
                        GetEventsResponse events = m_Utils.GetEvents(0, product, file);
                        Assert.AreEqual(1, events.Events.Count);

                        foreach (StackHashEvent theEvent in events.Events)
                        {
                            GetEventPackageResponse eventPackage = m_Utils.GetEventPackage(0, product, file, theEvent);

                            Assert.AreEqual(1, eventPackage.EventPackage.Cabs.Count);
                            Assert.AreEqual(1, eventPackage.EventPackage.EventInfoList.Count);
                        }
                    }
                }
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Ejemplo n.º 10
0
        //
        // 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 copyIndex(bool createDestinationIndexLocally, bool switchIndex, StackHashTestIndexData testData)
        {
            try
            {
                m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);
                m_Utils.CreateAndSetNewContext(ErrorIndexType.Xml); // Create a context and give it a non-default name.
                m_Utils.DeleteIndex(0);

                GetStackHashPropertiesResponse getResp = m_Utils.GetContextSettings();
                Assert.AreEqual(ErrorIndexStatus.NotCreated, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);

                m_Utils.ActivateContext(0); // Create the index.
                m_Utils.CreateTestIndex(0, testData);


                getResp = m_Utils.GetContextSettings();
                Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);

                String originalIndexPath = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder;
                String originalIndexName = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name;

                String destIndexName = "UnitTestsCopyIndexName";
                String destIndexPath = "c:\\stackhashunittests\\copyindexpath\\";

                // Make sure the destination folder does not exist.
                String fullDestPath = Path.Combine(destIndexPath, destIndexName);

                if (Directory.Exists(fullDestPath))
                {
                    PathUtils.DeleteDirectory(fullDestPath, true);
                }


                ErrorIndexSettings destSettings = new ErrorIndexSettings()
                {
                    Folder = destIndexPath,
                    Name   = destIndexName,
                    Type   = ErrorIndexType.SqlExpress
                };

                StackHashSqlConfiguration sqlConfig = new StackHashSqlConfiguration()
                {
                    ConnectionString  = String.Format(TestSettings.DefaultConnectionString, destIndexName),
                    InitialCatalog    = destIndexName,
                    MaxPoolSize       = 100,
                    MinPoolSize       = 2,
                    ConnectionTimeout = 20,
                };

                if (createDestinationIndexLocally)
                {
                    StackHashSqlControl.InstallerInterface installerInterface =
                        new StackHashSqlControl.InstallerInterface(TestSettings.DefaultConnectionString + "Initial Catalog=MASTER;",
                                                                   destSettings.Name, destSettings.Folder);

                    installerInterface.Connect();
                    installerInterface.CreateDatabase(true);
                    installerInterface.Disconnect();
                    SqlConnection.ClearAllPools();
                }

                m_Utils.DeactivateContext(0);
                m_Utils.CopyIndex(0, destSettings, sqlConfig, switchIndex, 60000);
                m_Utils.ActivateContext(0);

                Assert.AreEqual(true, Directory.Exists(Path.Combine(originalIndexPath, originalIndexName)));
                Assert.AreEqual(true, Directory.Exists(fullDestPath));

                Assert.AreNotEqual(null, m_Utils.CopyCompleteAdminReport);
                Assert.AreEqual(null, m_Utils.CopyCompleteAdminReport.LastException);
                Assert.AreEqual(StackHashAsyncOperationResult.Success, m_Utils.CopyCompleteAdminReport.ResultData);


                getResp = m_Utils.GetContextSettings();

                if (switchIndex)
                {
                    Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);
                    Assert.AreEqual(destSettings.Folder.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder.ToUpperInvariant());
                    Assert.AreEqual(destSettings.Name.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name.ToUpperInvariant());
                }
                else
                {
                    Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status);
                    Assert.AreEqual(originalIndexPath.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder.ToUpperInvariant());
                    Assert.AreEqual(originalIndexName.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name.ToUpperInvariant());
                }
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Ejemplo n.º 11
0
        public void SetIndexSettingsBeforeCreationSql()
        {
            CreateNewStackHashContextResponse newContextResp = m_Utils.CreateNewContext(ErrorIndexType.SqlExpress);

            Assert.AreEqual(ErrorIndexStatus.NotCreated, newContextResp.Settings.ErrorIndexSettings.Status);

            String originalIndexPath = newContextResp.Settings.ErrorIndexSettings.Folder;

            Assert.AreEqual(false, Directory.Exists(originalIndexPath));

            String indexName = "ShouldNeverExist";
            String testPath  = "c:\\stackhashunittests\\testindex\\";

            m_Utils.DeleteIndex(0);

            // Make sure the destination folder does not exist.
            String fullDestPath = Path.Combine(testPath, indexName);

            if (Directory.Exists(fullDestPath))
            {
                PathUtils.DeleteDirectory(fullDestPath, true);
            }

            newContextResp.Settings.ErrorIndexSettings.Folder     = testPath;
            newContextResp.Settings.ErrorIndexSettings.Name       = indexName;
            newContextResp.Settings.ErrorIndexSettings.Type       = ErrorIndexType.SqlExpress;
            newContextResp.Settings.SqlSettings.ConnectionString  = TestSettings.DefaultConnectionString;
            newContextResp.Settings.SqlSettings.InitialCatalog    = indexName;
            newContextResp.Settings.SqlSettings.EventsPerBlock    = 20;
            newContextResp.Settings.SqlSettings.ConnectionTimeout = 10;
            newContextResp.Settings.SqlSettings.MaxPoolSize       = 8;
            newContextResp.Settings.SqlSettings.MinPoolSize       = 3;
            m_Utils.SetContextSettings(newContextResp.Settings);

            m_Utils.RestartService();

            // Read them back and make sure they have changed.
            GetStackHashPropertiesResponse resp = m_Utils.GetContextSettings();

            Assert.AreEqual(1, resp.Settings.ContextCollection.Count);
            Assert.AreEqual(false, resp.Settings.ContextCollection[0].IsActive);

            Assert.AreEqual(newContextResp.Settings.ErrorIndexSettings.Folder,
                            resp.Settings.ContextCollection[0].ErrorIndexSettings.Folder);
            Assert.AreEqual(newContextResp.Settings.ErrorIndexSettings.Name,
                            resp.Settings.ContextCollection[0].ErrorIndexSettings.Name);
            Assert.AreEqual(newContextResp.Settings.ErrorIndexSettings.Type,
                            resp.Settings.ContextCollection[0].ErrorIndexSettings.Type);
            Assert.AreEqual(newContextResp.Settings.SqlSettings.ConnectionString,
                            resp.Settings.ContextCollection[0].SqlSettings.ConnectionString);
            Assert.AreEqual(newContextResp.Settings.SqlSettings.ConnectionTimeout,
                            resp.Settings.ContextCollection[0].SqlSettings.ConnectionTimeout);
            Assert.AreEqual(newContextResp.Settings.SqlSettings.EventsPerBlock,
                            resp.Settings.ContextCollection[0].SqlSettings.EventsPerBlock);
            Assert.AreEqual(newContextResp.Settings.SqlSettings.InitialCatalog,
                            resp.Settings.ContextCollection[0].SqlSettings.InitialCatalog);
            Assert.AreEqual(newContextResp.Settings.SqlSettings.MaxPoolSize,
                            resp.Settings.ContextCollection[0].SqlSettings.MaxPoolSize);
            Assert.AreEqual(newContextResp.Settings.SqlSettings.MinPoolSize,
                            resp.Settings.ContextCollection[0].SqlSettings.MinPoolSize);


            Assert.AreEqual(ErrorIndexStatus.NotCreated, newContextResp.Settings.ErrorIndexSettings.Status);
            Assert.AreEqual(false, Directory.Exists(Path.Combine(testPath, indexName)));
        }