protected override void SetUp() { base.SetUp(); RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataWriter)); RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataInventor)); _lmd = new LoadMetadata(CatalogueRepository, "Ive got a lovely bunch o' coconuts"); _LoadDirectory = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), @"EndToEndCacheTest", true); _lmd.LocationOfFlatFiles = _LoadDirectory.RootPath.FullName; _lmd.SaveToDatabase(); Clear(_LoadDirectory); _cata = new Catalogue(CatalogueRepository, "EndToEndCacheTest"); _cata.LoadMetadata_ID = _lmd.ID; _cata.SaveToDatabase(); _lp = new LoadProgress(CatalogueRepository, _lmd); _cp = new CacheProgress(CatalogueRepository, _lp); _lp.OriginDate = new DateTime(2001, 1, 1); _lp.SaveToDatabase(); _testPipeline = new TestDataPipelineAssembler("EndToEndCacheTestPipeline" + Guid.NewGuid(), CatalogueRepository); _testPipeline.ConfigureCacheProgressToUseThePipeline(_cp); _cp.CacheFillProgress = DateTime.Now.AddDays(-NumDaysToCache); _cp.SaveToDatabase(); _cp.SaveToDatabase(); }
public void CacheProvider_NoPipeline() { var pt1 = new ProcessTask(CatalogueRepository, _lmd, LoadStage.GetFiles); pt1.Path = typeof(TestCachedFileRetriever).FullName; pt1.ProcessTaskType = ProcessTaskType.DataProvider; pt1.Name = "Cache1"; pt1.SaveToDatabase(); _cp.CacheFillProgress = new DateTime(1999, 1, 1); _cp.Name = "MyTestCp"; _cp.SaveToDatabase(); pt1.CreateArgumentsForClassIfNotExists <TestCachedFileRetriever>(); var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", true); _lmd.LocationOfFlatFiles = projDir.RootPath.FullName; _lmd.SaveToDatabase(); try { var ex = Assert.Throws <Exception>(() => _factory.Create(_lp, new ThrowImmediatelyDataLoadEventListener())); Assert.AreEqual("CacheProgress MyTestCp does not have a Pipeline configured on it", ex.Message); } finally { projDir.RootPath.Delete(true); } }
public void ConfirmLogs_With2CacheProgress_Throws() { var lmd1 = new LoadMetadata(CatalogueRepository, "MyLmd"); var cata = new Catalogue(CatalogueRepository, "myCata"); cata.LoadMetadata_ID = lmd1.ID; cata.LoggingDataTask = "B"; cata.SaveToDatabase(); var lmd2 = new LoadMetadata(CatalogueRepository, "MyLmd"); var cata2 = new Catalogue(CatalogueRepository, "myCata"); cata2.LoadMetadata_ID = lmd2.ID; cata2.LoggingDataTask = "A"; cata2.SaveToDatabase(); var lp1 = new LoadProgress(CatalogueRepository, lmd1); var lp2 = new LoadProgress(CatalogueRepository, lmd2); var cp1 = new CacheProgress(CatalogueRepository, lp1); var cp2 = new CacheProgress(CatalogueRepository, lp2); cp2.Name = "MyCoolCache"; cp2.SaveToDatabase(); var lm = new LogManager(cp1.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists(cp1.GetDistinctLoggingTask()); // create a log entry for cp1 only var logEntry = lm.CreateDataLoadInfo(cp1.GetDistinctLoggingTask(), "pack o' cards", cp1.GetLoggingRunName(), null, true); // we mark it as completed successfully - this is a good, happy log entry logEntry.CloseAndMarkComplete(); // The first cache has logged success so should be happy var cmd1 = new ExecuteCommandConfirmLogs(new ThrowImmediatelyActivator(RepositoryLocator), cp1, null); Assert.DoesNotThrow(() => cmd1.Execute()); // The second cache has not logged any successes so should be unhappy var cmd2 = new ExecuteCommandConfirmLogs(new ThrowImmediatelyActivator(RepositoryLocator), cp2, null); var ex = Assert.Throws <LogsNotConfirmedException>(() => cmd2.Execute()); Assert.AreEqual("There are no log entries for MyCoolCache", ex.Message); }
public override void Execute() { base.Execute(); if (_window == null) { _window = SelectOne <PermissionWindow>(Activator.RepositoryLocator.CatalogueRepository); } if (_window == null) { return; } _cacheProgress.PermissionWindow_ID = _window.ID; _cacheProgress.SaveToDatabase(); Publish(_cacheProgress); }
public void RunEndToEndDLECacheTest() { RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataWriter)); RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataInventor)); int timeoutInMilliseconds = 120000; var lmd = TestLoadMetadata; LoadProgress lp = new LoadProgress(CatalogueRepository, lmd); lp.DataLoadProgress = new DateTime(2001, 1, 1); lp.DefaultNumberOfDaysToLoadEachTime = 10; lp.SaveToDatabase(); var cp = new CacheProgress(CatalogueRepository, lp); cp.CacheFillProgress = new DateTime(2001, 1, 11); //10 days available to load cp.SaveToDatabase(); var assembler = new TestDataPipelineAssembler("RunEndToEndDLECacheTest pipe", CatalogueRepository); assembler.ConfigureCacheProgressToUseThePipeline(cp); //setup the cache process task var pt = new ProcessTask(CatalogueRepository, lmd, LoadStage.GetFiles); pt.Path = typeof(BasicCacheDataProvider).FullName; pt.ProcessTaskType = ProcessTaskType.DataProvider; pt.SaveToDatabase(); pt.CreateArgumentsForClassIfNotExists <BasicCacheDataProvider>(); var attacher = lmd.ProcessTasks.Single(p => p.ProcessTaskType == ProcessTaskType.Attacher); var patternArgument = (ProcessTaskArgument)attacher.GetAllArguments().Single(a => a.Name.Equals("FilePattern")); patternArgument.SetValue("*.csv"); patternArgument.SaveToDatabase(); //take the forLoading file var csvFile = CreateFileInForLoading("bob.csv", 10, new Random(5000)); //and move it to the cache and give it a date in the range we expect for the cached data csvFile.MoveTo(Path.Combine(LoadDirectory.Cache.FullName, "2001-01-09.csv")); RunDLE(timeoutInMilliseconds); Assert.AreEqual(10, RowsNow - RowsBefore); Assert.AreEqual(0, LoadDirectory.Cache.GetFiles().Count()); Assert.AreEqual(0, LoadDirectory.ForLoading.GetFiles().Count()); Assert.AreEqual(1, LoadDirectory.ForArchiving.GetFiles().Count()); var archiveFile = LoadDirectory.ForArchiving.GetFiles()[0]; Assert.AreEqual(".zip", archiveFile.Extension); //load progress should be updated to the largest date in the cache (2001-01-09) lp.RevertToDatabaseState(); Assert.AreEqual(lp.DataLoadProgress, new DateTime(2001, 01, 09)); cp.DeleteInDatabase(); lp.DeleteInDatabase(); assembler.Destroy(); }
public void SaveCacheFillProgress(DateTime cacheFillProgress) { CacheProgress.CacheFillProgress = cacheFillProgress; CacheProgress.SaveToDatabase(); }
public void DeleteInDatabase() { CacheProgress.PermissionWindow_ID = null; CacheProgress.SaveToDatabase(); }
public void ConfigureCacheProgressToUseThePipeline(CacheProgress cp) { cp.Pipeline_ID = Pipeline.ID; cp.ChunkPeriod = new TimeSpan(12, 0, 0); cp.SaveToDatabase(); }