Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-893834 tests fix for Arrow #798

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

namespace Snowflake.Data.Tests.IntegrationTests
{
// TODO: enable tests for Arrow
//[TestFixture(ResultFormat.ARROW)]
[TestFixture(ResultFormat.ARROW)]
[TestFixture(ResultFormat.JSON)]
class SFDbDataReaderIT : SFBaseTest
{
Expand Down Expand Up @@ -186,7 +185,7 @@ public void TestGetDate(string inputTimeStr)
[Test]
public void TestDateOutputFormat()
{
using (IDbConnection conn = new SnowflakeDbConnection())
using (IDbConnection conn = CreateAndOpenConnection())
{
conn.ConnectionString = ConnectionString;
conn.Open();
Expand All @@ -200,6 +199,7 @@ public void TestDateOutputFormat()
cmd.CommandText = $"select TO_DATE('2013-05-17')";
IDataReader reader = cmd.ExecuteReader();

ValidateResultFormat(reader);
Assert.IsTrue(reader.Read());
Assert.AreEqual("05/17/2013", reader.GetString(0));

Expand Down Expand Up @@ -607,7 +607,7 @@ public void TestGetBoolean()
[Test]
public void TestGetByte()
{
using (IDbConnection conn = new SnowflakeDbConnection())
using (IDbConnection conn = CreateAndOpenConnection())
{
// Arrange
conn.ConnectionString = ConnectionString;
Expand Down Expand Up @@ -639,6 +639,7 @@ public void TestGetByte()
while (reader.Read())
{
// Assert
ValidateResultFormat(reader);
Assert.AreEqual(testBytes[index++], reader.GetByte(0));
}
}
Expand Down Expand Up @@ -790,7 +791,7 @@ public void TestGetBinary()
[Test]
public void TestGetChar()
{
using (IDbConnection conn = new SnowflakeDbConnection())
using (IDbConnection conn = CreateAndOpenConnection())
{
// Arrange
conn.ConnectionString = ConnectionString;
Expand All @@ -812,6 +813,7 @@ public void TestGetChar()
using (IDataReader reader = cmd.ExecuteReader())
{
// Assert
ValidateResultFormat(reader);
Assert.IsTrue(reader.Read());
Assert.AreEqual(testChar, reader.GetChar(0));
}
Expand Down Expand Up @@ -965,7 +967,7 @@ public void TestGetChars()
[Test]
public void TestGetDataTypeName()
{
using (IDbConnection conn = new SnowflakeDbConnection())
using (IDbConnection conn = CreateAndOpenConnection())
{
// Arrange
conn.ConnectionString = ConnectionString;
Expand Down Expand Up @@ -998,6 +1000,7 @@ public void TestGetDataTypeName()
using (DbDataReader reader = (DbDataReader)cmd.ExecuteReader())
{
// Assert
ValidateResultFormat(reader);
Assert.IsTrue(reader.Read());
Assert.AreEqual("TEXT", reader.GetDataTypeName(0));
Assert.AreEqual("BINARY", reader.GetDataTypeName(1));
Expand Down
16 changes: 7 additions & 9 deletions Snowflake.Data.Tests/UnitTests/Logger/EasyLoggerManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was wrong with the previous form of thread static? It didn't work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to use static field so I removed it. Its because of: https://github.com/snowflakedb/snowflake-connector-net/actions/runs/6585609942/job/17892373465#step:8:4582

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that this test might be flaky. How your change is going to improve the situation? I think that the cause of the error is that we try to remove working directory after the test while logger has not flushed its logs to the file yet - or something like that. I don't see how your change will improve the situation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The process cannot access the file 'C:\Users\runneradmin\AppData\Local\Temp\easy_logging_logs_dkdsyynl.bgd\dotnet\snowflake_dotnet_k0201fjm.log' because it is being used by another process.
The problem might be connected with static field. Since there is no need to use static I changed it to private.


[OneTimeTearDown]
public static void CleanUp()
Expand All @@ -35,21 +33,21 @@ 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]
public void TestThatChangesLogLevel()
{
// arrange
var logger = SFLoggerFactory.GetLogger<SFBlockingChunkDownloaderV3>();
EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Warn, t_directoryLogPath);
EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Warn, _directoryLogPath);

// assert
Assert.IsFalse(logger.IsDebugEnabled());
Expand All @@ -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());
Expand All @@ -74,7 +72,7 @@ public void TestThatLogsToProperFileWithProperLogLevelOnly()
{
// arrange
var logger = SFLoggerFactory.GetLogger<SFBlockingChunkDownloaderV3>();
EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Info, t_directoryLogPath);
EasyLoggerManager.Instance.ReconfigureEasyLogging(EasyLoggingLogLevel.Info, _directoryLogPath);

// act
logger.Debug(DebugMessage);
Expand All @@ -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<string>(s => s.Contains(DebugMessage)));
Assert.That(logLines, Has.Exactly(1).Matches<string>(s => s.Contains(InfoMessage)));
Assert.That(logLines, Has.Exactly(1).Matches<string>(s => s.Contains(WarnMessage)));
Expand Down
Loading