mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
fixed perf tests and added more scenarios (#683)
* fixed perf tests and added more scenarios
This commit is contained in:
@@ -25,8 +25,7 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
}
|
||||
|
||||
Logger.Initialize("testdriver", LogLevel.Verbose);
|
||||
|
||||
return TestRunner.RunTests(args, "Microsoft.SqlTools.ServiceLayer.PerfTests.").Result;
|
||||
return TestRunner.Instance.RunTests(args, "Microsoft.SqlTools.ServiceLayer.PerfTests.").Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,85 +18,94 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
[CreateTestDb(TestServerType.Azure)]
|
||||
public async Task ConnectAzureTest()
|
||||
{
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
testService.WriteToFile(queryTempFile.FilePath, query);
|
||||
|
||||
DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
TextDocument = new TextDocumentItem
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
testService.WriteToFile(queryTempFile.FilePath, query);
|
||||
|
||||
DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification
|
||||
{
|
||||
Uri = queryTempFile.FilePath,
|
||||
LanguageId = "enu",
|
||||
Version = 1,
|
||||
Text = query
|
||||
}
|
||||
};
|
||||
TextDocument = new TextDocumentItem
|
||||
{
|
||||
Uri = queryTempFile.FilePath,
|
||||
LanguageId = "enu",
|
||||
Version = 1,
|
||||
Text = query
|
||||
}
|
||||
};
|
||||
|
||||
await testService.RequestOpenDocumentNotification(openParams);
|
||||
await testService.RequestOpenDocumentNotification(openParams);
|
||||
|
||||
Thread.Sleep(500);
|
||||
var connected = await testService.CalculateRunTime(async () =>
|
||||
{
|
||||
var connectParams = testService.GetConnectionParameters(serverType, Common.PerfTestDatabaseName);
|
||||
return await testService.Connect(queryTempFile.FilePath, connectParams);
|
||||
}, true);
|
||||
Assert.True(connected, "Connection was not successful");
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
var connected = await testService.CalculateRunTime(async () =>
|
||||
{
|
||||
var connectParams = testService.GetConnectionParameters(serverType, Common.PerfTestDatabaseName);
|
||||
return await testService.Connect(queryTempFile.FilePath, connectParams);
|
||||
}, timer);
|
||||
Assert.True(connected, "Connection was not successful");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task ConnectOnPremTest()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
testService.WriteToFile(queryTempFile.FilePath, query);
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
TextDocument = new TextDocumentItem
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
testService.WriteToFile(queryTempFile.FilePath, query);
|
||||
|
||||
DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification
|
||||
{
|
||||
Uri = queryTempFile.FilePath,
|
||||
LanguageId = "enu",
|
||||
Version = 1,
|
||||
Text = query
|
||||
}
|
||||
};
|
||||
TextDocument = new TextDocumentItem
|
||||
{
|
||||
Uri = queryTempFile.FilePath,
|
||||
LanguageId = "enu",
|
||||
Version = 1,
|
||||
Text = query
|
||||
}
|
||||
};
|
||||
|
||||
await testService.RequestOpenDocumentNotification(openParams);
|
||||
await testService.RequestOpenDocumentNotification(openParams);
|
||||
|
||||
Thread.Sleep(500);
|
||||
var connected = await testService.CalculateRunTime(async () =>
|
||||
{
|
||||
var connectParams = testService.GetConnectionParameters(serverType, Common.PerfTestDatabaseName);
|
||||
return await testService.Connect(queryTempFile.FilePath, connectParams);
|
||||
}, true);
|
||||
Assert.True(connected, "Connection was not successful");
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
var connected = await testService.CalculateRunTime(async () =>
|
||||
{
|
||||
var connectParams = testService.GetConnectionParameters(serverType, Common.PerfTestDatabaseName);
|
||||
return await testService.Connect(queryTempFile.FilePath, connectParams);
|
||||
}, timer);
|
||||
Assert.True(connected, "Connection was not successful");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task DisconnectTest()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
await testService.ConnectForQuery(serverType, Scripts.TestDbSimpleSelectQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
Thread.Sleep(1000);
|
||||
var connected = await testService.CalculateRunTime(() => testService.Disconnect(queryTempFile.FilePath), true);
|
||||
Assert.True(connected);
|
||||
}
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
await testService.ConnectForQuery(serverType, Scripts.TestDbSimpleSelectQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
Thread.Sleep(1000);
|
||||
var connected = await testService.CalculateRunTime(() => testService.Disconnect(queryTempFile.FilePath), timer);
|
||||
Assert.True(connected);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,107 +21,122 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task HoverTestOnPrem()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
Hover hover = await testService.CalculateRunTime(() => testService.RequestHover(queryTempFile.FilePath, query, 0, Scripts.TestDbComplexSelectQueries.Length + 1), true);
|
||||
Assert.NotNull(hover);
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
await ValidateCompletionResponse(testService, queryTempFile.FilePath, Common.PerfTestDatabaseName, waitForIntelliSense: true);
|
||||
Hover hover = await testService.CalculateRunTime(() => testService.RequestHover(queryTempFile.FilePath, query, 0, Scripts.TestDbComplexSelectQueries.Length + 1), timer);
|
||||
Assert.NotNull(hover);
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task SuggestionsTest()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
await ValidateCompletionResponse(testService, queryTempFile.FilePath, false, Common.PerfTestDatabaseName, true);
|
||||
await ValidateCompletionResponse(testService, queryTempFile.FilePath, true, Common.PerfTestDatabaseName, false);
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
await ValidateCompletionResponse(testService, queryTempFile.FilePath, Common.PerfTestDatabaseName, timer: null, waitForIntelliSense: true);
|
||||
await ValidateCompletionResponse(testService, queryTempFile.FilePath, Common.PerfTestDatabaseName, timer: timer, waitForIntelliSense: false);
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task DiagnosticsTests()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
SqlTestDb.CreateNew(serverType, doNotCleanupDb: true, databaseName: Common.PerfTestDatabaseName, query: Scripts.CreateDatabaseObjectsQuery);
|
||||
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
await testService.ConnectForQuery(serverType, Scripts.TestDbSimpleSelectQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
SqlTestDb.CreateNew(serverType, doNotCleanupDb: true, databaseName: Common.PerfTestDatabaseName, query: Scripts.CreateDatabaseObjectsQuery);
|
||||
|
||||
Thread.Sleep(500);
|
||||
var contentChanges = new TextDocumentChangeEvent[1];
|
||||
contentChanges[0] = new TextDocumentChangeEvent()
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
Range = new Range
|
||||
await testService.ConnectForQuery(serverType, Scripts.TestDbSimpleSelectQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
|
||||
Thread.Sleep(500);
|
||||
var contentChanges = new TextDocumentChangeEvent[1];
|
||||
contentChanges[0] = new TextDocumentChangeEvent()
|
||||
{
|
||||
Start = new Position
|
||||
Range = new Range
|
||||
{
|
||||
Line = 0,
|
||||
Character = 5
|
||||
Start = new Position
|
||||
{
|
||||
Line = 0,
|
||||
Character = 5
|
||||
},
|
||||
End = new Position
|
||||
{
|
||||
Line = 0,
|
||||
Character = 6
|
||||
}
|
||||
},
|
||||
End = new Position
|
||||
{
|
||||
Line = 0,
|
||||
Character = 6
|
||||
}
|
||||
},
|
||||
RangeLength = 1,
|
||||
Text = "z"
|
||||
};
|
||||
DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams
|
||||
{
|
||||
ContentChanges = contentChanges,
|
||||
TextDocument = new VersionedTextDocumentIdentifier
|
||||
RangeLength = 1,
|
||||
Text = "z"
|
||||
};
|
||||
DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams
|
||||
{
|
||||
Version = 2,
|
||||
Uri = queryTempFile.FilePath
|
||||
}
|
||||
};
|
||||
ContentChanges = contentChanges,
|
||||
TextDocument = new VersionedTextDocumentIdentifier
|
||||
{
|
||||
Version = 2,
|
||||
Uri = queryTempFile.FilePath
|
||||
}
|
||||
};
|
||||
|
||||
TestTimer timer = new TestTimer() { PrintResult = true };
|
||||
await testService.RequestChangeTextDocumentNotification(changeParams);
|
||||
await testService.ExecuteWithTimeout(timer, 60000, async () =>
|
||||
{
|
||||
var completeEvent = await testService.Driver.WaitForEvent(PublishDiagnosticsNotification.Type, 15000);
|
||||
return completeEvent?.Diagnostics != null && completeEvent.Diagnostics.Length > 0;
|
||||
});
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
await testService.RequestChangeTextDocumentNotification(changeParams);
|
||||
await testService.ExecuteWithTimeout(timer, 60000, async () =>
|
||||
{
|
||||
var completeEvent = await testService.Driver.WaitForEvent(PublishDiagnosticsNotification.Type, 15000);
|
||||
return completeEvent?.Diagnostics != null && completeEvent.Diagnostics.Length > 0;
|
||||
});
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.Azure)]
|
||||
public async Task BindingCacheColdAzureSimpleQuery()
|
||||
{
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
await VerifyBindingLoadScenario(testService, serverType, Scripts.TestDbSimpleSelectQuery, false);
|
||||
}
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
await VerifyBindingLoadScenario(testService, serverType, Scripts.TestDbSimpleSelectQuery, false, timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task BindingCacheColdOnPremSimpleQuery()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
await VerifyBindingLoadScenario(testService, serverType, Scripts.TestDbSimpleSelectQuery, false);
|
||||
}
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
await VerifyBindingLoadScenario(testService, serverType, Scripts.TestDbSimpleSelectQuery, false, timer);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -129,76 +144,94 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
[CreateTestDb(TestServerType.Azure)]
|
||||
public async Task BindingCacheWarmAzureSimpleQuery()
|
||||
{
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
await VerifyBindingLoadScenario(testService, serverType, query, true);
|
||||
}
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
await VerifyBindingLoadScenario(testService, serverType, query, true, timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task BindingCacheWarmOnPremSimpleQuery()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
await VerifyBindingLoadScenario(testService, serverType, query, true);
|
||||
}
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
const string query = Scripts.TestDbSimpleSelectQuery;
|
||||
await VerifyBindingLoadScenario(testService, serverType, query, true, timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.Azure)]
|
||||
public async Task BindingCacheColdAzureComplexQuery()
|
||||
{
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
await VerifyBindingLoadScenario(testService, serverType, Scripts.TestDbComplexSelectQueries,false);
|
||||
}
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
await VerifyBindingLoadScenario(testService, serverType, Scripts.TestDbComplexSelectQueries, false, timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task BindingCacheColdOnPremComplexQuery()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
await VerifyBindingLoadScenario(testService, serverType, Scripts.TestDbComplexSelectQueries, false);
|
||||
}
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
await VerifyBindingLoadScenario(testService, serverType, Scripts.TestDbComplexSelectQueries, false, timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.Azure)]
|
||||
public async Task BindingCacheWarmAzureComplexQuery()
|
||||
{
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
string query = Scripts.TestDbComplexSelectQueries;
|
||||
const TestServerType serverType = TestServerType.Azure;
|
||||
await VerifyBindingLoadScenario(testService, serverType, query, true);
|
||||
}
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
string query = Scripts.TestDbComplexSelectQueries;
|
||||
const TestServerType serverType = TestServerType.Azure;
|
||||
await VerifyBindingLoadScenario(testService, serverType, query, true, timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task BindingCacheWarmOnPremComplexQuery()
|
||||
{
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
string query = Scripts.TestDbComplexSelectQueries;
|
||||
const TestServerType serverType = TestServerType.OnPrem;
|
||||
await VerifyBindingLoadScenario(testService, serverType, query, true);
|
||||
}
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
string query = Scripts.TestDbComplexSelectQueries;
|
||||
const TestServerType serverType = TestServerType.OnPrem;
|
||||
await VerifyBindingLoadScenario(testService, serverType, query, true, timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#region Private Helper Methods
|
||||
@@ -207,34 +240,36 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
TestServiceDriverProvider testService,
|
||||
TestServerType serverType,
|
||||
string query,
|
||||
bool preLoad,
|
||||
bool preLoad,
|
||||
TestTimer timer,
|
||||
[CallerMemberName] string testName = "")
|
||||
{
|
||||
string databaseName = Common.PerfTestDatabaseName;
|
||||
if (preLoad)
|
||||
{
|
||||
await VerifyCompletationLoaded(testService, serverType, Scripts.TestDbSimpleSelectQuery,
|
||||
databaseName, printResult: false, testName: testName);
|
||||
databaseName, null, testName: testName);
|
||||
Console.WriteLine("Intellisense cache loaded.");
|
||||
}
|
||||
await VerifyCompletationLoaded(testService, serverType, query, databaseName,
|
||||
printResult: true, testName: testName);
|
||||
timer, testName: testName);
|
||||
}
|
||||
|
||||
private async Task VerifyCompletationLoaded(
|
||||
TestServiceDriverProvider testService,
|
||||
TestServerType serverType,
|
||||
string query,
|
||||
private async Task VerifyCompletationLoaded(
|
||||
TestServiceDriverProvider testService,
|
||||
TestServerType serverType,
|
||||
string query,
|
||||
string databaseName,
|
||||
bool printResult,
|
||||
TestTimer timer,
|
||||
string testName)
|
||||
{
|
||||
|
||||
using (SelfCleaningTempFile testTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
testService.WriteToFile(testTempFile.FilePath, query);
|
||||
await testService.ConnectForQuery(serverType, query, testTempFile.FilePath, databaseName);
|
||||
await ValidateCompletionResponse(testService, testTempFile.FilePath, printResult, databaseName,
|
||||
waitForIntelliSense: true, testName: testName);
|
||||
await ValidateCompletionResponse(testService, testTempFile.FilePath, databaseName,
|
||||
waitForIntelliSense: true, timer: timer, testName: testName);
|
||||
await testService.Disconnect(testTempFile.FilePath);
|
||||
}
|
||||
}
|
||||
@@ -242,14 +277,17 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
private static async Task ValidateCompletionResponse(
|
||||
TestServiceDriverProvider testService,
|
||||
string ownerUri,
|
||||
bool printResult,
|
||||
string databaseName,
|
||||
bool waitForIntelliSense,
|
||||
bool waitForIntelliSense,
|
||||
TestTimer timer = null,
|
||||
[CallerMemberName] string testName = "")
|
||||
{
|
||||
TestTimer timer = new TestTimer() { PrintResult = printResult };
|
||||
if (timer == null)
|
||||
{
|
||||
timer = new TestTimer { PrintResult = false };
|
||||
}
|
||||
bool isReady = !waitForIntelliSense;
|
||||
await testService.ExecuteWithTimeout(timer, 150000, async () =>
|
||||
await testService.ExecuteWithTimeout(timer, 550000, async () =>
|
||||
{
|
||||
if (isReady)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
//
|
||||
// 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.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
{
|
||||
public class ObjectExplorerTests
|
||||
{
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.Azure)]
|
||||
public async Task CreateSessionAzure()
|
||||
{
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
await VerifyCreateSession(serverType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task CreateSessionOnPrem()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
await VerifyCreateSession(serverType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task ExpandDatabasesOnPrem()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
await VerifyExpand(serverType, SqlTestDb.MasterDatabaseName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task ExpandOneDatabaseOnPrem()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
await VerifyExpand(serverType, Common.PerfTestDatabaseName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.Azure)]
|
||||
public async Task ExpandDatabasesAzure()
|
||||
{
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
await VerifyExpand(serverType, SqlTestDb.MasterDatabaseName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.Azure)]
|
||||
public async Task ExpandOneDatabaseAzure()
|
||||
{
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
await VerifyExpand(serverType, Common.PerfTestDatabaseName);
|
||||
}
|
||||
|
||||
private async Task VerifyCreateSession(TestServerType serverType, [CallerMemberName] string testName = "")
|
||||
{
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
ConnectParams connectParams = TestServiceProvider.Instance.ConnectionProfileService.GetConnectionParameters(serverType, SqlTestDb.MasterDatabaseName);
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
var result = await testService.CalculateRunTime(() => testService.RequestObjectExplorerCreateSession(connectParams.Connection), timer);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.Success);
|
||||
Assert.False(string.IsNullOrEmpty(result.SessionId), "Session id cannot be empty");
|
||||
|
||||
await testService.RequestObjectExplorerCloseSession(new ObjectExplorer.Contracts.CloseSessionParams
|
||||
{
|
||||
SessionId = result.SessionId
|
||||
});
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
}, testName);
|
||||
}
|
||||
|
||||
|
||||
private async Task VerifyExpand(TestServerType serverType, string databaseName, [CallerMemberName] string testName = "")
|
||||
{
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
ConnectParams connectParams = TestServiceProvider.Instance.ConnectionProfileService.GetConnectionParameters(serverType, databaseName);
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
var result = await testService.CalculateRunTime(() => testService.RequestObjectExplorerCreateSession(connectParams.Connection), null);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.Success);
|
||||
Assert.False(string.IsNullOrEmpty(result.SessionId), "Session id cannot be empty");
|
||||
|
||||
await ExpandDatabase(testService, result.SessionId, result.RootNode, timer);
|
||||
|
||||
await testService.RequestObjectExplorerCloseSession(new ObjectExplorer.Contracts.CloseSessionParams
|
||||
{
|
||||
SessionId = result.SessionId
|
||||
});
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
}, testName);
|
||||
}
|
||||
|
||||
private async Task<bool> ExpandDatabase(TestServiceDriverProvider testService, string sessionId, NodeInfo nodeInfo, TestTimer timer)
|
||||
{
|
||||
if (nodeInfo == null) return false;
|
||||
bool foundNode = nodeInfo.NodePath.Contains("Database") || nodeInfo.NodeType == "Database";
|
||||
var expandResult = await testService.CalculateRunTime(() => testService.RequestObjectExplorerExpand(new ObjectExplorer.Contracts.ExpandParams
|
||||
{
|
||||
SessionId = sessionId,
|
||||
NodePath = nodeInfo.NodePath
|
||||
}, 50000), foundNode ? timer : null);
|
||||
|
||||
Assert.NotNull(expandResult);
|
||||
Assert.NotNull(expandResult.Nodes);
|
||||
Assert.False(expandResult.Nodes == null, "Nodes are not valid");
|
||||
if (!foundNode)
|
||||
{
|
||||
foreach (var node in expandResult.Nodes)
|
||||
{
|
||||
if (await ExpandDatabase(testService, sessionId, node, timer))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Node Expanded " + nodeInfo.NodePath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
@@ -17,82 +18,137 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
[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);
|
||||
}
|
||||
await QueryResultSummaryOnPremTest(TestServerType.OnPrem, Scripts.MasterBasicQuery);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task QueryResultFirstOnPremTest()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
await QueryResultFirstOnPremTest(TestServerType.OnPrem, Scripts.MasterBasicQuery);
|
||||
}
|
||||
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
const string query = Scripts.MasterBasicQuery;
|
||||
[Fact]
|
||||
public async Task LongQueryResultSummaryOnPremTest()
|
||||
{
|
||||
await QueryResultSummaryOnPremTest(TestServerType.OnPrem, Scripts.MasterLongQuery);
|
||||
}
|
||||
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
|
||||
[Fact]
|
||||
public async Task LongQueryResultFirstOnPremTest()
|
||||
{
|
||||
await QueryResultFirstOnPremTest(TestServerType.OnPrem, Scripts.MasterLongQuery);
|
||||
}
|
||||
|
||||
var queryResult = await testService.CalculateRunTime(async () =>
|
||||
{
|
||||
await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, query);
|
||||
return await testService.ExecuteSubset(queryTempFile.FilePath, 0, 0, 0, 100);
|
||||
}, true);
|
||||
[Fact]
|
||||
public async Task QueryResultSummaryOnAzureTest()
|
||||
{
|
||||
await QueryResultSummaryOnPremTest(TestServerType.Azure, Scripts.MasterBasicQuery);
|
||||
}
|
||||
|
||||
Assert.NotNull(queryResult);
|
||||
Assert.NotNull(queryResult.ResultSubset);
|
||||
Assert.True(queryResult.ResultSubset.Rows.Any());
|
||||
[Fact]
|
||||
public async Task QueryResultFirstOnAzureTest()
|
||||
{
|
||||
await QueryResultFirstOnPremTest(TestServerType.Azure, Scripts.MasterBasicQuery);
|
||||
}
|
||||
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
[Fact]
|
||||
public async Task LongQueryResultSummaryOnAzureTest()
|
||||
{
|
||||
await QueryResultSummaryOnPremTest(TestServerType.Azure, Scripts.MasterLongQuery);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LongQueryResultFirstOnAzureTest()
|
||||
{
|
||||
await QueryResultFirstOnPremTest(TestServerType.Azure, Scripts.MasterLongQuery);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task CancelQueryOnPremTest()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
await testService.ConnectForQuery(serverType, Scripts.DelayQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
var queryParams = new ExecuteDocumentSelectionParams
|
||||
{
|
||||
OwnerUri = queryTempFile.FilePath,
|
||||
QuerySelection = null
|
||||
};
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
var result = await testService.Driver.SendRequest(ExecuteDocumentSelectionRequest.Type, queryParams);
|
||||
if (result != null)
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
TestTimer timer = new TestTimer() { PrintResult = true };
|
||||
await testService.ExecuteWithTimeout(timer, 100000, async () =>
|
||||
await testService.ConnectForQuery(serverType, Scripts.DelayQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
var queryParams = new ExecuteDocumentSelectionParams
|
||||
{
|
||||
var cancelQueryResult = await testService.CancelQuery(queryTempFile.FilePath);
|
||||
return true;
|
||||
}, TimeSpan.FromMilliseconds(10));
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.True(false, "Failed to run the query");
|
||||
}
|
||||
OwnerUri = queryTempFile.FilePath,
|
||||
QuerySelection = null
|
||||
};
|
||||
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
testService.WriteToFile(queryTempFile.FilePath, Scripts.MasterLongQuery);
|
||||
|
||||
var result = await testService.Driver.SendRequest(ExecuteDocumentSelectionRequest.Type, queryParams);
|
||||
if (result != null)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private async Task QueryResultSummaryOnPremTest(TestServerType serverType, string query, [CallerMemberName] string testName = "")
|
||||
{
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
|
||||
testService.WriteToFile(queryTempFile.FilePath, query);
|
||||
var queryResult = await testService.CalculateRunTime(
|
||||
() => testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, 50000),
|
||||
timer);
|
||||
|
||||
Assert.NotNull(queryResult);
|
||||
Assert.True(queryResult.BatchSummaries.Any(x => x.ResultSetSummaries.Any(r => r.RowCount > 0)));
|
||||
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
}, testName);
|
||||
}
|
||||
|
||||
private async Task QueryResultFirstOnPremTest(TestServerType serverType, string query, [CallerMemberName] string testName = "")
|
||||
{
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
|
||||
testService.WriteToFile(queryTempFile.FilePath, query);
|
||||
await testService.RunQueryAndWaitToStart(queryTempFile.FilePath, 50000);
|
||||
await testService.ExecuteWithTimeout(timer, 500000, async () =>
|
||||
{
|
||||
var queryResult = await testService.ExecuteSubset(queryTempFile.FilePath, 0, 0, 0, 100);
|
||||
if (queryResult != null)
|
||||
{
|
||||
Assert.NotNull(queryResult);
|
||||
Assert.NotNull(queryResult.ResultSubset);
|
||||
Assert.True(queryResult.ResultSubset.Rows.Any());
|
||||
}
|
||||
return queryResult != null;
|
||||
}, TimeSpan.FromMilliseconds(10));
|
||||
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
}, testName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,39 +14,45 @@ namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
[Fact]
|
||||
public async Task TestSaveResultsToCsvTest()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (SelfCleaningTempFile outputTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
const string query = Scripts.MasterBasicQuery;
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
// Execute a query
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
|
||||
await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, query);
|
||||
await testService.CalculateRunTime(() => testService.SaveAsCsv(queryTempFile.FilePath, outputTempFile.FilePath, 0, 0), true);
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (SelfCleaningTempFile outputTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
const string query = Scripts.MasterBasicQuery;
|
||||
|
||||
// Execute a query
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
|
||||
await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, query);
|
||||
await testService.CalculateRunTime(() => testService.SaveAsCsv(queryTempFile.FilePath, outputTempFile.FilePath, 0, 0), timer);
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestSaveResultsToJsonTest()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (SelfCleaningTempFile outputTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
const string query = Scripts.MasterBasicQuery;
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
|
||||
// Execute a query
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
|
||||
await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, query);
|
||||
await testService.CalculateRunTime(() => testService.SaveAsJson(queryTempFile.FilePath, outputTempFile.FilePath, 0, 0), true);
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
using (SelfCleaningTempFile outputTempFile = new SelfCleaningTempFile())
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
{
|
||||
const string query = Scripts.MasterBasicQuery;
|
||||
|
||||
// Execute a query
|
||||
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
|
||||
await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, query);
|
||||
await testService.CalculateRunTime(() => testService.SaveAsJson(queryTempFile.FilePath, outputTempFile.FilePath, 0, 0), timer);
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// 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.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.PerfTests
|
||||
{
|
||||
public class ScriptingTests
|
||||
{
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.Azure)]
|
||||
public async Task ScripTableAzure()
|
||||
{
|
||||
TestServerType serverType = TestServerType.Azure;
|
||||
await VerifyScriptTable(serverType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[CreateTestDb(TestServerType.OnPrem)]
|
||||
public async Task ScripTableOnPrem()
|
||||
{
|
||||
TestServerType serverType = TestServerType.OnPrem;
|
||||
await VerifyScriptTable(serverType);
|
||||
}
|
||||
|
||||
|
||||
private async Task VerifyScriptTable(TestServerType serverType, [CallerMemberName] string testName = "")
|
||||
{
|
||||
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
|
||||
{
|
||||
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
await testService.ConnectForQuery(serverType, string.Empty, queryTempFile.FilePath, Common.PerfTestDatabaseName);
|
||||
List<ScriptingObject> scriptingObjects = new List<ScriptingObject>()
|
||||
{
|
||||
new ScriptingObject
|
||||
{
|
||||
Schema = "Person",
|
||||
Name = "Address",
|
||||
Type = "Table"
|
||||
}
|
||||
};
|
||||
ScriptingParams scriptingParams = new ScriptingParams
|
||||
{
|
||||
OwnerUri = queryTempFile.FilePath,
|
||||
Operation = ScriptingOperationType.Create,
|
||||
FilePath = queryTempFile.FilePath,
|
||||
ScriptOptions = new ScriptOptions
|
||||
{
|
||||
ScriptCreateDrop = "ScriptCreate",
|
||||
},
|
||||
ScriptDestination = "ToEditor",
|
||||
ScriptingObjects = scriptingObjects
|
||||
|
||||
};
|
||||
var result = await testService.CalculateRunTime(() => testService.RequestScript(scriptingParams), timer);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Script);
|
||||
|
||||
Assert.False(string.IsNullOrEmpty(result.Script), "Script result is invalid");
|
||||
|
||||
await testService.Disconnect(queryTempFile.FilePath);
|
||||
}
|
||||
}, testName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user