mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Adding pausing functionality for the profiler (#634)
* Dropping profiler session on stop request * Changes to IXEventSession to simplify dropping sessions * Stop sessions instead of dropping, disable flaky tests * Initial framework for profiler pause requests * Restructuring profiler session monitoring * Fixes to session monitor * Testing for pause functionality * Fixing comments from PR * Changes to testing * Commenting out flaky test * Deleting leftover testing code
This commit is contained in:
committed by
GitHub
parent
aff0f1afae
commit
f53e532225
@@ -188,19 +188,168 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
|
||||
" </event>" +
|
||||
"</RingBufferTarget>";
|
||||
|
||||
|
||||
|
||||
public int Id { get { return 51; } }
|
||||
|
||||
public void Start(){}
|
||||
|
||||
public void Stop(){}
|
||||
public string GetTargetXml()
|
||||
{
|
||||
return testXEventXml;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestXEventSession1 : IXEventSession
|
||||
{
|
||||
private const string testXEventXml_1 =
|
||||
"<RingBufferTarget truncated=\"0\" processingTime=\"3\" totalEventsProcessed=\"1\" eventCount=\"1\" droppedCount=\"0\" memoryUsed=\"47996\">" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-09-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>1</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
"</RingBufferTarget>";
|
||||
|
||||
private const string testXEventXml_2 =
|
||||
"<RingBufferTarget truncated=\"0\" processingTime=\"3\" totalEventsProcessed=\"1\" eventCount=\"1\" droppedCount=\"0\" memoryUsed=\"47996\">" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-09-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>1</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-10-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>1</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
"</RingBufferTarget>";
|
||||
|
||||
private const string testXEventXml_3 =
|
||||
"<RingBufferTarget truncated=\"0\" processingTime=\"3\" totalEventsProcessed=\"1\" eventCount=\"1\" droppedCount=\"0\" memoryUsed=\"47996\">" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-09-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>1</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-10-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>1</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-11-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>1</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
"</RingBufferTarget>";
|
||||
|
||||
public int Id { get { return 1; } }
|
||||
|
||||
public void Start(){}
|
||||
|
||||
public void Stop(){}
|
||||
|
||||
private int pollCount = 0;
|
||||
private string[] poll_returns = { testXEventXml_1, testXEventXml_2, testXEventXml_3 };
|
||||
public string GetTargetXml()
|
||||
{
|
||||
string res = poll_returns[pollCount];
|
||||
pollCount++;
|
||||
pollCount = pollCount > 2 ? 0 : pollCount;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestXEventSession2 : IXEventSession
|
||||
{
|
||||
private const string testXEventXml_1 =
|
||||
"<RingBufferTarget truncated=\"0\" processingTime=\"3\" totalEventsProcessed=\"1\" eventCount=\"1\" droppedCount=\"0\" memoryUsed=\"47996\">" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-09-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>2</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
"</RingBufferTarget>";
|
||||
|
||||
private const string testXEventXml_2 =
|
||||
"<RingBufferTarget truncated=\"0\" processingTime=\"3\" totalEventsProcessed=\"1\" eventCount=\"1\" droppedCount=\"0\" memoryUsed=\"47996\">" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-09-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>2</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-10-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>2</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
"</RingBufferTarget>";
|
||||
|
||||
private const string testXEventXml_3 =
|
||||
"<RingBufferTarget truncated=\"0\" processingTime=\"3\" totalEventsProcessed=\"1\" eventCount=\"1\" droppedCount=\"0\" memoryUsed=\"47996\">" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-09-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>2</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-10-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>2</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-11-08T07:46:53.579Z\">" +
|
||||
" <data name=\"session_id\">" +
|
||||
" <type name=\"int16\" package=\"package0\"></type>" +
|
||||
" <value>2</value>" +
|
||||
" </data>" +
|
||||
" </event>" +
|
||||
"</RingBufferTarget>";
|
||||
|
||||
public int Id { get { return 2; } }
|
||||
|
||||
public void Start(){}
|
||||
|
||||
public void Stop(){}
|
||||
|
||||
private int pollCount = 0;
|
||||
private string[] poll_returns = { testXEventXml_1, testXEventXml_2, testXEventXml_3 };
|
||||
public string GetTargetXml()
|
||||
{
|
||||
string res = poll_returns[pollCount];
|
||||
pollCount++;
|
||||
pollCount = pollCount > 2 ? 0 : pollCount;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestXEventSessionFactory : IXEventSessionFactory
|
||||
{
|
||||
public IXEventSession CreateXEventSession(ConnectionInfo connInfo)
|
||||
private int sessionNum = 1;
|
||||
public IXEventSession GetOrCreateXEventSession(string template, ConnectionInfo connInfo)
|
||||
{
|
||||
return new TestXEventSession();
|
||||
if(sessionNum == 1)
|
||||
{
|
||||
sessionNum = 2;
|
||||
return new TestXEventSession1();
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionNum = 1;
|
||||
return new TestXEventSession2();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user