Beispiel #1
0
        public async Task WhenUnableToCheckpointWithStorageExceptionThenLogs()
        {
            // Arrange
            var context = MockPartitionContext.Create("0", () =>
            {
                throw new StorageException();
            });

            var processor =
                new ColdStorageProcessor(
                    n => _writerMock.Object,
                    Mock.Of <IColdStorageInstrumentationPublisher>(),
                    CancellationToken.None,
                    CircuitBreakerWarningLevel,
                    CircuitBreakerStallLevel,
                    CircuitBreakerStallInterval,
                    TimeSpan.FromSeconds(200),
                    "Test",
                    maxBlockSize: MaxBlockSize);

            _writerMock
            .Setup(w => w.WriteAsync(It.IsAny <IReadOnlyCollection <BlockData> >(), It.IsAny <CancellationToken>()))
            .Returns(() => TaskHelpers.CreateCompletedTask(true));

            await processor.OpenAsync(context);

            // Act
            await processor.ProcessEventsAsync(context, new[]
            {
                CreateEventData((byte)'a', 100),
                CreateEventData((byte)'b', 200),
                CreateEventData((byte)'c', 300),
                CreateEventData((byte)'d', 400),
            });
        }
Beispiel #2
0
        public async Task WhenIncomingMessagesFailToFillABlock_ThenDoesNotWrite()
        {
            var context = MockPartitionContext.CreateWithNoopCheckpoint("0");
            await _processor.OpenAsync(context);

            await _processor.ProcessEventsAsync(
                context,
                new[]
            {
                CreateEventData((byte)'a', 100),
                CreateEventData((byte)'b', 200),
                CreateEventData((byte)'c', 300),
            });

            _writerMock.Verify(
                w => w.WriteAsync(It.IsAny <IReadOnlyCollection <BlockData> >(), It.IsAny <CancellationToken>()),
                Times.Never());
        }
        public async Task WhenUnableToCheckpointWithStorageExceptionThenLogs()
        {
            // Arrange
            var context = MockPartitionContext.Create("0", () =>
                {
                    throw new StorageException();
                });
            
            var processor =
               new ColdStorageProcessor(
                   n => _writerMock.Object,
                   CircuitBreakerWarningLevel,
                   CircuitBreakerStallLevel,
                   CircuitBreakerStallInterval,
                   TimeSpan.FromSeconds(200),
                   "Test",
                   maxBlockSize: MaxBlockSize);

            _writerMock
                .Setup(w => w.WriteAsync(It.IsAny<IReadOnlyCollection<BlockData>>(), It.IsAny<CancellationToken>()))
                .Returns(() => TaskHelpers.CreateCompletedTask(true));
                
            await processor.OpenAsync(context);

            // Act
            await processor.ProcessEventsAsync(context, new[] 
                {
                    CreateEventData((byte)'a', 100),
                    CreateEventData((byte)'b', 200),
                    CreateEventData((byte)'c', 300),
                    CreateEventData((byte)'d', 400),
                });
        }