Example #1
0
        public async Task InitializeAsync()
        {
            await _sqlDataStoreTestsFixture.InitializeAsync();

            await _blobStorageTestsFixture.InitializeAsync();

            var cleanupConfiguration = new DeletedInstanceCleanupConfiguration
            {
                BatchSize       = 10,
                DeleteDelay     = TimeSpan.FromSeconds(1),
                MaxRetries      = 3,
                PollingInterval = TimeSpan.FromSeconds(1),
                RetryBackOff    = TimeSpan.FromSeconds(2),
            };

            var optionsConfiguration = Substitute.For <IOptions <DeletedInstanceCleanupConfiguration> >();

            optionsConfiguration.Value.Returns(cleanupConfiguration);
            DeleteService = new DeleteService(
                _sqlDataStoreTestsFixture.SqlIndexDataStoreFactory,
                _blobStorageTestsFixture.MetadataStore,
                _blobStorageTestsFixture.FileStore,
                optionsConfiguration,
                _sqlDataStoreTestsFixture.SqlTransactionHandler,
                NullLogger <DeleteService> .Instance);
        }
Example #2
0
        public DeleteServiceTests()
        {
            _indexDataStore      = Substitute.For <IIndexDataStore>();
            _metadataStore       = Substitute.For <IMetadataStore>();
            _fileDataStore       = Substitute.For <IFileStore>();
            _deleteConfiguration = new DeletedInstanceCleanupConfiguration
            {
                DeleteDelay     = TimeSpan.FromDays(1),
                BatchSize       = 10,
                MaxRetries      = 5,
                PollingInterval = TimeSpan.FromSeconds(1),
                RetryBackOff    = TimeSpan.FromDays(4),
            };

            IOptions <DeletedInstanceCleanupConfiguration> deletedInstanceCleanupConfigurationOptions = Substitute.For <IOptions <DeletedInstanceCleanupConfiguration> >();

            deletedInstanceCleanupConfigurationOptions.Value.Returns(_deleteConfiguration);
            ITransactionHandler transactionHandler = Substitute.For <ITransactionHandler>();

            _transactionScope = Substitute.For <ITransactionScope>();
            transactionHandler.BeginTransaction().Returns(_transactionScope);
            _dicomRequestContextAccessor = Substitute.For <IDicomRequestContextAccessor>();
            _dicomRequestContextAccessor.RequestContext.DataPartitionEntry = new PartitionEntry(DefaultPartition.Key, DefaultPartition.Name);

            _deleteService = new DeleteService(_indexDataStore, _metadataStore, _fileDataStore, deletedInstanceCleanupConfigurationOptions, transactionHandler, NullLogger <DeleteService> .Instance, _dicomRequestContextAccessor);
        }
Example #3
0
        public DeleteServiceTests()
        {
            _indexDataStore        = Substitute.For <IIndexDataStore>();
            _metadataStore         = Substitute.For <IMetadataStore>();
            _fileDataStore         = Substitute.For <IFileStore>();
            _indexDataStoreFactory = Substitute.For <IIndexDataStoreFactory>();
            _deleteConfiguration   = new DeletedInstanceCleanupConfiguration
            {
                DeleteDelay     = TimeSpan.FromDays(1),
                BatchSize       = 10,
                MaxRetries      = 5,
                PollingInterval = TimeSpan.FromSeconds(1),
                RetryBackOff    = TimeSpan.FromDays(4),
            };

            IOptions <DeletedInstanceCleanupConfiguration> deletedInstanceCleanupConfigurationOptions = Substitute.For <IOptions <DeletedInstanceCleanupConfiguration> >();

            deletedInstanceCleanupConfigurationOptions.Value.Returns(_deleteConfiguration);
            ITransactionHandler transactionHandler = Substitute.For <ITransactionHandler>();

            _transactionScope = Substitute.For <ITransactionScope>();
            transactionHandler.BeginTransaction().Returns(_transactionScope);

            _indexDataStoreFactory.GetInstance().Returns(_indexDataStore);
            _deleteService = new DeleteService(_indexDataStoreFactory, _metadataStore, _fileDataStore, deletedInstanceCleanupConfigurationOptions, transactionHandler, NullLogger <DeleteService> .Instance);
        }
        public async Task InitializeAsync()
        {
            await _sqlDataStoreTestsFixture.InitializeAsync();

            await _blobStorageTestsFixture.InitializeAsync();

            var cleanupConfiguration = new DeletedInstanceCleanupConfiguration
            {
                BatchSize       = 10,
                DeleteDelay     = TimeSpan.FromSeconds(1),
                MaxRetries      = 3,
                PollingInterval = TimeSpan.FromSeconds(1),
                RetryBackOff    = TimeSpan.FromSeconds(2),
            };

            var optionsConfiguration = Substitute.For <IOptions <DeletedInstanceCleanupConfiguration> >();

            optionsConfiguration.Value.Returns(cleanupConfiguration);
            var dicomRequestContextAccessor = Substitute.For <IDicomRequestContextAccessor>();

            dicomRequestContextAccessor.RequestContext.DataPartitionEntry = new PartitionEntry(DefaultPartition.Key, DefaultPartition.Name);

            DeleteService = new DeleteService(
                _sqlDataStoreTestsFixture.IndexDataStore,
                _blobStorageTestsFixture.MetadataStore,
                _blobStorageTestsFixture.FileStore,
                optionsConfiguration,
                _sqlDataStoreTestsFixture.SqlTransactionHandler,
                NullLogger <DeleteService> .Instance,
                dicomRequestContextAccessor);
        }
