mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Feature: Progressive Messages (#208)
This change is a reworking of the way that messages are sent to clients from the service layer. It is also a reworking of the protocol to ensure that all formulations of query send back events to the client in a deterministic ordering. To support the first change: * Added a new event that will be sent when a message is generated * Messages now indicate which Batch (if any) generated them * Messages now indicate if they were error level * Removed message storage in Batch objects and BatchSummary objects * Batch objects no longer have error state
This commit is contained in:
@@ -327,34 +327,33 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
}
|
||||
*/
|
||||
|
||||
[Fact]
|
||||
public async Task NoOpQueryReturnsMessage()
|
||||
[Theory]
|
||||
[InlineData("-- no-op")]
|
||||
[InlineData("GO")]
|
||||
[InlineData("GO -- no-op")]
|
||||
public async Task NoOpQueryReturnsMessage(string query)
|
||||
{
|
||||
// Given queries that do nothing (no-ops)...
|
||||
var queries = new string[]
|
||||
{
|
||||
"-- no-op",
|
||||
"GO",
|
||||
"GO -- no-op"
|
||||
};
|
||||
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestHelper testHelper = new TestHelper())
|
||||
{
|
||||
foreach (var query in queries)
|
||||
{
|
||||
Assert.True(await testHelper.Connect(queryTempFile.FilePath, ConnectionTestUtils.LocalhostConnection));
|
||||
Assert.True(await testHelper.Connect(queryTempFile.FilePath, ConnectionTestUtils.LocalhostConnection));
|
||||
|
||||
// If the queries are executed...
|
||||
var queryResult = await testHelper.RunQueryAsync(queryTempFile.FilePath, query);
|
||||
// If: the query is executed...
|
||||
var queryResult = await testHelper.RunQueryAsync(queryTempFile.FilePath, query);
|
||||
var message = await testHelper.WaitForMessage();
|
||||
|
||||
// Then I expect messages that the commands were completed successfully to be in the result
|
||||
Assert.NotNull(queryResult);
|
||||
Assert.NotNull(queryResult.Messages);
|
||||
Assert.Equal("Commands completed successfully.", queryResult.Messages);
|
||||
// Then:
|
||||
// ... I expect a query result to indicate successfully started query
|
||||
Assert.NotNull(queryResult);
|
||||
|
||||
await testHelper.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
// ... I expect a non-error message to be returned without a batch associated with it
|
||||
Assert.NotNull(message);
|
||||
Assert.NotNull(message.Message);
|
||||
Assert.NotNull(message.Message.Message);
|
||||
Assert.False(message.Message.IsError);
|
||||
Assert.Null(message.Message.BatchId);
|
||||
|
||||
await testHelper.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
};
|
||||
|
||||
var result = await Driver.SendRequest(QueryExecuteRequest.Type, queryParams);
|
||||
if (result != null && string.IsNullOrEmpty(result.Messages))
|
||||
if (result != null)
|
||||
{
|
||||
var eventResult = await Driver.WaitForEvent(QueryExecuteCompleteEvent.Type, timeoutMilliseconds);
|
||||
return eventResult;
|
||||
@@ -384,6 +384,15 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits for a message to be returned by the service
|
||||
/// </summary>
|
||||
/// <returns>A message from the service layer</returns>
|
||||
public async Task<QueryExecuteMessageParams> WaitForMessage()
|
||||
{
|
||||
return await Driver.WaitForEvent(QueryExecuteMessageEvent.Type);
|
||||
}
|
||||
|
||||
public void WriteToFile(string ownerUri, string query)
|
||||
{
|
||||
lock (fileLock)
|
||||
|
||||
Reference in New Issue
Block a user