コード例 #1
0
        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);
        }
コード例 #2
0
        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 testService.ConnectForQuery(serverType, Scripts.TestDbSimpleSelectQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName);

                    Thread.Sleep(500);
                    var contentChanges = new TextDocumentChangeEvent[1];
                    contentChanges[0] = new TextDocumentChangeEvent()
                    {
                        Range = new Range
                        {
                            Start = new Position
                            {
                                Line      = 0,
                                Character = 5
                            },
                            End = new Position
                            {
                                Line      = 0,
                                Character = 6
                            }
                        },
                        RangeLength = 1,
                        Text        = "z"
                    };
                    DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams
                    {
                        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);
                }
        }
コード例 #3
0
 private static async Task ValidateCompletionResponse(
     TestServiceDriverProvider testService,
     string ownerUri,
     string databaseName,
     bool waitForIntelliSense,
     TestTimer timer = null,
     [CallerMemberName] string testName = "")
 {
     if (timer == null)
     {
         timer = new TestTimer {
             PrintResult = false
         };
     }
     bool isReady = !waitForIntelliSense;
     await testService.ExecuteWithTimeout(timer, 550000, async() =>
     {
         if (isReady)
         {
             string query = Scripts.SelectQuery;
             CompletionItem[] completions = await testService.RequestCompletion(ownerUri, query, 0, query.Length + 1);
             return(completions != null &&
                    (completions.Any(x => string.Compare(x.Label, databaseName, StringComparison.OrdinalIgnoreCase) == 0 ||
                                     string.Compare(x.Label, $"[{databaseName}]", StringComparison.OrdinalIgnoreCase) == 0 ||
                                     string.Compare(x.Label, $"\"{databaseName}\"", StringComparison.OrdinalIgnoreCase) == 0)));
         }
         else
         {
             var completeEvent = await testService.Driver.WaitForEvent(IntelliSenseReadyNotification.Type, 100000);
             isReady           = completeEvent.OwnerUri == ownerUri;
             if (isReady)
             {
                 Console.WriteLine("IntelliSense cache is loaded.");
             }
             return(false);
         }
     }, testName : testName);
 }
コード例 #4
0
        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);
                }
        }