mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-29 01:25:41 -05:00
Update to XElite (#1287)
* added Xevent.xelite to packages * WIP on XELite conversion * added wip changes * added streaminfo class for preserving streams * added list for profilerService * added cancelXelStreamRequest.cs * added test configuration for profilerservice * added request handler using startprofilingrequest * fix start profiling result * added small connection string * WIP branch for XElite (not functional) * added hardcoded string with working stream * added check for buildconnectionstring * added back HandleXEvent * added profilerservice eventsavailable test * WIP change for profilersessionmonitor * added more changes to profilersessionmonitor * changed HandleXEvent * added more additions to profielrSessionMonitor * added startmonitoringstream * added startmonitoringsession * added startmonitoringstream to IProfilerSessionMonitor * switch to monitoringStream * added assignment of connectioninfo * added conninfo * added conninfo to iProfilerSessionMonitor.cs * added isStreaming flag * added token list * added XEventSession name. * removed polling lock * test adding filters * removed old profile filter as its incompatible * added wip cancel feature in removesession * moved cancellationtoken outside * added backIsStreaming * moved isstreaming around * added multiple events in list * added timeout to handleXEvent * removed timeout * remove eventList count check * remove old events filter * returned eventlist * remove old events filter * renamed xelite handle function * restored sqlclient version * removed original handlestartprofilingrequest * added monitoring stream to handlecreatexeventsessionrequest * removed unnecessary sections from monitor * Revert "removed unnecessary sections from monitor" This reverts commit 91cadeebeeedfe99cec2e9c42944ba6716d95a61. * added xevent actions to profileEvent * removed polling lock for processStreams * added filter for oldevents * removed unused methods * removed comment * removed unnecessary class * removed unnecessary requests * removed outdated methods * added work in progress cancellation task * added profilersessionmonitor changes * added small changes * renamed startMonitoringStream * more changes related to feedback * made changes to code * removed more polling code * fixed tests * added connectioninfo to testxeventsessions * changed functions * added back else * small formatting fix * more changes made * added changes to XEventSession * update to strings * added changes to accomodate tests * more changes * added profilerservicetest for stopprofiling * added TestStoppedSessionNotification test * added session missing details handler * simplified error message * restored strings and added changes * added auto-getter setter for IsStreaming * added more changes * removed unnecessary lines from test * added more debugging messages * made last changes * added error message for handlestopprofilingrequest * added more debug messages * added back an s * added verbose
This commit is contained in:
@@ -65,17 +65,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
// start profiling session
|
||||
await profilerService.HandleStartProfilingRequest(requestParams, requestContext.Object);
|
||||
|
||||
profilerService.SessionMonitor.PollSession(1);
|
||||
// simulate a short polling delay
|
||||
Thread.Sleep(200);
|
||||
profilerService.SessionMonitor.PollSession(1);
|
||||
|
||||
// wait for polling to finish, or for timeout
|
||||
System.Timers.Timer pollingTimer = new System.Timers.Timer();
|
||||
pollingTimer.Interval = 10000;
|
||||
pollingTimer.Start();
|
||||
bool timeout = false;
|
||||
pollingTimer.Elapsed += new System.Timers.ElapsedEventHandler((s_, e_) => {timeout = true;});
|
||||
pollingTimer.Elapsed += new System.Timers.ElapsedEventHandler((s_, e_) => { timeout = true; });
|
||||
while (sessionId == null && !timeout)
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
@@ -125,6 +120,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
ConnectionInfo connectionInfo = TestObjects.GetTestConnectionInfo();
|
||||
profilerService.ConnectionServiceInstance.OwnerToConnectionMap.Add(testUri, connectionInfo);
|
||||
profilerService.XEventSessionFactory = new TestXEventSessionFactory();
|
||||
mockSession.SetupProperty(p => p.ConnectionDetails, connectionInfo.ConnectionDetails);
|
||||
mockSession.SetupProperty(p => p.Session, new Session(null, testUri));
|
||||
|
||||
var requestParams = new StopProfilingParams();
|
||||
requestParams.OwnerUri = testUri;
|
||||
@@ -149,12 +146,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Test]
|
||||
// TODO: Add more in-depth testing for pause effects on events received.
|
||||
public async Task TestPauseProfilingRequest()
|
||||
{
|
||||
bool success = false;
|
||||
string testUri = "test_session";
|
||||
bool recievedEvents = false;
|
||||
|
||||
|
||||
// capture pausing results
|
||||
var requestContext = new Mock<RequestContext<PauseProfilingResult>>();
|
||||
requestContext.Setup(rc => rc.SendResult(It.IsAny<PauseProfilingResult>()))
|
||||
@@ -164,75 +161,34 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
return Task.FromResult(0);
|
||||
});
|
||||
|
||||
// capture Listener event notifications
|
||||
var mockListener = new Mock<IProfilerSessionListener>();
|
||||
mockListener.Setup(p => p.EventsAvailable(It.IsAny<string>(), It.IsAny<List<ProfilerEvent>>(), It.IsAny<bool>())).Callback(() =>
|
||||
{
|
||||
recievedEvents = true;
|
||||
});
|
||||
|
||||
// setup profiler service
|
||||
var mockListener = new TestSessionListener();
|
||||
var profilerService = new ProfilerService();
|
||||
profilerService.SessionMonitor.AddSessionListener(mockListener.Object);
|
||||
profilerService.SessionMonitor.AddSessionListener(mockListener);
|
||||
profilerService.ConnectionServiceInstance = TestObjects.GetTestConnectionService();
|
||||
ConnectionInfo connectionInfo = TestObjects.GetTestConnectionInfo();
|
||||
profilerService.ConnectionServiceInstance.OwnerToConnectionMap.Add(testUri, connectionInfo);
|
||||
|
||||
var testSession = new TestXEventSession1();
|
||||
testSession.ConnectionDetails = connectionInfo.ConnectionDetails;
|
||||
testSession.Session = new Session(null, testUri);
|
||||
|
||||
var requestParams = new PauseProfilingParams();
|
||||
requestParams.OwnerUri = testUri;
|
||||
|
||||
// begin monitoring session
|
||||
profilerService.SessionMonitor.StartMonitoringSession(testUri, new TestXEventSession1());
|
||||
|
||||
// poll the session
|
||||
profilerService.SessionMonitor.PollSession(1);
|
||||
Thread.Sleep(500);
|
||||
profilerService.SessionMonitor.PollSession(1);
|
||||
|
||||
// wait for polling to finish, or for timeout
|
||||
System.Timers.Timer pollingTimer = new System.Timers.Timer();
|
||||
pollingTimer.Interval = 10000;
|
||||
pollingTimer.Start();
|
||||
bool timeout = false;
|
||||
pollingTimer.Elapsed += new System.Timers.ElapsedEventHandler((s_, e_) => {timeout = true;});
|
||||
while (!recievedEvents && !timeout)
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
pollingTimer.Stop();
|
||||
|
||||
// confirm that polling works
|
||||
Assert.True(recievedEvents);
|
||||
profilerService.SessionMonitor.StartMonitoringSession(testUri, testSession);
|
||||
|
||||
// pause viewer
|
||||
await profilerService.HandlePauseProfilingRequest(requestParams, requestContext.Object);
|
||||
Assert.True(success);
|
||||
|
||||
recievedEvents = false;
|
||||
success = false;
|
||||
|
||||
profilerService.SessionMonitor.PollSession(1);
|
||||
|
||||
// confirm that no events were sent to paused Listener
|
||||
Assert.False(recievedEvents);
|
||||
|
||||
// unpause viewer
|
||||
await profilerService.HandlePauseProfilingRequest(requestParams, requestContext.Object);
|
||||
Assert.True(success);
|
||||
|
||||
profilerService.SessionMonitor.PollSession(1);
|
||||
|
||||
// wait for polling to finish, or for timeout
|
||||
timeout = false;
|
||||
pollingTimer.Start();
|
||||
while (!recievedEvents && !timeout)
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
|
||||
// check that events got sent to Listener
|
||||
Assert.True(recievedEvents);
|
||||
|
||||
requestContext.VerifyAll();
|
||||
}
|
||||
|
||||
@@ -263,21 +219,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
profilerService.ConnectionServiceInstance = TestObjects.GetTestConnectionService();
|
||||
ConnectionInfo connectionInfo = TestObjects.GetTestConnectionInfo();
|
||||
profilerService.ConnectionServiceInstance.OwnerToConnectionMap.Add(testUri, connectionInfo);
|
||||
mockSession.SetupProperty(p => p.ConnectionDetails, connectionInfo.ConnectionDetails);
|
||||
mockSession.SetupProperty(p => p.Session, new Session(null, testUri));
|
||||
|
||||
// start monitoring test session
|
||||
profilerService.SessionMonitor.StartMonitoringSession(testUri, mockSession.Object);
|
||||
|
||||
// wait for polling to finish, or for timeout
|
||||
System.Timers.Timer pollingTimer = new System.Timers.Timer();
|
||||
pollingTimer.Interval = 10000;
|
||||
pollingTimer.Start();
|
||||
bool timeout = false;
|
||||
pollingTimer.Elapsed += new System.Timers.ElapsedEventHandler((s_, e_) => {timeout = true;});
|
||||
while (sessionStopped == false && !timeout)
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
pollingTimer.Stop();
|
||||
// Call stop session to simulate when a server has stopped a session on its side.
|
||||
profilerService.SessionMonitor.StopSession(0);
|
||||
|
||||
// check that a stopped session notification was sent
|
||||
Assert.True(sessionStopped);
|
||||
|
||||
Reference in New Issue
Block a user