Exemple #1
0
        public void CanSubmitSimpleEvent()
        {
            var container = AppBuilder.CreateContainer();

            using (WebApp.Start(Settings.Current.BaseURL, app => AppBuilder.BuildWithContainer(app, container))) {
                var queue        = container.GetInstance <IQueue <EventPost> >() as InMemoryQueue <EventPost>;
                var statsCounter = container.GetInstance <IAppStatsClient>() as InMemoryAppStatsClient;
                EnsureSampleData(container);

                Assert.NotNull(queue);
                Assert.Equal(0, queue.Count);

                var client = new ExceptionlessClient();
                client.SubmitEvent(new Event {
                    Message = "Test"
                });
                client.ProcessQueue();

                var processEventsJob = container.GetInstance <ProcessEventPostsJob>();
                Task.Factory.StartNew(() => processEventsJob.Run());
                Task.Delay(TimeSpan.FromSeconds(2)).Wait();
                processEventsJob.Cancel();
                Assert.Equal(0, queue.Count);
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsSubmitted));
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsQueued));
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsParsed));
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsDequeued));
                Assert.Equal(1, statsCounter.GetCount(StatNames.EventsProcessed));
            }
        }
        public async Task CanSubmitSimpleEvent()
        {
            var container = AppBuilder.CreateContainer();

            using (WebApp.Start(Settings.Current.BaseURL, app => AppBuilder.BuildWithContainer(app, container, false))) {
                var queue = container.GetInstance <IQueue <EventPost> >();
                Assert.NotNull(queue);
                Assert.Equal(0, queue.GetQueueCount());

                var statsCounter = container.GetInstance <IAppStatsClient>() as InMemoryAppStatsClient;
                Assert.NotNull(statsCounter);

                EnsureSampleData(container);

                var client = CreateClient();
                client.SubmitEvent(new Event {
                    Message = "Test"
                });

                var storage = client.Configuration.Resolver.GetFileStorage() as InMemoryFileStorage;
                Assert.NotNull(storage);
                Assert.Equal(1, storage.GetFileList().Count());

                Assert.True(statsCounter.WaitForCounter(StatNames.EventsProcessed, work: client.ProcessQueue));

                Assert.Equal(0, queue.GetQueueCount());
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsSubmitted));
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsQueued));
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsParsed));
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsDequeued));
                Assert.Equal(1, statsCounter.GetCount(StatNames.EventsProcessed));
            }
        }
        public void PostUserDescription()
        {
            var container = AppBuilder.CreateContainer();

            using (WebApp.Start(Settings.Current.BaseURL, app => AppBuilder.BuildWithContainer(app, container, false))) {
                var repository = container.GetInstance <IEventRepository>();
                repository.RemoveAll();

                const string referenceId    = "fda94ff32921425ebb08b73df1d1d34c";
                const string badReferenceId = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";

                var statsCounter = container.GetInstance <IAppStatsClient>() as InMemoryAppStatsClient;
                Assert.NotNull(statsCounter);

                EnsureSampleData(container);

                var events = new List <Event> {
                    new Event {
                        Message = "Testing", ReferenceId = referenceId
                    }
                };
                var configuration = GetClient().Configuration;
                var serializer    = new DefaultJsonSerializer();

                var client      = new DefaultSubmissionClient();
                var description = new UserDescription {
                    EmailAddress = "*****@*****.**", Description = "Some description."
                };
                statsCounter.WaitForCounter(StatNames.EventsUserDescriptionErrors, work: () => {
                    var response = client.PostUserDescription(referenceId, description, configuration, serializer);
                    Assert.True(response.Success, response.Message);
                    Assert.Null(response.Message);
                });

                statsCounter.WaitForCounter(StatNames.EventsUserDescriptionProcessed, work: () => {
                    var response = client.PostEvents(events, configuration, serializer);
                    Assert.True(response.Success, response.Message);
                    Assert.Null(response.Message);
                });

                container.GetInstance <IElasticClient>().Refresh();
                var ev = repository.GetByReferenceId("537650f3b77efe23a47914f4", referenceId).FirstOrDefault();
                Assert.NotNull(ev);
                Assert.NotNull(ev.GetUserDescription());
                Assert.Equal(description.ToJson(), ev.GetUserDescription().ToJson());

                Assert.Equal(2, statsCounter.GetCount(StatNames.EventsUserDescriptionErrors));
                statsCounter.WaitForCounter(StatNames.EventsUserDescriptionErrors, work: () => {
                    var response = client.PostUserDescription(badReferenceId, description, configuration, serializer);
                    Assert.True(response.Success, response.Message);
                    Assert.Null(response.Message);
                });

                Assert.Equal(2, statsCounter.GetCount(StatNames.EventsUserDescriptionErrors));
            }
        }
Exemple #4
0
        public void GetSettings()
        {
            var container = AppBuilder.CreateContainer();

            using (WebApp.Start(Settings.Current.BaseURL, app => AppBuilder.BuildWithContainer(app, container))) {
                EnsureSampleData(container);

                var configuration = GetClient().Configuration;
                var serializer    = new DefaultJsonSerializer();

                var client   = new DefaultSubmissionClient();
                var response = client.GetSettings(configuration, serializer);
                Assert.True(response.Success, response.Message);
                Assert.NotEqual(-1, response.SettingsVersion);
                Assert.NotNull(response.Settings);
                Assert.Null(response.Message);
            }
        }
