mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-12 11:08:31 -05:00
Add ability to create sessions from templates, and list existing sessions (#671)
* Initial changes to connect to existing sessions * Creating new profiler sessions * Some session template changes * Fixing errors * Cleaning up comments, string constants, and formatting * Removing commented code
This commit is contained in:
committed by
GitHub
parent
e8360ef68e
commit
4b9807f0cf
@@ -39,7 +39,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Profiler
|
||||
// start a new session
|
||||
var startParams = new StartProfilingParams();
|
||||
startParams.OwnerUri = connectionResult.ConnectionInfo.OwnerUri;
|
||||
startParams.TemplateName = "Standard";
|
||||
startParams.SessionName = "Standard";
|
||||
|
||||
string sessionId = null;
|
||||
var startContext = new Mock<RequestContext<StartProfilingResult>>();
|
||||
@@ -47,7 +47,6 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Profiler
|
||||
.Returns<StartProfilingResult>((result) =>
|
||||
{
|
||||
// capture the session id for sending the stop message
|
||||
sessionId = result.SessionId;
|
||||
return Task.FromResult(0);
|
||||
});
|
||||
|
||||
@@ -82,7 +81,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Profiler
|
||||
{
|
||||
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
|
||||
ProfilerService profilerService = new ProfilerService();
|
||||
IXEventSession xeSession = profilerService.GetOrCreateXEventSession("Profiler", liveConnection.ConnectionInfo);
|
||||
IXEventSession xeSession = profilerService.GetXEventSession("Profiler", liveConnection.ConnectionInfo);
|
||||
Assert.NotNull(xeSession);
|
||||
Assert.NotNull(xeSession.GetTargetXml());
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
.Returns<StartProfilingResult>((result) =>
|
||||
{
|
||||
// capture the session id for sending the stop message
|
||||
sessionId = result.SessionId;
|
||||
return Task.FromResult(0);
|
||||
});
|
||||
|
||||
@@ -60,7 +59,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
|
||||
var requestParams = new StartProfilingParams();
|
||||
requestParams.OwnerUri = testUri;
|
||||
requestParams.TemplateName = "Standard";
|
||||
requestParams.SessionName = "Standard";
|
||||
|
||||
// start profiling session
|
||||
await profilerService.HandleStartProfilingRequest(requestParams, requestContext.Object);
|
||||
|
||||
@@ -400,7 +400,21 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
public class TestXEventSessionFactory : IXEventSessionFactory
|
||||
{
|
||||
private int sessionNum = 1;
|
||||
public IXEventSession GetOrCreateXEventSession(string template, ConnectionInfo connInfo)
|
||||
public IXEventSession GetXEventSession(string sessionName, ConnectionInfo connInfo)
|
||||
{
|
||||
if(sessionNum == 1)
|
||||
{
|
||||
sessionNum = 2;
|
||||
return new TestXEventSession1();
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionNum = 1;
|
||||
return new TestXEventSession2();
|
||||
}
|
||||
}
|
||||
|
||||
public IXEventSession CreateXEventSession(string createStatement, string sessionName, ConnectionInfo connInfo)
|
||||
{
|
||||
if(sessionNum == 1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user