Exemplo n.º 1
0
        public async Task ConnectOnPremTest()
        {
            await TestServiceDriverProvider.RunTestIterations(async (timer) =>
            {
                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));
                        }, timer);
                        Assert.True(connected, "Connection was not successful");
                    }
            });
        }
Exemplo n.º 2
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);
        }
 public async Task BindingCacheColdOnPremComplexQuery()
 {
     await TestServiceDriverProvider.RunTestIterations(async (timer) =>
     {
         TestServerType serverType = TestServerType.OnPrem;
         using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
         {
             await VerifyBindingLoadScenario(testService, serverType, Scripts.TestDbComplexSelectQueries, false, timer);
         }
     });
 }
        public async Task DiagnosticsTests()
        {
            await TestServiceDriverProvider.RunTestIterations(async (timer) =>
            {
                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
                            }
                        };

                        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);
                    }
            });
        }
 public async Task BindingCacheWarmOnPremComplexQuery()
 {
     await TestServiceDriverProvider.RunTestIterations(async (timer) =>
     {
         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);
             }
     });
 }
 public async Task BindingCacheWarmAzureSimpleQuery()
 {
     await TestServiceDriverProvider.RunTestIterations(async (timer) =>
     {
         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);
             }
     });
 }
Exemplo n.º 7
0
        public async Task DisconnectTest()
        {
            await TestServiceDriverProvider.RunTestIterations(async (timer) =>
            {
                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);
                    }
            });
        }
 public async Task SuggestionsTest()
 {
     await TestServiceDriverProvider.RunTestIterations(async (timer) =>
     {
         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);
             }
     });
 }
 public async Task HoverTestOnPrem()
 {
     await TestServiceDriverProvider.RunTestIterations(async (timer) =>
     {
         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);
             }
     });
 }
Exemplo n.º 10
0
        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 TestSaveResultsToJsonTest()
        {
            await TestServiceDriverProvider.RunTestIterations(async (timer) =>
            {
                TestServerType serverType = TestServerType.OnPrem;

                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);
                        }
            });
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
                        }
                    }
            });
        }