Skip to content

Commit

Permalink
clean debug changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Jan 4, 2024
1 parent a01a485 commit ee2f57c
Show file tree
Hide file tree
Showing 14 changed files with 5 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using NUnit.Framework;
using Snowflake.Data.Client;
using Snowflake.Data.Core.Session;
using Snowflake.Data.Log;
using Snowflake.Data.Tests.Util;

namespace Snowflake.Data.Tests.IntegrationTests
Expand All @@ -15,7 +14,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
public class ConnectionMultiplePoolsIT: SFBaseTest
{
private readonly PoolConfig _previousPoolConfig = new PoolConfig();
private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger<ConnectionMultiplePoolsIT>();

[SetUp]
public new void BeforeTest()
Expand Down Expand Up @@ -121,7 +119,6 @@ public void TestWaitForTheIdleConnectionWhenExceedingMaxConnectionsLimit()
watch.Stop();

// assert
s_logger.Warn($"TestWaitForTheIdleConnectionWhenExceedingMaxConnectionsLimit - start at: {start}, stop at: {stop}");
Assert.That(thrown.Message, Does.Contain("Unable to connect. Could not obtain a connection from the pool within a given timeout"));
Assert.GreaterOrEqual(watch.ElapsedMilliseconds, 1000);
Assert.LessOrEqual(watch.ElapsedMilliseconds, 1500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace Snowflake.Data.Tests
{

[TestFixture]
[Ignore("temporary disabled to debug problem with tests")]
public class FileUploadDownloadLargeFilesIT : SFBaseTest
{
private const string FileName = "large_file_to_test_dotnet_driver.json";
Expand Down
1 change: 0 additions & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFBindTestIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
using System.Collections.Generic;

[TestFixture]
[Ignore("temporary disabled to debug problem with tests")]
class SFBindTestIT : SFBaseTest
{
[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
namespace Snowflake.Data.Tests.IntegrationTests
{
[TestFixture, NonParallelizable]
[Ignore("temporary disabled to debug problem with tests")]
class SFConnectionPoolITAsync : SFBaseTestAsync
{
private static PoolConfig s_previousPoolConfigRestorer;
Expand Down
1 change: 0 additions & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFDbAdaptorIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
using System.Runtime.InteropServices;

[TestFixture]
[Ignore("temporary disabled to debug problem with tests")]
class SFDbAdaptorIT : SFBaseTest
{
private IDbDataAdapter _adapter;
Expand Down
1 change: 0 additions & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFDbCommandIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
using Snowflake.Data.Core;

[TestFixture]
[Ignore("temporary disabled to debug problem with tests")]
class SFDbCommandITAsync : SFBaseTestAsync
{
[Test]
Expand Down
1 change: 0 additions & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
// TODO: enable tests for Arrow
//[TestFixture(ResultFormat.ARROW)]
[TestFixture(ResultFormat.JSON)]
[Ignore("temporary disabled to debug problem with tests")]
class SFDbDataReaderIT : SFBaseTest
{
protected override string TestName => base.TestName + _resultFormat;
Expand Down
1 change: 0 additions & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFDbFactoryIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
using System.Data.Common;

[TestFixture]
[Ignore("temporary disabled to debug problem with tests")]
class SFDbFactoryIT : SFBaseTest
{
DbProviderFactory _factory;
Expand Down
1 change: 0 additions & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFDbTransactionIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
using System.Threading.Tasks;

[TestFixture]
[Ignore("temporary disabled to debug problem with tests")]
class SFDbTransactionIT : SFBaseTest
{
[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
using NUnit.Framework;

[TestFixture]
[Ignore("temporary disabled to debug problem with tests")]
class SFMultiStatementsIT : SFBaseTest
{
[Test]
Expand Down
1 change: 0 additions & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFPutGetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Snowflake.Data.Tests.IntegrationTests

[TestFixture]
[Parallelizable(ParallelScope.Children)]
[Ignore("temporary disabled to debug problem with tests")]
class SFPutGetTest : SFBaseTest
{
private const int NumberOfRows = 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
using System.Threading.Tasks;

[TestFixture, NonParallelizable]
[Ignore("temporary disabled to debug problem with tests")]
class SFReusableChunkTest : SFBaseTest
{
[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Snowflake.Data.Tests.IntegrationTests
using System.Data.Common;

[TestFixture]
[Ignore("temporary disabled to debug problem with tests")]
class SFStatementTypeTest : SFBaseTest
{
[Test]
Expand Down
18 changes: 5 additions & 13 deletions Snowflake.Data/Core/Session/SessionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,42 +181,34 @@ private bool IsAllowedToCreateNewSession()
private SFSession WaitForSession(string connStr)
{
var timeout = _waitingQueue.GetWaitingTimeoutMillis();
s_logger.Warn($"SessionPool::WaitForSession for {timeout} millis timeout");
s_logger.Debug($"SessionPool::WaitForSession for {timeout} millis timeout");
_sessionPoolEventHandler.OnWaitingForSessionStarted(this);
var beforeWaitingTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
string debugApplicationName = "";
if (connStr.EndsWith("application=TestWaitForMaxSize1"))
debugApplicationName = "TestWaitForMaxSize1";
if (connStr.EndsWith("application=TestWaitForMaxSize2"))
debugApplicationName = "TestWaitForMaxSize2";
if (connStr.EndsWith("application=TestWaitForMaxSize3"))
debugApplicationName = "TestWaitForMaxSize3";
s_logger.Warn($"Wait for session started at: {beforeWaitingTime} for: {debugApplicationName}");
long nowTime = beforeWaitingTime;
while (nowTime < beforeWaitingTime + timeout) // we loop to handle the case if someone overtook us after being woken or session which we were promised has just expired
{
var timeoutLeft = beforeWaitingTime + timeout - nowTime;
var successful = _waitingQueue.Wait((int) timeoutLeft, CancellationToken.None);
if (successful)
{
s_logger.Warn($"SessionPool::WaitForSession - woken with a session granted for: {debugApplicationName} at: {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
s_logger.Debug($"SessionPool::WaitForSession - woken with a session granted");
lock (_sessionPoolLock)
{
var session = ExtractIdleSession(connStr);
if (session != null)
{
s_logger.Warn($"SessionPool::WaitForSession - a session was extracted from idle sessions for: {debugApplicationName}");
s_logger.Debug($"SessionPool::WaitForSession - a session was extracted from idle sessions");
return session;
}
}
}
else
{
s_logger.Warn($"SessionPool::WaitForSession - woken without a session granted for: {debugApplicationName}");
s_logger.Debug($"SessionPool::WaitForSession - woken without a session granted");
}
nowTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
}
s_logger.Warn($"SessionPool::WaitForSession - could not find any idle session available withing a given timeout for: {debugApplicationName} at: {nowTime}");
s_logger.Debug($"SessionPool::WaitForSession - could not find any idle session available withing a given timeout");
throw WaitingFailedException();
}

Expand Down

0 comments on commit ee2f57c

Please sign in to comment.