-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e7e029
commit b81599d
Showing
9 changed files
with
267 additions
and
79 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsAsyncIT.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using Snowflake.Data.Client; | ||
using Snowflake.Data.Core.Session; | ||
using Snowflake.Data.Tests.Util; | ||
|
||
namespace Snowflake.Data.Tests.IntegrationTests | ||
{ | ||
[TestFixture] | ||
[NonParallelizable] | ||
public class ConnectionMultiplePoolsAsyncIT: SFBaseTestAsync | ||
{ | ||
private readonly PoolConfig _previousPoolConfig = new PoolConfig(); | ||
|
||
[SetUp] | ||
public new void BeforeTest() | ||
{ | ||
SnowflakeDbConnectionPool.SetConnectionPoolVersion(ConnectionPoolType.MultipleConnectionPool); | ||
SnowflakeDbConnectionPool.ClearAllPools(); | ||
SnowflakeDbConnectionPool.SetPooling(true); | ||
} | ||
|
||
[TearDown] | ||
public new void AfterTest() | ||
{ | ||
_previousPoolConfig.Reset(); | ||
} | ||
|
||
[Test] | ||
public async Task TestMinPoolSizeAsync() | ||
{ | ||
// arrange | ||
var connection = new SnowflakeDbConnection(); | ||
connection.ConnectionString = ConnectionString + "application=TestMinPoolSizeAsync;minPoolSize=3"; | ||
|
||
// act | ||
await connection.OpenAsync().ConfigureAwait(false); | ||
Thread.Sleep(3000); | ||
|
||
// assert | ||
var pool = SnowflakeDbConnectionPool.GetPool(connection.ConnectionString); | ||
Assert.AreEqual(3, pool.GetCurrentPoolSize()); | ||
|
||
// cleanup | ||
await connection.CloseAsync(CancellationToken.None).ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Snowflake.Data.Tests/UnitTests/Session/SessionOrCreationTokensTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using Snowflake.Data.Core; | ||
using Snowflake.Data.Core.Session; | ||
|
||
namespace Snowflake.Data.Tests.UnitTests.Session | ||
{ | ||
[TestFixture] | ||
public class SessionOrCreationTokensTest | ||
{ | ||
private SFSession _session = new SFSession("account=test;user=test;password=test", null); | ||
|
||
[Test] | ||
public void TestNoBackgroundSessionsToCreateWhenInitialisedWithSession() | ||
{ | ||
// arrange | ||
var sessionOrTokens = new SessionOrCreationTokens(_session); | ||
|
||
// act | ||
var backgroundCreationTokens = sessionOrTokens.BackgroundSessionCreationTokens(); | ||
|
||
Assert.AreEqual(0, backgroundCreationTokens.Count); | ||
} | ||
|
||
[Test] | ||
public void TestReturnFirstCreationToken() | ||
{ | ||
// arrange | ||
var sessionCreationTokenCounter = new SessionCreationTokenCounter(TimeSpan.FromSeconds(10)); | ||
var tokens = Enumerable.Range(1, 3) | ||
.Select(_ => sessionCreationTokenCounter.NewToken()) | ||
.ToList(); | ||
var sessionOrTokens = new SessionOrCreationTokens(tokens); | ||
|
||
// act | ||
var token = sessionOrTokens.SessionCreationToken(); | ||
|
||
// assert | ||
Assert.AreSame(tokens[0], token); | ||
} | ||
|
||
[Test] | ||
public void TestReturnCreationTokensFromTheSecondOneForBackgroundExecution() | ||
{ | ||
// arrange | ||
var sessionCreationTokenCounter = new SessionCreationTokenCounter(TimeSpan.FromSeconds(10)); | ||
var tokens = Enumerable.Range(1, 3) | ||
.Select(_ => sessionCreationTokenCounter.NewToken()) | ||
.ToList(); | ||
var sessionOrTokens = new SessionOrCreationTokens(tokens); | ||
|
||
// act | ||
var backgroundTokens = sessionOrTokens.BackgroundSessionCreationTokens(); | ||
|
||
// assert | ||
Assert.AreEqual(2, backgroundTokens.Count); | ||
Assert.AreSame(tokens[1], backgroundTokens[0]); | ||
Assert.AreSame(tokens[2], backgroundTokens[1]); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.