Skip to content

Commit

Permalink
Merge branch 'master' into SNOW-1488701_read_structured_types_json
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-lf authored Aug 21, 2024
2 parents 1ec6d5e + 3707fa0 commit 14476a2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
39 changes: 39 additions & 0 deletions Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,45 @@ public void TestUseMultiplePoolsConnectionPoolByDefault()
// assert
Assert.AreEqual(ConnectionPoolType.MultipleConnectionPool, poolVersion);
}

[Test]
[TestCase("connection_timeout=5;")]
[TestCase("")]
public void TestOpenAsyncThrowExceptionWhenConnectToUnreachableHost(string extraParameters)
{
// arrange
var connectionString = "account=testAccount;user=testUser;password=testPassword;useProxy=true;proxyHost=no.such.pro.xy;proxyPort=8080;" +
extraParameters;
using (var connection = new SnowflakeDbConnection(connectionString))
{
// act
var thrown = Assert.Throws<AggregateException>(() => connection.OpenAsync().Wait());

// assert
Assert.IsTrue(thrown.InnerException is TaskCanceledException || thrown.InnerException is SnowflakeDbException);
if (thrown.InnerException is SnowflakeDbException)
SnowflakeDbExceptionAssert.HasErrorCode(thrown.InnerException, SFError.INTERNAL_ERROR);
Assert.AreEqual(ConnectionState.Closed, connection.State);
}
}

[Test]
public void TestOpenAsyncThrowExceptionWhenOperationIsCancelled()
{
// arrange
var connectionString = "account=testAccount;user=testUser;password=testPassword;useProxy=true;proxyHost=no.such.pro.xy;proxyPort=8080;";
using (var connection = new SnowflakeDbConnection(connectionString))
{
var shortCancellation = new CancellationTokenSource(TimeSpan.FromSeconds(5));

// act
var thrown = Assert.Throws<AggregateException>(() => connection.OpenAsync(shortCancellation.Token).Wait());

// assert
Assert.IsInstanceOf<TaskCanceledException>(thrown.InnerException);
Assert.AreEqual(ConnectionState.Closed, connection.State);
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Snowflake.Data/Client/SnowflakeDbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public override Task OpenAsync(CancellationToken cancellationToken)
{
_connectionState = ConnectionState.Closed;
logger.Debug("Connection canceled");
throw new TaskCanceledException("Connecting was cancelled");
}
else
{
Expand All @@ -330,8 +331,7 @@ public override Task OpenAsync(CancellationToken cancellationToken)
logger.Debug($"Connection open with pooled session: {SfSession.sessionId}");
OnSessionEstablished();
}
},
cancellationToken);
}, TaskContinuationOptions.None); // this continuation should be executed always (even if the whole operation was canceled) because it sets the proper state of the connection
}

public Mutex GetArrayBindingMutex()
Expand Down
2 changes: 1 addition & 1 deletion Snowflake.Data/Snowflake.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Company>Snowflake Computing, Inc</Company>
<Product>Snowflake Connector for .NET</Product>
<Authors>Snowflake</Authors>
<Version>4.0.0</Version>
<Version>4.1.0</Version>
<DebugType>Full</DebugType>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
Expand Down
8 changes: 8 additions & 0 deletions deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ dotnet build Snowflake.Data\Snowflake.Data.csproj -c Release --force -v n /p:Sig

dotnet pack Snowflake.Data\Snowflake.Data.csproj -c Release --force -v n --no-build --output %ROOT_DIR%

aws s3 cp s3://sfc-eng-jenkins/repository/net/sign-artifact.exe .
@For /F Delims^= %%G In ('""certutil.exe" -HashFile "sign-artifact.exe" SHA512|"find.exe" /V ":""')Do @Set "SHA=%%G"
if not %SHA%==94f0b4a78979ded42f7f8c8ce2534691f9f874888bcf7963876f5be881cf6d0ce00e6f8d3e656492249fcfcb890ad656745f2cf68f98e828eb02ded6189a87d4 (
echo "Failed to verify the sha for the signing script"
exit 1
)
sign-artifact.exe sign-artifact -o snowflakedb -r snowflake-connector-net -t v%VERSION% -l 20 -v -u -f Snowflake.Data.%VERSION%.nupkg

dotnet nuget push Snowflake.Data.%VERSION%.nupkg -k %API_KEY% -s https://api.nuget.org/v3/index.json

0 comments on commit 14476a2

Please sign in to comment.