public void Builder_should_allow_specify_quota() { var quotaPerMessageType = 10; using (var processor = SlaProcessorBuilder.For(new SlaProvider()).WithQuotaPerMessageType(quotaPerMessageType).Build()) Assert.That(processor.QuotaPerMessageType, Is.EqualTo(quotaPerMessageType)); }
public void Builder_should_allow_specify_timeout_validation_scheduler() { var mockScheduler = new Mock <IDisposable>(); SlaProcessorBuilder.For(new SlaProvider()) .WithTimeoutValidationSchedulerFactory(p => mockScheduler.Object) .Build() .Dispose(); mockScheduler.Verify(s => s.Dispose()); }
public void Response_within_sla_should_result_with_DEBUG_log_entry() { var id = Guid.Parse("cca0662a-b6fb-4b26-b6dd-97ba1e7d32c2"); using (var processor = SlaProcessorBuilder.For(_provider).Build()) { processor.ProcessOutgoingMessage(new Request { Id = id }); processor.ProcessIncomingMessage(new Response { Id = id }); AssertLogEntry(Level.Debug, "SLA=Wonga.SLAMonitor.Tests.Asynchronous.SlaProcessorIntegrationTests\\+Request Response=Wonga.SLAMonitor.Tests.Asynchronous.SlaProcessorIntegrationTests\\+Response ResponseTime=[0-9]+ milliseconds CorrelationId=cca0662a-b6fb-4b26-b6dd-97ba1e7d32c2"); } }
public void Request_should_timeout_when_timeout_processing_is_scheduled_and_request_took_more_than_twice_time_of_sla() { using (var processor = SlaProcessorBuilder.For(_provider) .WithTimeoutValidationScheduler(TimeSpan.FromMilliseconds(200)) .Build()) { var correltationId = Guid.Parse("cca0662a-b6fb-4b26-b6dd-97ba1e7d32ff"); processor.ProcessOutgoingMessage(new Request { Id = correltationId }); Thread.Sleep(250); AssertLogEntry(Level.Error, "SLA=Wonga.SLAMonitor.Tests.Asynchronous.SlaProcessorIntegrationTests\\+Request Response=monitor-timed-out ResponseTime=[0-9]+ milliseconds CorrelationId=cca0662a-b6fb-4b26-b6dd-97ba1e7d32ff"); } }
public void Response_should_default_to_DEBUG_with_unsupported_log_level(Level level) { var id = Guid.Parse("cca0662a-b6fb-4b26-b6dd-97ba1e7d32c2"); using (var processor = SlaProcessorBuilder.For(_provider).WithLoggingConfiguration(new LoggingConfiguration(Level.Off, level)).Build()) { processor.ProcessOutgoingMessage(new Request { Id = id }); processor.ProcessIncomingMessage(new Response { Id = id }); AssertLogEntry(Level.Debug, "SLA=Wonga.SLAMonitor.Tests.Asynchronous.SlaProcessorIntegrationTests\\+Request Response=Wonga.SLAMonitor.Tests.Asynchronous.SlaProcessorIntegrationTests\\+Response ResponseTime=[0-9]+ milliseconds CorrelationId=cca0662a-b6fb-4b26-b6dd-97ba1e7d32c2"); } }
public void Response_violating_sla_should_have_configurable_log_level(Level level) { var id = Guid.Parse("cca0662a-b6fb-4b26-b6dd-97ba1e7d32c2"); using (var processor = SlaProcessorBuilder.For(_provider).WithLoggingConfiguration(new LoggingConfiguration(level, Level.Off)).Build()) { processor.ProcessOutgoingMessage(new Request { Id = id }); Thread.Sleep(_violatedSla); processor.ProcessIncomingMessage(new Response { Id = id }); AssertLogEntry(level, "SLA=Wonga.SLAMonitor.Tests.Asynchronous.SlaProcessorIntegrationTests\\+Request Response=Wonga.SLAMonitor.Tests.Asynchronous.SlaProcessorIntegrationTests\\+Response ResponseTime=[0-9]+ milliseconds CorrelationId=cca0662a-b6fb-4b26-b6dd-97ba1e7d32c2"); } }
public void Request_exceeding_the_request_message_quota_should_result_with_WARN_log_entry() { var quotaPerMessageType = 1; using (var processor = SlaProcessorBuilder.For(_provider).WithQuotaPerMessageType(quotaPerMessageType).Build()) { var correltationId = Guid.Parse("cca0662a-b6fb-4b26-b6dd-97ba1e7d32ff"); processor.ProcessOutgoingMessage(new Request { Id = Guid.NewGuid() }); processor.ProcessOutgoingMessage(new Request { Id = correltationId }); AssertLogEntry(Level.Warn, "SLA=Wonga.SLAMonitor.Tests.Asynchronous.SlaProcessorIntegrationTests\\+Request monitoring message quota reached. Message with CorrelationId=cca0662a-b6fb-4b26-b6dd-97ba1e7d32ff is not going to be monitored."); } }
public void Builder_should_construct_processor_with_defaults() { using (var processor = SlaProcessorBuilder.For(new SlaProvider()).Build()) Assert.That(processor.QuotaPerMessageType, Is.EqualTo(SlaProcessorBuilder.DefaultQuotaPerMessageType)); }