public void LogExceptionReceivedEvent_AggregateExceptions_LoggedAsInfo() { var ctor = typeof(AggregateException).GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(IEnumerable <Exception>) }, null); var request = new RequestResult() { HttpStatusCode = 409 }; var information = new StorageExtendedErrorInformation(); typeof(StorageExtendedErrorInformation).GetProperty("ErrorCode").SetValue(information, "LeaseIdMismatchWithLeaseOperation"); typeof(RequestResult).GetProperty("ExtendedErrorInformation").SetValue(request, information); var storageException = new StorageException(request, "The lease ID specified did not match the lease ID for the blob.", null); var ex = (AggregateException)ctor.Invoke(new object[] { new Exception[] { storageException } }); ctor = typeof(ExceptionReceivedEventArgs).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single(); var e = (ExceptionReceivedEventArgs)ctor.Invoke(new object[] { "TestHostName", "TestPartitionId", ex, "TestAction" }); EventHubExtensionConfigProvider.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action='TestAction', HostName='TestHostName', PartitionId='TestPartitionId')."; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.Equal(LogLevel.Information, logMessage.Level); Assert.Same(storageException, logMessage.Exception); Assert.Equal(expectedMessage + string.Format(_template, typeof(WindowsAzure.Storage.StorageException).Name), logMessage.FormattedMessage); }
public void LogExceptionReceivedEvent_PartitionExceptions_LoggedAsInfo() { var ex = new EventHubsException(false, "New receiver with higher epoch of '30402' is created hence current receiver with epoch '30402' is getting disconnected.", EventHubsException.FailureReason.ConsumerDisconnected); var e = new ExceptionReceivedEventArgs("TestHostName", "TestAction", "TestPartitionId", ex); EventHubExtensionConfigProvider.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action='TestAction', HostName='TestHostName', PartitionId='TestPartitionId')."; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.AreEqual(LogLevel.Information, logMessage.Level); Assert.AreSame(ex, logMessage.Exception); Assert.AreEqual(expectedMessage + string.Format(_template, typeof(EventHubsException).Name), logMessage.FormattedMessage); }
public void LogExceptionReceivedEvent_NonMessagingException_LoggedAsError() { var ex = new MissingMethodException("What method??"); var e = new ExceptionReceivedEventArgs("TestHostName", "TestAction", "TestPartitionId", ex); EventHubExtensionConfigProvider.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action='TestAction', HostName='TestHostName', PartitionId='TestPartitionId')."; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.AreEqual(LogLevel.Error, logMessage.Level); Assert.AreSame(ex, logMessage.Exception); Assert.AreEqual(expectedMessage, logMessage.FormattedMessage); }
public void LogExceptionReceivedEvent_OperationCanceledException_LoggedAsVerbose() { var ex = new OperationCanceledException("Testing"); var e = new ExceptionReceivedEventArgs("TestHostName", "TestAction", "TestPartitionId", ex); EventHubExtensionConfigProvider.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action='TestAction', HostName='TestHostName', PartitionId='TestPartitionId')."; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.AreEqual(LogLevel.Information, logMessage.Level); Assert.AreSame(ex, logMessage.Exception); Assert.AreEqual(expectedMessage + string.Format(_template, typeof(OperationCanceledException).Name), logMessage.FormattedMessage); }
public void LogExceptionReceivedEvent_NonMessagingException_LoggedAsError() { var ex = new MissingMethodException("What method??"); var ctor = typeof(ExceptionReceivedEventArgs).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single(); var e = (ExceptionReceivedEventArgs)ctor.Invoke(new object[] { "TestHostName", "TestPartitionId", ex, "TestAction" }); EventHubExtensionConfigProvider.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action=TestAction, HostName=TestHostName, PartitionId=TestPartitionId)"; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.Equal(LogLevel.Error, logMessage.Level); Assert.Same(ex, logMessage.Exception); Assert.Equal(expectedMessage, logMessage.FormattedMessage); }
public void LogExceptionReceivedEvent_OperationCanceledException_LoggedAsVerbose() { var ex = new OperationCanceledException("Testing"); var ctor = typeof(ExceptionReceivedEventArgs).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single(); var e = (ExceptionReceivedEventArgs)ctor.Invoke(new object[] { "TestHostName", "TestPartitionId", ex, "TestAction" }); EventHubExtensionConfigProvider.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action='TestAction', HostName='TestHostName', PartitionId='TestPartitionId')."; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.Equal(LogLevel.Information, logMessage.Level); Assert.Same(ex, logMessage.Exception); Assert.Equal(expectedMessage + string.Format(_template, typeof(OperationCanceledException).Name), logMessage.FormattedMessage); }
public void LogExceptionReceivedEvent_PartitionExceptions_LoggedAsInfo() { var ctor = typeof(ReceiverDisconnectedException).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(string) }, null); var ex = (ReceiverDisconnectedException)ctor.Invoke(new object[] { "New receiver with higher epoch of '30402' is created hence current receiver with epoch '30402' is getting disconnected." }); ctor = typeof(ExceptionReceivedEventArgs).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single(); var e = (ExceptionReceivedEventArgs)ctor.Invoke(new object[] { "TestHostName", "TestPartitionId", ex, "TestAction" }); EventHubExtensionConfigProvider.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action=TestAction, HostName=TestHostName, PartitionId=TestPartitionId)"; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.Equal(LogLevel.Information, logMessage.Level); Assert.Same(ex, logMessage.Exception); Assert.Equal(expectedMessage, logMessage.FormattedMessage); }
public void LogExceptionReceivedEvent_NonTransientEvent_LoggedAsError() { var ex = new EventHubsException(false); Assert.False(ex.IsTransient); var ctor = typeof(ExceptionReceivedEventArgs).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single(); var e = (ExceptionReceivedEventArgs)ctor.Invoke(new object[] { "TestHostName", "TestPartitionId", ex, "TestAction" }); EventHubExtensionConfigProvider.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action='TestAction', HostName='TestHostName', PartitionId='TestPartitionId')."; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.Equal(LogLevel.Error, logMessage.Level); Assert.Same(ex, logMessage.Exception); Assert.Equal(expectedMessage, logMessage.FormattedMessage); }