public async Task ConnectOnPremTest() { TestServerType serverType = TestServerType.OnPrem; using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { const string query = Scripts.TestDbSimpleSelectQuery; testService.WriteToFile(queryTempFile.FilePath, query); DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification { TextDocument = new TextDocumentItem { Uri = queryTempFile.FilePath, LanguageId = "enu", Version = 1, Text = query } }; 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"); } }
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, 50); 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); }
private async Task VerifyCompletationLoaded( TestServiceDriverProvider testService, TestServerType serverType, string query, string databaseName, 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, databaseName, waitForIntelliSense : true, timer : timer, testName : testName); await testService.Disconnect(testTempFile.FilePath); } }
public async Task CompletionTest() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { string query = "SELECT * FROM sys.objects"; testService.WriteToFile(queryTempFile.FilePath, query); DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification { TextDocument = new TextDocumentItem { Uri = queryTempFile.FilePath, LanguageId = "enu", Version = 1, Text = query } }; await testService.RequestOpenDocumentNotification(openParams); Thread.Sleep(500); bool connected = await testService.Connect(TestServerType.OnPrem, queryTempFile.FilePath); Assert.True(connected, "Connection is successful"); Thread.Sleep(10000); CompletionItem[] completions = await testService.RequestCompletion(queryTempFile.FilePath, query, 0, 15); Assert.True(completions != null && completions.Length > 0, "Completion items list is null or empty"); Thread.Sleep(50); await testService.RequestResolveCompletion(completions[0]); Assert.True(completions != null && completions.Length > 0, "Completion items list is null or empty"); await testService.Disconnect(queryTempFile.FilePath); } }
public async Task DefinitionTest() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { string query = "SELECT * FROM sys.objects"; int lineNumber = 0; int position = 23; testService.WriteToFile(queryTempFile.FilePath, query); DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification { TextDocument = new TextDocumentItem { Uri = queryTempFile.FilePath, LanguageId = "enu", Version = 1, Text = query } }; await testService.RequestOpenDocumentNotification(openParams); Thread.Sleep(500); bool connected = await testService.Connect(TestServerType.OnPrem, queryTempFile.FilePath); // Wait for intellisense to be ready var readyParams = await testService.Driver.WaitForEvent(IntelliSenseReadyNotification.Type, 30000); Assert.NotNull(readyParams); Assert.True(connected, "Connection is successful"); // Request definition for "objects" Location[] locations = await testService.RequestDefinition(queryTempFile.FilePath, query, lineNumber, position); Assert.True(locations != null, "Location is not null and not empty"); 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); }
public async Task HoverTest() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { string query = "SELECT * FROM sys.objects"; testService.WriteToFile(queryTempFile.FilePath, query); DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification { TextDocument = new TextDocumentItem { Uri = queryTempFile.FilePath, LanguageId = "enu", Version = 1, Text = query } }; await testService.RequestOpenDocumentNotification(openParams); Thread.Sleep(500); bool connected = await testService.Connect(TestServerType.OnPrem, queryTempFile.FilePath); Assert.True(connected, "Connection was not successful"); Thread.Sleep(10000); Hover hover = await testService.RequestHover(queryTempFile.FilePath, query, 0, 15); Assert.True(hover != null, "Hover tooltop is null"); await testService.Disconnect(queryTempFile.FilePath); } }
public async Task CancelQueryOnPremTest() { await TestServiceDriverProvider.RunTestIterations(async (timer) => { 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 }; 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); } } }); }