diff --git a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs index ee1442b56..0161bf999 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs @@ -1711,40 +1711,37 @@ public void TestCancelLoginBeforeTimeout() [Test] public void TestAsyncLoginTimeout() { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + using (var conn = new MockSnowflakeDbConnection()) { - using (var conn = new MockSnowflakeDbConnection()) - { - int timeoutSec = 5; - string loginTimeOut5sec = String.Format(ConnectionString + "connection_timeout={0}", - timeoutSec); - conn.ConnectionString = loginTimeOut5sec; + int timeoutSec = 5; + string loginTimeOut5sec = String.Format(ConnectionString + "connection_timeout={0}", + timeoutSec); + conn.ConnectionString = loginTimeOut5sec; - Assert.AreEqual(conn.State, ConnectionState.Closed); + Assert.AreEqual(conn.State, ConnectionState.Closed); - Stopwatch stopwatch = Stopwatch.StartNew(); - try - { - Task connectTask = conn.OpenAsync(CancellationToken.None); - connectTask.Wait(); - } - catch (AggregateException e) - { - Assert.AreEqual(SFError.INTERNAL_ERROR.GetAttribute().errorCode, - ((SnowflakeDbException)e.InnerException).ErrorCode); + Stopwatch stopwatch = Stopwatch.StartNew(); + try + { + Task connectTask = conn.OpenAsync(CancellationToken.None); + connectTask.Wait(); + } + catch (AggregateException e) + { + Assert.AreEqual(SFError.INTERNAL_ERROR.GetAttribute().errorCode, + ((SnowflakeDbException)e.InnerException).ErrorCode); - } - stopwatch.Stop(); - int detla = 10; //in case server time slower. + } + stopwatch.Stop(); + int detla = 10; //in case server time slower. - // Should timeout after 5sec - Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, 5 * 1000 - detla); - // But never more than 1 sec (max backoff) after the default timeout - Assert.LessOrEqual(stopwatch.ElapsedMilliseconds, (6) * 1000); + // Should timeout after 5sec + Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, 5 * 1000 - detla); + // But never more than 2 sec (max backoff) after the default timeout + Assert.LessOrEqual(stopwatch.ElapsedMilliseconds, 7 * 1000); - Assert.AreEqual(ConnectionState.Closed, conn.State); - Assert.AreEqual(5, conn.ConnectionTimeout); - } + Assert.AreEqual(ConnectionState.Closed, conn.State); + Assert.AreEqual(5, conn.ConnectionTimeout); } } diff --git a/Snowflake.Data.Tests/UnitTests/Logger/EasyLoggerManagerTest.cs b/Snowflake.Data.Tests/UnitTests/Logger/EasyLoggerManagerTest.cs index feeb728b9..a648e914f 100644 --- a/Snowflake.Data.Tests/UnitTests/Logger/EasyLoggerManagerTest.cs +++ b/Snowflake.Data.Tests/UnitTests/Logger/EasyLoggerManagerTest.cs @@ -22,9 +22,7 @@ public class EasyLoggerManagerTest private const string ErrorMessage = "Easy logging Error message"; private const string FatalMessage = "Easy logging Fatal message"; private static readonly string s_logsDirectory = Path.GetTempPath(); - - [ThreadStatic] - private static string t_directoryLogPath; + private string _directoryLogPath; [OneTimeTearDown] public static void CleanUp() @@ -35,13 +33,13 @@ public static void CleanUp() [SetUp] public void BeforeEach() { - t_directoryLogPath = RandomLogsDirectoryPath(); + _directoryLogPath = RandomLogsDirectoryPath(); } [TearDown] public void AfterEach() { - EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Warn, t_directoryLogPath); + EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Warn, _directoryLogPath); } [Test] @@ -49,7 +47,7 @@ public void TestThatChangesLogLevel() { // arrange var logger = SFLoggerFactory.GetLogger(); - EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Warn, t_directoryLogPath); + EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Warn, _directoryLogPath); // assert Assert.IsFalse(logger.IsDebugEnabled()); @@ -59,7 +57,7 @@ public void TestThatChangesLogLevel() Assert.IsTrue(logger.IsFatalEnabled()); // act - EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Debug, t_directoryLogPath); + EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Debug, _directoryLogPath); // assert Assert.IsTrue(logger.IsDebugEnabled()); @@ -74,7 +72,7 @@ public void TestThatLogsToProperFileWithProperLogLevelOnly() { // arrange var logger = SFLoggerFactory.GetLogger(); - EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Info, t_directoryLogPath); + EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Info, _directoryLogPath); // act logger.Debug(DebugMessage); @@ -84,7 +82,7 @@ public void TestThatLogsToProperFileWithProperLogLevelOnly() logger.Fatal(FatalMessage); // assert - var logLines = File.ReadLines(FindLogFilePath(t_directoryLogPath)); + var logLines = File.ReadLines(FindLogFilePath(_directoryLogPath)); Assert.That(logLines, Has.Exactly(0).Matches(s => s.Contains(DebugMessage))); Assert.That(logLines, Has.Exactly(1).Matches(s => s.Contains(InfoMessage))); Assert.That(logLines, Has.Exactly(1).Matches(s => s.Contains(WarnMessage)));