Skip to content

Commit

Permalink
Revert changes to tests which should not rely on pool and its disable…
Browse files Browse the repository at this point in the history
…d state
  • Loading branch information
sfc-gh-mhofman committed Oct 9, 2023
1 parent 0521968 commit 1962320
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 44 deletions.
24 changes: 0 additions & 24 deletions Snowflake.Data.Tests/IntegrationTests/PoolConfigRestorer.cs

This file was deleted.

18 changes: 1 addition & 17 deletions Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,16 @@ namespace Snowflake.Data.Tests.IntegrationTests
using Snowflake.Data.Tests.Mock;
using System.Runtime.InteropServices;

[TestFixture, NonParallelizable]
[TestFixture]
class SFConnectionIT : SFBaseTest
{
private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger<SFConnectionIT>();
private static readonly PoolConfigRestorer s_previousPoolConfig = new PoolConfigRestorer();

[SetUp]
public void BeforeTest()
{
s_previousPoolConfig.Reset();
SnowflakeDbConnectionPool.ClearAllPools();
}

[TearDown]
public void AfterTest()
{
s_previousPoolConfig.Reset();
}
[Test]
public void TestBasicConnection()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
SnowflakeDbConnectionPool.SetPooling(false);
conn.ConnectionString = ConnectionString;
conn.Open();
Assert.AreEqual(ConnectionState.Open, conn.State);
Expand Down Expand Up @@ -150,7 +136,6 @@ public void TestIncorrectUserOrPasswordBasicConnection()
[TestCase(false)]
public void TestConnectionIsNotMarkedAsOpenWhenWasNotCorrectlyOpenedBefore(bool explicitClose)
{
SnowflakeDbConnectionPool.SetPooling(true);
for (int i = 0; i < 2; ++i)
{
s_logger.Debug($"Running try #{i}");
Expand Down Expand Up @@ -1902,7 +1887,6 @@ public void TestCloseAsync()
[Test, NonParallelizable]
public void TestCloseAsyncFailure()
{
SnowflakeDbConnectionPool.SetPooling(false);
using (var conn = new MockSnowflakeDbConnection(new MockCloseSessionException()))
{
conn.ConnectionString = ConnectionString;
Expand Down
26 changes: 23 additions & 3 deletions Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,32 @@ namespace Snowflake.Data.Tests.IntegrationTests
using Snowflake.Data.Tests.Mock;
using System.Data.Common;
using Moq;

class PoolConfig {
private readonly bool _pooling;
private readonly long _timeout;
private readonly int _maxPoolSize;

public PoolConfig()
{
_maxPoolSize = SnowflakeDbConnectionPool.GetMaxPoolSize();
_timeout = SnowflakeDbConnectionPool.GetTimeout();
_pooling = SnowflakeDbConnectionPool.GetPooling();
}

public void Reset()
{
SnowflakeDbConnectionPool.SetMaxPoolSize(_maxPoolSize);
SnowflakeDbConnectionPool.SetTimeout(_timeout);
SnowflakeDbConnectionPool.SetPooling(_pooling);
}
}

[TestFixture, NonParallelizable]
class SFConnectionPoolT : SFBaseTest
{
private static readonly PoolConfigRestorer s_previousPoolConfig = new PoolConfigRestorer();

private static readonly PoolConfig s_previousPoolConfig = new PoolConfig();
[SetUp]
public void BeforeTest()
{
Expand Down Expand Up @@ -414,7 +434,7 @@ public void TestConnectionPoolTurnOff()
class SFConnectionPoolITAsync : SFBaseTestAsync
{
private static SFLogger logger = SFLoggerFactory.GetLogger<SFConnectionPoolITAsync>();
private static readonly PoolConfigRestorer s_previousPoolConfigRestorer = new PoolConfigRestorer();
private static readonly PoolConfig s_previousPoolConfigRestorer = new PoolConfig();

[SetUp]
public void BeforeTest()
Expand Down

0 comments on commit 1962320

Please sign in to comment.