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"); } }
/// <summary> /// Repeatedly connect and disconnect to stress test the connection service. /// </summary> //[Fact] public async Task TestConnectionService() { string ownerUri = "file:///my/test/file.sql"; using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { var connection = testService.GetConnectionParameters(TestServerType.OnPrem); connection.Connection.Pooling = false; // Connect/disconnect repeatedly Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (stopwatch.Elapsed < TimeSpan.FromMinutes(60)) { // Connect bool connected = await testService.Connect(ownerUri, connection); Assert.True(connected, "Connection is successful"); // Disconnect bool disconnected = await testService.Disconnect(ownerUri); Assert.True(disconnected, "Disconnect is successful"); } } }