示例#1
0
        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);
                }
        }
示例#2
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);
        }
示例#3
0
        public async Task TestSaveResultsToJsonTest()
        {
            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), true);

                        await testService.Disconnect(queryTempFile.FilePath);
                    }
        }
示例#4
0
        /// <summary>
        /// Repeatedly execute queries to stress test the query execution service.
        /// </summary>
        //[Fact]
        public async Task TestQueryExecutionService()
        {
            const string queryToRun = "SELECT * FROM sys.all_objects GO " +
                                      "SELECT * FROM sys.objects GO " +
                                      "SELECT * FROM sys.tables GO " +
                                      "SELECT COUNT(*) FROM sys.objects";

            using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
                using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
                {
                    // Connect
                    bool connected = await testService.Connect(TestServerType.OnPrem, string.Empty, queryTempFile.FilePath);

                    Assert.True(connected, "Connection is successful");

                    // Run queries repeatedly
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    while (stopwatch.Elapsed < TimeSpan.FromMinutes(60))
                    {
                        var queryResult = await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, queryToRun, 10000);

                        Assert.NotNull(queryResult);
                        Assert.NotNull(queryResult.BatchSummaries);
                        Assert.NotEmpty(queryResult.BatchSummaries);
                        Assert.NotNull(queryResult.BatchSummaries[0].ResultSetSummaries);
                        Assert.NotNull(queryResult.BatchSummaries[1].ResultSetSummaries);
                        Assert.NotNull(queryResult.BatchSummaries[2].ResultSetSummaries);
                        Assert.NotNull(queryResult.BatchSummaries[3].ResultSetSummaries);

                        Assert.NotNull(await testService.ExecuteSubset(queryTempFile.FilePath, 0, 0, 0, 7));
                        Assert.NotNull(await testService.ExecuteSubset(queryTempFile.FilePath, 1, 0, 0, 7));
                        Assert.NotNull(await testService.ExecuteSubset(queryTempFile.FilePath, 2, 0, 0, 7));
                        Assert.NotNull(await testService.ExecuteSubset(queryTempFile.FilePath, 3, 0, 0, 1));

                        Thread.Sleep(500);
                    }

                    await testService.Disconnect(queryTempFile.FilePath);
                }
        }
示例#5
0
        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);
                }
        }