mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-22 09:35:38 -05:00
Profiler notifications (#640)
* Initial changes for adding lost event notifications * Handling polling errors by notifying listeners * Restructuring lost events & testing * Minor fixes to tests * Add back in filtering * Changing how lost events are found * Cleaning up tests
This commit is contained in:
committed by
GitHub
parent
f244d307e2
commit
838a7e4fab
@@ -34,6 +34,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
|
||||
// add a new event
|
||||
var newEvent = new ProfilerEvent("new event", "1/1/2017");
|
||||
newEvent.Values.Add("event_sequence", "4");
|
||||
allEvents.Add(newEvent);
|
||||
|
||||
// poll all events
|
||||
@@ -52,7 +53,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
Assert.Equal(profilerEvents.Count, 0);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Test the FilterProfilerEvents method
|
||||
/// </summary>
|
||||
@@ -68,6 +68,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
// add a new "Profiler Polling" event
|
||||
var newEvent = new ProfilerEvent("sql_batch_completed", "1/1/2017");
|
||||
newEvent.Values.Add("batch_text", "SELECT target_data FROM sys.dm_xe_session_targets");
|
||||
newEvent.Values.Add("event_sequence", "4");
|
||||
profilerEvents.Add(newEvent);
|
||||
|
||||
// verify that the polling event is removed
|
||||
@@ -76,6 +77,53 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
Assert.Equal(newProfilerEvents.Count, expectedEventCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test notifications for lost events
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestEventsLost()
|
||||
{
|
||||
// create a profiler session and get some test events
|
||||
var profilerSession = new ProfilerSession();
|
||||
var profilerEvents = ProfilerTestObjects.TestProfilerEvents;
|
||||
|
||||
// filter all the results from the first poll
|
||||
// these events happened before the profiler began
|
||||
profilerSession.FilterOldEvents(profilerEvents);
|
||||
Assert.Equal(profilerEvents.Count, 0);
|
||||
// No events should be lost
|
||||
Assert.False(profilerSession.EventsLost);
|
||||
|
||||
// test all events are overwritten, but no events are lost
|
||||
profilerEvents.Clear();
|
||||
ProfilerEvent newEvent = new ProfilerEvent("event4", "6/18/2018");
|
||||
newEvent.Values.Add("event_sequence", "4");
|
||||
|
||||
profilerEvents.Add(newEvent);
|
||||
profilerSession.FilterOldEvents(profilerEvents);
|
||||
|
||||
// should not show event loss
|
||||
Assert.False(profilerSession.EventsLost);
|
||||
|
||||
// test all events are overwritten, and events are lost
|
||||
profilerEvents.Clear();
|
||||
newEvent = new ProfilerEvent("event7", "6/18/2018");
|
||||
newEvent.Values.Add("event_sequence", "7");
|
||||
|
||||
profilerEvents.Add(newEvent);
|
||||
profilerSession.FilterOldEvents(profilerEvents);
|
||||
|
||||
// should show event loss
|
||||
Assert.True(profilerSession.EventsLost);
|
||||
|
||||
//poll again with previously seen events
|
||||
profilerEvents.Add(newEvent);
|
||||
|
||||
// old events were seen, no event loss occured
|
||||
profilerSession.FilterOldEvents(profilerEvents);
|
||||
Assert.False(profilerSession.EventsLost);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the TryEnterPolling method
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user