mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
* Initial changes to have serialization generate its own .exe * Removed additional project from sln file * remove all references to removed temporary project * Moved shared contracts into own dll and fixed imports. Addressed PR comments * Undid having a separate contracts project since that'll be a task for later on. Moved dbcellvalue and saveresultsrequest to Hosting, where they will be imported and shared by the service layer and serialization projects * Switched backslashes in project reference in csproj file to forward slashes for consistency * Moved necessary contracts back to service layer. Refactored CommandOptions to reduce code duplication. Addressed miscellaneous PR suggestions * Accidentally left these files out of previous commit * Initialized loggers for serialization and credentials with the logging directory provided by the cmd line arg, if there is one * Changed default log directory paths for serialization and credentials. Removed unnecessary cast and added a copyright * Changed name of generated executable for serialization service * removed unnecessary object cast * removing unnecessary imports and addressing other PR comments
99 lines
3.9 KiB
C#
99 lines
3.9 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
|
|
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
|
{
|
|
public class QueryExecutionTests
|
|
{
|
|
[Fact]
|
|
public async Task QueryResultSummaryOnPremTest()
|
|
{
|
|
TestServerType serverType = TestServerType.OnPrem;
|
|
|
|
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
|
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
|
{
|
|
const string query = Scripts.MasterBasicQuery;
|
|
|
|
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
|
|
var queryResult = await testService.CalculateRunTime(() => testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, query), true);
|
|
|
|
Assert.NotNull(queryResult);
|
|
Assert.True(queryResult.BatchSummaries.Any(x => x.ResultSetSummaries.Any(r => r.RowCount > 0)));
|
|
|
|
await testService.Disconnect(queryTempFile.FilePath);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public async Task QueryResultFirstOnPremTest()
|
|
{
|
|
TestServerType serverType = TestServerType.OnPrem;
|
|
|
|
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
|
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
|
{
|
|
const string query = Scripts.MasterBasicQuery;
|
|
|
|
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
|
|
|
|
var queryResult = await testService.CalculateRunTime(async () =>
|
|
{
|
|
await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, query);
|
|
return await testService.ExecuteSubset(queryTempFile.FilePath, 0, 0, 0, 100);
|
|
}, true);
|
|
|
|
Assert.NotNull(queryResult);
|
|
Assert.NotNull(queryResult.ResultSubset);
|
|
Assert.True(queryResult.ResultSubset.Rows.Any());
|
|
|
|
await testService.Disconnect(queryTempFile.FilePath);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
[CreateTestDb(TestServerType.OnPrem)]
|
|
public async Task CancelQueryOnPremTest()
|
|
{
|
|
TestServerType serverType = TestServerType.OnPrem;
|
|
|
|
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
|
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
|
{
|
|
await testService.ConnectForQuery(serverType, Scripts.DelayQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
|
var queryParams = new ExecuteDocumentSelectionParams
|
|
{
|
|
OwnerUri = queryTempFile.FilePath,
|
|
QuerySelection = null
|
|
};
|
|
|
|
var result = await testService.Driver.SendRequest(ExecuteDocumentSelectionRequest.Type, queryParams);
|
|
if (result != null)
|
|
{
|
|
TestTimer timer = new TestTimer() { PrintResult = true };
|
|
await testService.ExecuteWithTimeout(timer, 100000, async () =>
|
|
{
|
|
var cancelQueryResult = await testService.CancelQuery(queryTempFile.FilePath);
|
|
return true;
|
|
}, TimeSpan.FromMilliseconds(10));
|
|
}
|
|
else
|
|
{
|
|
Assert.True(false, "Failed to run the query");
|
|
}
|
|
|
|
await testService.Disconnect(queryTempFile.FilePath);
|
|
}
|
|
}
|
|
}
|
|
}
|