public void VerifyDeduplicationMultithreaded() { var client = CreateClient(); var errorPlugin = new ErrorPlugin(); List<EventPluginContext> contexts = new List<EventPluginContext>(); using (var duplicateCheckerPlugin = new DuplicateCheckerPlugin(TimeSpan.FromMilliseconds(100))) { var result = Parallel.For(0, 10, index => { var builder = GetException().ToExceptionless(); var context = new EventPluginContext(client, builder.Target, builder.PluginContextData); contexts.Add(context); errorPlugin.Run(context); duplicateCheckerPlugin.Run(context); }); while (!result.IsCompleted) Thread.Sleep(1); } Thread.Sleep(150); Assert.Equal(1, contexts.Count(c => !c.Cancel)); Assert.Equal(9, contexts.Count(c => c.Cancel)); Assert.Equal(9, contexts.Sum(c => c.Event.Count.GetValueOrDefault())); }
public void VerifyDeduplicationFromFiles() { var client = CreateClient(); var errorPlugin = new ErrorPlugin(); foreach (var ev in ErrorDataReader.GetEvents()) { using (var duplicateCheckerPlugin = new DuplicateCheckerPlugin(TimeSpan.FromMilliseconds(20))) { for (int index = 0; index < 2; index++) { var contextData = new ContextData(); var context = new EventPluginContext(client, ev, contextData); errorPlugin.Run(context); duplicateCheckerPlugin.Run(context); if (index == 0) { Assert.False(context.Cancel); Assert.Null(context.Event.Count); } else { Assert.True(context.Cancel); Thread.Sleep(50); Assert.Equal(1, context.Event.Count); } } } } }
public void VerifyDeduplication() { var client = CreateClient(); var errorPlugin = new ErrorPlugin(); EventPluginContext mergedContext = null; using (var duplicateCheckerPlugin = new DuplicateCheckerPlugin(TimeSpan.FromMilliseconds(40))) { for (int index = 0; index < 10; index++) { var builder = GetException().ToExceptionless(); var context = new EventPluginContext(client, builder.Target, builder.PluginContextData); errorPlugin.Run(context); duplicateCheckerPlugin.Run(context); if (index == 0) { Assert.False(context.Cancel); Assert.Null(context.Event.Count); } else { Assert.True(context.Cancel); if (index == 1) mergedContext = context; } } } Thread.Sleep(100); Assert.Equal(9, mergedContext.Event.Count.GetValueOrDefault()); }