Skip to content

Commit

Permalink
Make command IT not interfere with each other
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Apr 23, 2024
1 parent e0ac1fb commit d8b3be2
Showing 1 changed file with 41 additions and 54 deletions.
95 changes: 41 additions & 54 deletions Snowflake.Data.Tests/IntegrationTests/SFDbCommandIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ class SFDbCommandITAsync : SFBaseTestAsync
[Test]
public void TestExecAsyncAPI()
{
SnowflakeDbConnectionPool.ClearAllPools();
using (DbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

Task connectTask = conn.OpenAsync(CancellationToken.None);
connectTask.Wait();
Expand Down Expand Up @@ -63,10 +62,9 @@ public void TestExecAsyncAPI()
[Test]
public void TestExecAsyncAPIParallel()
{
SnowflakeDbConnectionPool.ClearAllPools();
using (DbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

Task connectTask = conn.OpenAsync(CancellationToken.None);
connectTask.Wait();
Expand Down Expand Up @@ -112,8 +110,7 @@ public void TestCancelExecuteAsync()

using (DbConnection conn = new SnowflakeDbConnection())
{
SnowflakeDbConnectionPool.ClearAllPools();
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";;

conn.Open();

Expand Down Expand Up @@ -185,7 +182,7 @@ public async Task TestAsyncExecQueryAsync()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
await conn.OpenAsync(CancellationToken.None).ConfigureAwait(false);

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand Down Expand Up @@ -224,7 +221,7 @@ public async Task TestExecuteNormalQueryWhileAsyncExecQueryIsRunningAsync()
SnowflakeDbConnection[] connections = new SnowflakeDbConnection[3];
for (int i = 0; i < connections.Length; i++)
{
connections[i] = new SnowflakeDbConnection(ConnectionString);
connections[i] = new SnowflakeDbConnection(ConnectionString + "poolingEnabled=false");
await connections[i].OpenAsync(CancellationToken.None).ConfigureAwait(false);
}

Expand Down Expand Up @@ -279,7 +276,7 @@ public async Task TestAsyncExecCancelWhileGettingResultsAsync()
{
using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";;
await conn.OpenAsync(CancellationToken.None).ConfigureAwait(false);

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand Down Expand Up @@ -313,7 +310,7 @@ public async Task TestFailedAsyncExecQueryThrowsErrorAsync()
{
using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
await conn.OpenAsync(CancellationToken.None).ConfigureAwait(false);

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand Down Expand Up @@ -355,7 +352,7 @@ public async Task TestGetStatusOfInvalidQueryIdAsync()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
await conn.OpenAsync(CancellationToken.None).ConfigureAwait(false);

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand All @@ -379,7 +376,7 @@ public async Task TestGetResultsOfInvalidQueryIdAsync()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
await conn.OpenAsync(CancellationToken.None).ConfigureAwait(false);

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand All @@ -403,7 +400,7 @@ public async Task TestGetStatusOfUnknownQueryIdAsync()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
await conn.OpenAsync(CancellationToken.None).ConfigureAwait(false);

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand All @@ -427,7 +424,7 @@ public async Task TestGetResultsOfUnknownQueryIdAsyncWithDefaultRetry()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
await conn.OpenAsync(CancellationToken.None).ConfigureAwait(false);

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand All @@ -453,7 +450,7 @@ public async Task TestGetResultsOfUnknownQueryIdAsyncWithConfiguredRetry()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
await conn.OpenAsync(CancellationToken.None).ConfigureAwait(false);

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand Down Expand Up @@ -482,7 +479,7 @@ public void TestLongRunningQuery()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

conn.Open();

Expand All @@ -501,7 +498,7 @@ public void TestLongRunningQuery()
[Ignore("This test case takes too much time so run it manually")]
public void TestRowsAffectedOverflowInt()
{
using (IDbConnection conn = new SnowflakeDbConnection(ConnectionString))
using (IDbConnection conn = new SnowflakeDbConnection(ConnectionString + "poolingEnabled=false"))
{
conn.Open();

Expand All @@ -527,7 +524,7 @@ public void TestSimpleCommand()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

conn.Open();
IDbCommand cmd = conn.CreateCommand();
Expand Down Expand Up @@ -590,7 +587,7 @@ public void TestSimpleLargeResultSet()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

conn.Open();

Expand All @@ -610,18 +607,10 @@ public void TestSimpleLargeResultSet()
}
}

[Test]
public void DummyTest()
{
var conn = new SnowflakeDbConnection(ConnectionString);
conn.Close();
conn.Close();
}

[Test, NonParallelizable]
public void TestUseV1ResultParser()
{
var connectionString = ConnectionString + "application=v1resultParser";
var connectionString = ConnectionString + "poolingEnabled=false";
var chunkParserVersion = SFConfiguration.Instance().ChunkParserVersion;
int chunkDownloaderVersion = SFConfiguration.Instance().ChunkDownloaderVersion;
SFConfiguration.Instance().ChunkParserVersion = 1;
Expand Down Expand Up @@ -651,7 +640,7 @@ public void TestUseV1ResultParser()
[Test, NonParallelizable]
public void TestUseV2ChunkDownloader()
{
var connectionString = ConnectionString + "application=v2chunkDownloader";
var connectionString = ConnectionString + "poolingEnabled=false";
var chunkParserVersion = SFConfiguration.Instance().ChunkParserVersion;
int chunkDownloaderVersion = SFConfiguration.Instance().ChunkDownloaderVersion;
SFConfiguration.Instance().ChunkParserVersion = 2;
Expand Down Expand Up @@ -682,7 +671,7 @@ public void TestUseV2ChunkDownloader()
[Parallelizable(ParallelScope.Children)]
public void TestDefaultChunkDownloaderWithPrefetchThreads([Values(1, 2, 4)] int prefetchThreads)
{
using (SnowflakeDbConnection conn = new SnowflakeDbConnection(ConnectionString))
using (SnowflakeDbConnection conn = new SnowflakeDbConnection(ConnectionString + "poolingEnabled=false"))
{
conn.Open();

Expand Down Expand Up @@ -710,7 +699,7 @@ public void TestDataSourceError()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

conn.Open();

Expand All @@ -736,7 +725,7 @@ public void TestCancelQuery()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

conn.Open();

Expand Down Expand Up @@ -791,7 +780,7 @@ public void TestQueryTimeout()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

conn.Open();

Expand Down Expand Up @@ -828,7 +817,7 @@ public void TestTransaction()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

conn.Open();

Expand Down Expand Up @@ -897,7 +886,7 @@ public void TestRowsAffected()

using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";

conn.Open();

Expand All @@ -920,7 +909,7 @@ public void TestExecuteScalarNull()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (IDbCommand command = conn.CreateCommand())
Expand Down Expand Up @@ -994,7 +983,7 @@ public void TestRowsAffectedUnload()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (IDbCommand command = conn.CreateCommand())
Expand Down Expand Up @@ -1026,7 +1015,7 @@ public void TestRowsAffectedUnload()
//[Ignore("Ignore flaky unstable test case for now. Will revisit later and sdk issue created (210)")]
public void testPutArrayBindAsync()
{
ArrayBindTest(ConnectionString, TableName, 15000);
ArrayBindTest(ConnectionString + "poolingEnabled=false", TableName, 15000);
}

private void ArrayBindTest(string connstr, string tableName, int size)
Expand Down Expand Up @@ -1166,8 +1155,8 @@ public void TestPutArrayBindAsyncMultiThreading()
var t1TableName = TableName + 1;
var t2TableName = TableName + 2;

Thread t1 = new Thread(() => ThreadProcess1(ConnectionString, t1TableName));
Thread t2 = new Thread(() => ThreadProcess2(ConnectionString, t2TableName));
Thread t1 = new Thread(() => ThreadProcess1(ConnectionString + "poolingEnabled=false", t1TableName));
Thread t2 = new Thread(() => ThreadProcess2(ConnectionString + "poolingEnabled=false", t2TableName));
//Thread t3 = new Thread(() => ThreadProcess3(ConnectionString));
//Thread t4 = new Thread(() => ThreadProcess4(ConnectionString));

Expand Down Expand Up @@ -1205,7 +1194,7 @@ public void testExecuteScalarAsyncSelect()
CancellationTokenSource externalCancel = new CancellationTokenSource();
using (DbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

CreateOrReplaceTable(conn, TableName, new []{"cola INTEGER"});
Expand Down Expand Up @@ -1245,9 +1234,7 @@ public void testExecuteLargeQueryWithGcsDownscopedToken()
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString
+ String.Format(
";GCS_USE_DOWNSCOPED_CREDENTIAL=true");
conn.ConnectionString = ConnectionString + "GCS_USE_DOWNSCOPED_CREDENTIAL=true;poolingEnabled=false";
conn.Open();

int rowCount = 100000;
Expand All @@ -1266,7 +1253,7 @@ public void TestGetQueryId()
{
using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

// query id is null when no query executed
Expand Down Expand Up @@ -1355,7 +1342,7 @@ public void TestAsyncExecQuery()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand Down Expand Up @@ -1393,7 +1380,7 @@ public void TestExecuteNormalQueryWhileAsyncExecQueryIsRunning()
SnowflakeDbConnection[] connections = new SnowflakeDbConnection[3];
for (int i = 0; i < connections.Length; i++)
{
connections[i] = new SnowflakeDbConnection(ConnectionString);
connections[i] = new SnowflakeDbConnection(ConnectionString + "poolingEnabled=false");
connections[i].Open();
}

Expand Down Expand Up @@ -1448,7 +1435,7 @@ public void TestFailedAsyncExecQueryThrowsError()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand Down Expand Up @@ -1485,7 +1472,7 @@ public void TestAsyncExecQueryPutGetThrowsNotImplemented()
{
using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand Down Expand Up @@ -1520,7 +1507,7 @@ public void TestGetStatusOfInvalidQueryId()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand All @@ -1543,7 +1530,7 @@ public void TestGetResultsOfInvalidQueryId()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand All @@ -1566,7 +1553,7 @@ public void TestGetStatusOfUnknownQueryId()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand All @@ -1590,7 +1577,7 @@ public void TestGetResultsOfUnknownQueryIdWithDefaultRetry()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand All @@ -1615,7 +1602,7 @@ public void TestGetResultsOfUnknownQueryIdWithConfiguredRetry()

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString;
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
Expand Down

0 comments on commit d8b3be2

Please sign in to comment.