Example #5
0
        public DeleteService(
            IIndexDataStore indexDataStore,
            IMetadataStore metadataStore,
            IFileStore fileStore,
            IOptions <DeletedInstanceCleanupConfiguration> deletedInstanceCleanupConfiguration,
            ITransactionHandler transactionHandler,
            ILogger <DeleteService> logger,
            IDicomRequestContextAccessor contextAccessor)
        {
            EnsureArg.IsNotNull(indexDataStore, nameof(indexDataStore));
            EnsureArg.IsNotNull(metadataStore, nameof(metadataStore));
            EnsureArg.IsNotNull(fileStore, nameof(fileStore));
            EnsureArg.IsNotNull(deletedInstanceCleanupConfiguration?.Value, nameof(deletedInstanceCleanupConfiguration));
            EnsureArg.IsNotNull(transactionHandler, nameof(transactionHandler));
            EnsureArg.IsNotNull(logger, nameof(logger));
            EnsureArg.IsNotNull(contextAccessor, nameof(contextAccessor));

            _indexDataStore = indexDataStore;
            _metadataStore  = metadataStore;
            _fileStore      = fileStore;
            _deletedInstanceCleanupConfiguration = deletedInstanceCleanupConfiguration.Value;
            _transactionHandler = transactionHandler;
            _logger             = logger;
            _contextAccessor    = contextAccessor;
        }
Example #6
0
        public BackgroundServiceHealthCheck(
            IIndexDataStoreFactory indexDataStoreFactory,
            IOptions <DeletedInstanceCleanupConfiguration> deletedInstanceCleanupConfiguration,
            TelemetryClient telemetryClient,
            BackgroundServiceHealthCheckCache backgroundServiceHealthCheckCache)
        {
            EnsureArg.IsNotNull(indexDataStoreFactory, nameof(indexDataStoreFactory));
            EnsureArg.IsNotNull(deletedInstanceCleanupConfiguration?.Value, nameof(deletedInstanceCleanupConfiguration));
            EnsureArg.IsNotNull(telemetryClient, nameof(telemetryClient));
            EnsureArg.IsNotNull(backgroundServiceHealthCheckCache, nameof(backgroundServiceHealthCheckCache));

            _indexDataStore = indexDataStoreFactory.GetInstance();
            _deletedInstanceCleanupConfiguration = deletedInstanceCleanupConfiguration.Value;
            _telemetryClient = telemetryClient;
            _backgroundServiceHealthCheckCache = backgroundServiceHealthCheckCache;
        }
        public BackgroundServiceHealthCheck(
            IIndexDataStore indexDataStore,
            IOptions <DeletedInstanceCleanupConfiguration> deletedInstanceCleanupConfiguration,
            TelemetryClient telemetryClient,
            BackgroundServiceHealthCheckCache backgroundServiceHealthCheckCache,
            ILogger <BackgroundServiceHealthCheck> logger)
        {
            EnsureArg.IsNotNull(indexDataStore, nameof(indexDataStore));
            EnsureArg.IsNotNull(deletedInstanceCleanupConfiguration?.Value, nameof(deletedInstanceCleanupConfiguration));
            EnsureArg.IsNotNull(telemetryClient, nameof(telemetryClient));
            EnsureArg.IsNotNull(backgroundServiceHealthCheckCache, nameof(backgroundServiceHealthCheckCache));
            EnsureArg.IsNotNull(logger, nameof(logger));

            _indexDataStore = indexDataStore;
            _deletedInstanceCleanupConfiguration = deletedInstanceCleanupConfiguration.Value;
            _telemetryClient = telemetryClient;
            _backgroundServiceHealthCheckCache = backgroundServiceHealthCheckCache;
            _logger = logger;
        }
Example #8
0
        public DeleteService(
            IIndexDataStoreFactory indexDataStoreFactory,
            IMetadataStore metadataStore,
            IFileStore fileStore,
            IOptions <DeletedInstanceCleanupConfiguration> deletedInstanceCleanupConfiguration,
            ITransactionHandler transactionHandler,
            ILogger <DeleteService> logger)
        {
            EnsureArg.IsNotNull(indexDataStoreFactory, nameof(indexDataStoreFactory));
            EnsureArg.IsNotNull(metadataStore, nameof(metadataStore));
            EnsureArg.IsNotNull(fileStore, nameof(fileStore));
            EnsureArg.IsNotNull(deletedInstanceCleanupConfiguration?.Value, nameof(deletedInstanceCleanupConfiguration));
            EnsureArg.IsNotNull(transactionHandler, nameof(transactionHandler));
            EnsureArg.IsNotNull(logger, nameof(logger));

            _indexDataStore = indexDataStoreFactory.GetInstance();
            _metadataStore  = metadataStore;
            _fileStore      = fileStore;
            _deletedInstanceCleanupConfiguration = deletedInstanceCleanupConfiguration.Value;
            _transactionHandler = transactionHandler;
            _logger             = logger;
        }