-
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.
Merge branch 'master' of https://github.com/snowflakedb/snowflake-con…
…nector-net into SNOW-916949-Okta-429-Retry
- Loading branch information
Showing
16 changed files
with
951 additions
and
67 deletions.
There are no files selected for viewing
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,99 @@ | ||
using System.Data; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using Mono.Unix.Native; | ||
using NUnit.Framework; | ||
using Snowflake.Data.Client; | ||
using Snowflake.Data.Configuration; | ||
using Snowflake.Data.Core; | ||
using Snowflake.Data.Log; | ||
using static Snowflake.Data.Tests.UnitTests.Configuration.EasyLoggingConfigGenerator; | ||
|
||
namespace Snowflake.Data.Tests.IntegrationTests | ||
{ | ||
[TestFixture, NonParallelizable] | ||
public class EasyLoggingIT: SFBaseTest | ||
{ | ||
private static readonly string s_workingDirectory = Path.Combine(Path.GetTempPath(), "easy_logging_test_configs_", Path.GetRandomFileName()); | ||
|
||
[OneTimeSetUp] | ||
public static void BeforeAll() | ||
{ | ||
if (!Directory.Exists(s_workingDirectory)) | ||
{ | ||
Directory.CreateDirectory(s_workingDirectory); | ||
} | ||
} | ||
|
||
[OneTimeTearDown] | ||
public static void AfterAll() | ||
{ | ||
Directory.Delete(s_workingDirectory, true); | ||
} | ||
|
||
[TearDown] | ||
public static void AfterEach() | ||
{ | ||
EasyLoggingStarter.Instance.Reset(EasyLoggingLogLevel.Warn); | ||
} | ||
|
||
[Test] | ||
public void TestEnableEasyLogging() | ||
{ | ||
// arrange | ||
var configFilePath = CreateConfigTempFile(s_workingDirectory, Config("WARN", s_workingDirectory)); | ||
using (IDbConnection conn = new SnowflakeDbConnection()) | ||
{ | ||
conn.ConnectionString = ConnectionString + $"CLIENT_CONFIG_FILE={configFilePath}"; | ||
|
||
// act | ||
conn.Open(); | ||
|
||
// assert | ||
Assert.IsTrue(EasyLoggerManager.HasEasyLoggingAppender()); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TestFailToEnableEasyLoggingForWrongConfiguration() | ||
{ | ||
// arrange | ||
var configFilePath = CreateConfigTempFile(s_workingDirectory, "random config content"); | ||
using (IDbConnection conn = new SnowflakeDbConnection()) | ||
{ | ||
conn.ConnectionString = ConnectionString + $"CLIENT_CONFIG_FILE={configFilePath}"; | ||
|
||
// act | ||
var thrown = Assert.Throws<SnowflakeDbException>(() => conn.Open()); | ||
|
||
// assert | ||
Assert.That(thrown.Message, Does.Contain("Connection string is invalid: Unable to connect")); | ||
Assert.IsFalse(EasyLoggerManager.HasEasyLoggingAppender()); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TestFailToEnableEasyLoggingWhenConfigHasWrongPermissions() | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
Assert.Ignore("skip test on Windows"); | ||
} | ||
|
||
// arrange | ||
var configFilePath = CreateConfigTempFile(s_workingDirectory, Config("WARN", s_workingDirectory)); | ||
Syscall.chmod(configFilePath, FilePermissions.S_IRUSR | FilePermissions.S_IWUSR | FilePermissions.S_IWGRP); | ||
using (IDbConnection conn = new SnowflakeDbConnection()) | ||
{ | ||
conn.ConnectionString = ConnectionString + $"CLIENT_CONFIG_FILE={configFilePath}"; | ||
|
||
// act | ||
var thrown = Assert.Throws<SnowflakeDbException>(() => conn.Open()); | ||
|
||
// assert | ||
Assert.That(thrown.Message, Does.Contain("Connection string is invalid: Unable to connect")); | ||
Assert.IsFalse(EasyLoggerManager.HasEasyLoggingAppender()); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.