Exemple #5
0
        public void PostEvents()
        {
            var container = AppBuilder.CreateContainer();

            using (WebApp.Start(Settings.Current.BaseURL, app => AppBuilder.BuildWithContainer(app, container))) {
                EnsureSampleData(container);

                var events = new List <Event> {
                    new Event {
                        Message = "Testing"
                    }
                };
                var configuration = GetClient().Configuration;
                var serializer    = new DefaultJsonSerializer();

                var client   = new DefaultSubmissionClient();
                var response = client.PostEvents(events, configuration, serializer);
                Assert.True(response.Success, response.Message);
                Assert.Null(response.Message);
            }
        }
        public async Task CanSubmitSimpleException()
        {
            var container = AppBuilder.CreateContainer();

            using (WebApp.Start(Settings.Current.BaseURL, app => AppBuilder.BuildWithContainer(app, container, false))) {
                var queue = container.GetInstance <IQueue <EventPost> >();
                Assert.NotNull(queue);
                Assert.Equal(0, queue.GetQueueCount());

                var statsCounter = container.GetInstance <IAppStatsClient>() as InMemoryAppStatsClient;
                Assert.NotNull(statsCounter);

                EnsureSampleData(container);

                var client      = CreateClient();
                var clientQueue = client.Configuration.Resolver.GetEventQueue();
                // make sure the queue isn't processed until we are ready for it
                clientQueue.SuspendProcessing(TimeSpan.FromSeconds(10));
                try {
                    throw new Exception("Simple Exception");
                } catch (Exception ex) {
                    client.SubmitException(ex);
                }

                var storage = client.Configuration.Resolver.GetFileStorage() as InMemoryFileStorage;
                Assert.NotNull(storage);
                Assert.Equal(1, storage.GetFileList().Count());

                Assert.True(statsCounter.WaitForCounter(StatNames.EventsProcessed, work: client.ProcessQueue));

                Assert.Equal(0, queue.GetQueueCount());
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsSubmitted));
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsQueued));
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsParsed));
                Assert.Equal(1, statsCounter.GetCount(StatNames.PostsDequeued));
                Assert.Equal(1, statsCounter.GetCount(StatNames.EventsProcessed));
            }
        }
Exemple #7
0
        public async Task PostUserDescription()
        {
            var container = AppBuilder.CreateContainer();

            using (WebApp.Start(Settings.Current.BaseURL, app => AppBuilder.BuildWithContainer(app, container))) {
                var repository = container.GetInstance <IEventRepository>();
                repository.RemoveAll();

                const string referenceId    = "fda94ff32921425ebb08b73df1d1d34c";
                const string badReferenceId = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";

                var statsCounter = container.GetInstance <IMetricsClient>() as InMemoryMetricsClient;
                var descQueue    = container.GetInstance <IQueue <EventUserDescription> >() as InMemoryQueue <EventUserDescription>;

                Assert.NotNull(statsCounter);

                EnsureSampleData(container);

                var ev = new Event {
                    Message = "Testing", ReferenceId = referenceId
                };
                ev.Data.Add("First Name", "Eric");
                ev.Data.Add("IsVerified", true);
                ev.Data.Add("Age", Int32.MaxValue);
                ev.Data.Add(" Birthday ", DateTime.MinValue);
                ev.Data.Add("@excluded", DateTime.MinValue);
                ev.Data.Add("Address", new { State = "Texas" });

                var events = new List <Event> {
                    ev
                };
                var configuration = GetClient().Configuration;
                var serializer    = new DefaultJsonSerializer();

                var client      = new DefaultSubmissionClient();
                var description = new UserDescription {
                    EmailAddress = "*****@*****.**", Description = "Some description."
                };
                Debug.WriteLine("Before Submit Description");
                statsCounter.DisplayStats();
                Assert.True(statsCounter.WaitForCounter(MetricNames.EventsUserDescriptionErrors, work: () => {
                    var response = client.PostUserDescription(referenceId, description, configuration, serializer);
                    Debug.WriteLine("After Submit Description");
                    Assert.True(response.Success, response.Message);
                    Assert.Null(response.Message);
                }));
                statsCounter.DisplayStats();
                Debug.WriteLine(descQueue.GetQueueCount());

                Debug.WriteLine("Before Post Event");
                Assert.True(statsCounter.WaitForCounter(MetricNames.EventsProcessed, work: () => {
                    var response = client.PostEvents(events, configuration, serializer);
                    Debug.WriteLine("After Post Event");
                    Assert.True(response.Success, response.Message);
                    Assert.Null(response.Message);
                }));
                statsCounter.DisplayStats();
                if (statsCounter.GetCount(MetricNames.EventsUserDescriptionProcessed) == 0)
                {
                    Assert.True(statsCounter.WaitForCounter(MetricNames.EventsUserDescriptionProcessed));
                }

                container.GetInstance <IElasticClient>().Refresh();
                ev = repository.GetByReferenceId("537650f3b77efe23a47914f4", referenceId).FirstOrDefault();
                Assert.NotNull(ev);
                Assert.NotNull(ev.GetUserDescription());
                Assert.Equal(description.ToJson(), ev.GetUserDescription().ToJson());

                Assert.InRange(statsCounter.GetCount(MetricNames.EventsUserDescriptionErrors), 1, 5);
                Assert.True(statsCounter.WaitForCounter(MetricNames.EventsUserDescriptionErrors, work: () => {
                    var response = client.PostUserDescription(badReferenceId, description, configuration, serializer);
                    Assert.True(response.Success, response.Message);
                    Assert.Null(response.Message);
                }));
                statsCounter.DisplayStats();

                Assert.InRange(statsCounter.GetCount(MetricNames.EventsUserDescriptionErrors), 2, 10);
            }
        }