public void FaultSettingsNull() { String diagnosticsFileName = Path.Combine(m_LogFolder, "StackHashServiceDiagnosticsLog_00000001.txt"); double size1 = 0; double size2 = 0; try { m_Utils.EnableLogging(); FileInfo info = new FileInfo(diagnosticsFileName); size1 = info.Length; SetStackHashPropertiesResponse resp = m_Utils.SetContextSettings(null); } catch (FaultException <ReceiverFaultDetail> ex) { FileInfo info = new FileInfo(diagnosticsFileName); size2 = info.Length; m_Utils.DisableLogging(); Assert.AreEqual(true, ex.Message.Contains("Value cannot be null")); Assert.AreEqual(true, ex.Message.Contains("contextSettings")); Assert.AreEqual(StackHashServiceErrorCode.UnexpectedError, ex.Detail.ServiceErrorCode); Assert.AreEqual(true, size1 < size2); throw; } }
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); } }
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); } }
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); } }